mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Compare commits
1012 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ffc48769a | |||
| 4a74408eee | |||
| c729fbd652 | |||
| 608968aa83 | |||
| 5caf6244a3 | |||
| eaaba6462e | |||
| 92e9d4ec3a | |||
| fbb2cabe77 | |||
| 3fd2384b81 | |||
| e851a41d78 | |||
| 5e0f95b948 | |||
| f7aa2e0d44 | |||
| a11b7a8293 | |||
| e6062532fa | |||
| e7d35d51fa | |||
| c524f669c7 | |||
| 203ac0f818 | |||
| eab556e1e0 | |||
| 9819ebc095 | |||
| fb6db3dcfc | |||
| 7601c21612 | |||
| cb9b08eca1 | |||
| 48b8aa51cd | |||
| 6e8241b78d | |||
| f61076a5d8 | |||
| 5f5fcef962 | |||
| 12ce6b5c15 | |||
| 27b1f8f446 | |||
| c6e1e3acdc | |||
| 53661d55ae | |||
| 120b7a61c3 | |||
| 470d34ddbb | |||
| a0c2718adb | |||
| a836892edb | |||
| 25518a12f1 | |||
| 2aa15ab3ff | |||
| 807ec00b85 | |||
| 53305d4a7e | |||
| 2863f950d6 | |||
| 12d2bd4adb | |||
| 24ee7b5080 | |||
| aab390c51d | |||
| 8b4871a28d | |||
| cf31243c74 | |||
| 88b689bcf1 | |||
| f589237e23 | |||
| 7da6e9086c | |||
| 68043f4de9 | |||
| c0eaff3608 | |||
| bcce25900b | |||
| 34ba32ff27 | |||
| 857007372d | |||
| 6a661e1e28 | |||
| cc5a6f3b86 | |||
| aa7a964139 | |||
| 73a8369631 | |||
| 6a8f57e5d7 | |||
| eb94dfb442 | |||
| 7be0c78533 | |||
| 97d9ea00fe | |||
| 491502a349 | |||
| 0e4eed0ba1 | |||
| 8ffcc76011 | |||
| c020a7bb67 | |||
| e268fdc0ed | |||
| bb925fe488 | |||
| 1dbdb1cfc9 | |||
| 30b33a4413 | |||
| 945ad277ea | |||
| 6f4e35cc0e | |||
| df8f61877e | |||
| ddb482b14a | |||
| f378f1d585 | |||
| 36f11a54e1 | |||
| f8d0d6365e | |||
| cff79609c8 | |||
| c434198ee5 | |||
| ef70b0baa4 | |||
| b4ddf3d8c5 | |||
| 42b25d747b | |||
| a66b5e2c13 | |||
| 8f0b72be9e | |||
| 15dc6f70dc | |||
| 95014f311d | |||
| 6dfd7e3da2 | |||
| cfe84b953c | |||
| f78b9468dd | |||
| 034dc3b0dd | |||
| 80d1f2ddfa | |||
| d05714995c | |||
| 252e871a8b | |||
| 59b91d6c31 | |||
| 5992c46606 | |||
| 00d2f34888 | |||
| a91a11e533 | |||
| 2423cddb00 | |||
| eb54e5c55c | |||
| 514e6df460 | |||
| 94253e8b83 | |||
| a6baedd02c | |||
| c63092781a | |||
| 2d1350a9d6 | |||
| 2200e13c71 | |||
| 633b0e56a5 | |||
| 8393d755f6 | |||
| 7474ad81d9 | |||
| e805a55a5b | |||
| 14032c6653 | |||
| 17233c687e | |||
| 57cbde3393 | |||
| 579781e35e | |||
| 66f3c1ae79 | |||
| 1ad814a191 | |||
| 221342fb25 | |||
| 5718d09e39 | |||
| b67523550f | |||
| 5a791e6e06 | |||
| 61e76e767d | |||
| 51b5fdba25 | |||
| 379ea15d16 | |||
| 4437e0c3b9 | |||
| fad3a6bf15 | |||
| ab0f0f26a1 | |||
| b7ad95beaa | |||
| 2c8da29f3a | |||
| efd3fafa25 | |||
| d61528b2d5 | |||
| e8b2c5682e | |||
| ce2a65db85 | |||
| 2f3d4df2f2 | |||
| 6205981235 | |||
| 28a78003f0 | |||
| e2a99d24ec | |||
| 601e3aaf98 | |||
| dd2fd39c05 | |||
| 84887d3011 | |||
| 9e298ea1bb | |||
| 65ba2e0adf | |||
| 42e1fe301c | |||
| 7fe97376c2 | |||
| 03407a9da0 | |||
| d56b2b56fb | |||
| d47b1f3b70 | |||
| 090ee46f4a | |||
| dbb57cd0ae | |||
| 0c07836fba | |||
| 835acd3f31 | |||
| f8b03d4a4b | |||
| 413fba14ab | |||
| 44d7435a48 | |||
| f77f2876ff | |||
| 914f57f28d | |||
| ed94136548 | |||
| c973aaabc5 | |||
| 3267fb90c6 | |||
| b10fedde56 | |||
| 8817907647 | |||
| 398ebbac98 | |||
| c43498c6ad | |||
| 389fa5d38e | |||
| 2a1f46c42d | |||
| e225850cc6 | |||
| 10e1de74d2 | |||
| 292dfc2d72 | |||
| b085158d59 | |||
| 904640c9ae | |||
| 06455fc0cd | |||
| 3b191bf2dd | |||
| 56bcdfd7d9 | |||
| 14089b1e7c | |||
| 5f6077bc62 | |||
| 19a914be16 | |||
| f1c91a8d34 | |||
| 5a71f4a0ca | |||
| a449731a57 | |||
| e801e336ed | |||
| 0d01b97b75 | |||
| 7fedfa0380 | |||
| 4a297a2443 | |||
| 108d07c655 | |||
| 34a9ce6eb3 | |||
| f1e50ecab3 | |||
| a0ce12f8ba | |||
| 3d6659112f | |||
| 1055f9d208 | |||
| 403c3c3d03 | |||
| 877b175565 | |||
| 82f889d9b8 | |||
| 7eb37bd1dd | |||
| 384fa95680 | |||
| 2266a8c85f | |||
| 83761d5f8e | |||
| ecbd5b0574 | |||
| c8d8b1fbcd | |||
| 92fb3fb33f | |||
| 02bc17be6f | |||
| 534dcbe017 | |||
| 12cd3b55ec | |||
| bbfa239036 | |||
| c96630c9f0 | |||
| 60f1c9dcdf | |||
| 82aff110b7 | |||
| 26321795f7 | |||
| f780ee12a0 | |||
| e56d6054aa | |||
| 36222c9eed | |||
| 8436dac090 | |||
| 713ec7be45 | |||
| 42569cfd61 | |||
| 7c8a3da0ac | |||
| 9d25bd583f | |||
| 85af8735ab | |||
| ccea0a831a | |||
| 65a6674c6e | |||
| 9698b93d10 | |||
| 78ce5b815d | |||
| 6aec71d7ee | |||
| 83b16ab7b7 | |||
| 54c81cbde4 | |||
| 3cf535926a | |||
| 35738bcadd | |||
| 184862582c | |||
| c4f9ff0285 | |||
| a75840d19c | |||
| f06c44f1f1 | |||
| 844f1d0281 | |||
| a2e9bfbaf4 | |||
| 2e45095e8d | |||
| 027da35c33 | |||
| 2c1161a6f9 | |||
| 5f4b48da34 | |||
| 4e1d396ce1 | |||
| 98bd0a06dc | |||
| f57630d92b | |||
| ae2e4af4a1 | |||
| cb66f82c1d | |||
| 1389fd67ab | |||
| 7a4c5e9421 | |||
| cf1ba0c4e1 | |||
| ebdb0eb0c1 | |||
| 4d80419f29 | |||
| 32d71cf85f | |||
| 2876670de3 | |||
| 36d4c29b11 | |||
| c8930cc279 | |||
| 01f4a173ab | |||
| daf3368d2e | |||
| f6fd3abd31 | |||
| f1c52e426b | |||
| 203dc3bb48 | |||
| 7b8ab4e5c6 | |||
| 73891d619a | |||
| fe4fbc2c3b | |||
| 2ebf4e084a | |||
| df22bafe6d | |||
| c49d5d5252 | |||
| 104502c5be | |||
| 7d6cf66303 | |||
| d1b08486ae | |||
| 205022ceee | |||
| 47998c03f8 | |||
| 27cddfb8e9 | |||
| 3f116468c6 | |||
| 8c2563be41 | |||
| 2493083935 | |||
| e15928b49e | |||
| df434298b8 | |||
| c401168bea | |||
| 0b1f626efd | |||
| 74367093c8 | |||
| 7a472d85ef | |||
| 81c5fae56f | |||
| 9e9926a2f0 | |||
| 6e5da9dbe3 | |||
| b97b650ab3 | |||
| a1d2258ac3 | |||
| 8f04c8b16c | |||
| 2d674fc151 | |||
| 479179638e | |||
| a3d74704e5 | |||
| 90aac764dd | |||
| 46470d92a0 | |||
| a5cd62f7bf | |||
| 12ea8477a3 | |||
| 87db636c61 | |||
| c5c620bab0 | |||
| d84c7e5143 | |||
| 8ba88892d7 | |||
| eb2901bd69 | |||
| c89ae6e537 | |||
| 25c36fb05f | |||
| 71ba54b2f4 | |||
| 18ce529256 | |||
| 26e0f408f0 | |||
| fe494297e4 | |||
| c3569211d5 | |||
| dcc5a2cb22 | |||
| 67842df9e2 | |||
| 8226bd25c4 | |||
| 8efe7bafaa | |||
| 2124361ff7 | |||
| 42459cad02 | |||
| 0def2dbb73 | |||
| 1b0ff57562 | |||
| 95ce21d407 | |||
| ec353dbdda | |||
| f056e713c3 | |||
| 4046d9f850 | |||
| aa55cdb735 | |||
| ec8d39d059 | |||
| d1a3b530be | |||
| a55aed5f42 | |||
| b067e0ca5d | |||
| 85e133a051 | |||
| 4a086cf517 | |||
| fb22028be3 | |||
| 6728b40ad3 | |||
| e77af4ae33 | |||
| 7bc017601f | |||
| decf6cab5e | |||
| 2b635edce6 | |||
| 2aa18ca3e9 | |||
| 4dc788ff84 | |||
| cec700525c | |||
| 20b3261204 | |||
| ab8cf31ae9 | |||
| c0ae812aa2 | |||
| 8b87c4b96a | |||
| cbb21f3cf2 | |||
| 4189214d04 | |||
| e6ed853905 | |||
| 59915a3fc9 | |||
| 22816a4c43 | |||
| 4d84999452 | |||
| 6d4b778303 | |||
| df0b83332d | |||
| be1207e5e4 | |||
| 1255bd8d4b | |||
| f5d9a2a9c1 | |||
| edcbbee979 | |||
| 70ff4af4fa | |||
| 6a395d88ff | |||
| 1f4fdfd599 | |||
| 0c00652f6b | |||
| 91e10a3105 | |||
| 08086178bd | |||
| 839cffdefe | |||
| a362fd80df | |||
| 1237faef80 | |||
| a0d9d6db5b | |||
| 8533b45ce9 | |||
| dcd4f8f5db | |||
| 0cad2d2a83 | |||
| 73316e10a0 | |||
| 69cd9cc1a6 | |||
| 594a93316c | |||
| c6d9ce8fd3 | |||
| 9deaddcdff | |||
| 98b6e1d5fe | |||
| 57dc28fe99 | |||
| c8794c89c7 | |||
| 18edd917e3 | |||
| 6032d86e23 | |||
| 64a9e92390 | |||
| b6075e11b8 | |||
| c19764e557 | |||
| 71768de939 | |||
| f943261847 | |||
| 7763b58a60 | |||
| 6f8be3f693 | |||
| 6113dc1b99 | |||
| 4d4f291553 | |||
| 29faf164b9 | |||
| 435a3e337b | |||
| f92e880d3d | |||
| 8a76fadaa3 | |||
| be5247921d | |||
| e3b42bf93b | |||
| f34a0a874a | |||
| c71dc78cd4 | |||
| f3dde79ed6 | |||
| da0904df2d | |||
| c08a0edea1 | |||
| 27b55ea761 | |||
| 8943441115 | |||
| 6674a024fc | |||
| ee35263e48 | |||
| 84596bff09 | |||
| e3a6d74945 | |||
| dd3c1d3b8c | |||
| 3a5cd12dee | |||
| 2d2499f610 | |||
| c11895f529 | |||
| 004a1cd64a | |||
| d0b2e60edc | |||
| 8e1f31f543 | |||
| a2869109f0 | |||
| 431b3b4323 | |||
| 9966903ae1 | |||
| 8a67858068 | |||
| f5862dacb6 | |||
| 67f9406cbe | |||
| f99a135eda | |||
| e1ec45c948 | |||
| 8acd05f12a | |||
| be01ea734d | |||
| d01a2038ae | |||
| 0e6dd32858 | |||
| bc7923e382 | |||
| c608c232a2 | |||
| 5f9bb6249e | |||
| b76a691bcf | |||
| bc6a355370 | |||
| 37911e60d8 | |||
| c92aa95726 | |||
| 59c6661db0 | |||
| f0453bd853 | |||
| 116c8d0ddf | |||
| 16821b877c | |||
| 45c5f0a549 | |||
| f46eff4eb0 | |||
| 1073175c77 | |||
| 34bfd7ef51 | |||
| 94b236872c | |||
| 7abaae39ec | |||
| 940a90130d | |||
| a42ca2eeb3 | |||
| bf80c94125 | |||
| d0580df339 | |||
| ea5a3e557f | |||
| 22576f4dfe | |||
| 4ca89db22d | |||
| dc88a2bcf2 | |||
| 71f4281080 | |||
| 4bd1e3dcbd | |||
| 30373d2566 | |||
| 914d9662d3 | |||
| ad23c10600 | |||
| a50a355e63 | |||
| 7d67d60fb1 | |||
| fc1d85bf59 | |||
| 125f9f0be1 | |||
| 8e7af7f089 | |||
| a65b5df5da | |||
| 2370c8a058 | |||
| 2b3c140f04 | |||
| ec32022bdf | |||
| 898ca38257 | |||
| 5aac909046 | |||
| 592f8d8c1b | |||
| a9807d8f54 | |||
| d9c0231475 | |||
| f0b606ff77 | |||
| 3542c98d45 | |||
| 00f03c5739 | |||
| 4f6c493b87 | |||
| 73c2a12449 | |||
| 99a9c10b57 | |||
| 9b131b5f7e | |||
| 5232ea1ee6 | |||
| d8d4ea857a | |||
| f3880c60a6 | |||
| 6045608330 | |||
| 0a4b1b8d68 | |||
| 25c17b107e | |||
| 2938860b3f | |||
| 2e33844f0d | |||
| 1e4395a8e1 | |||
| 70c605a03d | |||
| 84e2fa79a0 | |||
| a8844de7b5 | |||
| 0369431ebd | |||
| 50e8f91064 | |||
| fd0ac962fb | |||
| fc8e848a54 | |||
| 26d288bd11 | |||
| adf43e7d2a | |||
| 047764f476 | |||
| 6d4f66472e | |||
| eba176c299 | |||
| 00e43a9022 | |||
| 9148a37624 | |||
| 019b7c5a66 | |||
| 59e825ee02 | |||
| bcc669f3f7 | |||
| e5313246a7 | |||
| 97af608030 | |||
| 181b448c4d | |||
| 289a8da39e | |||
| b85c77283b | |||
| 0742e12f0b | |||
| 9b659736da | |||
| 69a6765bf7 | |||
| 3f68d6d8a7 | |||
| 83b8cd0152 | |||
| 4e542a65a3 | |||
| aa46e31c6d | |||
| ddbd074678 | |||
| 5fdb42a7c9 | |||
| 6c252d8cdc | |||
| 636b7ec0c4 | |||
| 534645a12f | |||
| 09c84a0164 | |||
| cd1c8693d8 | |||
| 325cbd7c84 | |||
| b19cd93738 | |||
| 602b08d9c7 | |||
| 019162486c | |||
| fe7b3f1228 | |||
| 1bc1f3d311 | |||
| a8a51db42b | |||
| 70d49446e9 | |||
| a2620f72c7 | |||
| 50d44e06e3 | |||
| c5fc8e03ff | |||
| 0aa5e43a14 | |||
| 235889ddbb | |||
| c67e75b68f | |||
| 047ad4ff71 | |||
| ae8bb718cd | |||
| 7bbe1a53cf | |||
| b6fe4cc807 | |||
| eecb64a973 | |||
| e72a053cca | |||
| e43997dbb5 | |||
| 813ff37967 | |||
| b8a24b36ce | |||
| d2f13a8259 | |||
| 94d84c5fad | |||
| 1eb2fa9efb | |||
| 7e48fa58eb | |||
| 59ec224009 | |||
| 0ed2cbc931 | |||
| 1ff33e6e4d | |||
| b450811e4b | |||
| 87160cb297 | |||
| dcdd6af5a8 | |||
| badc3bd312 | |||
| b1ed8bc0d1 | |||
| 3b84acfc48 | |||
| 436d7e4eaf | |||
| 910d7dab1f | |||
| b0e9d76ced | |||
| 05b259fe2e | |||
| 6aabd6cc7a | |||
| 19c914db51 | |||
| c057d29192 | |||
| e29de5dd2b | |||
| 1654dfe3a9 | |||
| d3a124c820 | |||
| 86cc4f3aa4 | |||
| 9de87d96cc | |||
| 65f502bc99 | |||
| fcb537bacd | |||
| 3dbf392d48 | |||
| 2b43d4f477 | |||
| cac4a7e5b5 | |||
| 3fddce67c6 | |||
| a5c04baec1 | |||
| 361bb1197f | |||
| 0b33eb0929 | |||
| 8ed1a274e1 | |||
| 70e1b4ddf0 | |||
| bab86d65cb | |||
| aef3019152 | |||
| 28b19d6e3e | |||
| e728ffd5bf | |||
| 4b1455579f | |||
| 1033f2b1bd | |||
| 0a439570a0 | |||
| 50365b7741 | |||
| 62359f70ff | |||
| c5ed507737 | |||
| 7d4a67f2a8 | |||
| d5f152494b | |||
| 1b8acd662f | |||
| 7ad308ea47 | |||
| 6df8ac0342 | |||
| 08112f3821 | |||
| 18ff806d5b | |||
| d0684ac139 | |||
| a8ae9cab08 | |||
| 84535a60f2 | |||
| ca1a0a1108 | |||
| 7d18f49a49 | |||
| 0da947e6b3 | |||
| 6cedc82799 | |||
| b417fb0939 | |||
| cd4176104d | |||
| 5c709f4aaa | |||
| ae5e1f8ece | |||
| a9de6900e5 | |||
| 83b5b86f7d | |||
| ca46171246 | |||
| d4e2e6279c | |||
| 197078e331 | |||
| d0d2faf551 | |||
| a4b5eabccf | |||
| 7b701fee60 | |||
| 99183e98d3 | |||
| c231472ad6 | |||
| 9930076dc5 | |||
| ecb6bcf2e0 | |||
| 74f1295756 | |||
| 3966595f9a | |||
| 0fcc6f5d60 | |||
| 3e45795232 | |||
| 51cb56ef2c | |||
| f39ee9c6a1 | |||
| 84ee4d701a | |||
| 267c5a747b | |||
| edadcfa7d9 | |||
| 62ed6cdc74 | |||
| ce20efb8e7 | |||
| 825b14278e | |||
| 8d4777c81d | |||
| c0b6061a5e | |||
| 2324674dfb | |||
| 53b5afbba9 | |||
| d48d2d7fe2 | |||
| b0bce60c16 | |||
| eff42f6387 | |||
| 5404930112 | |||
| e49febb70f | |||
| 7e680bd9ff | |||
| 766a0c0f25 | |||
| 9fa505027a | |||
| 61c2f094b9 | |||
| 558b17dede | |||
| 86b128dbb3 | |||
| 5560db73bf | |||
| 7349b8f5ce | |||
| 88507fa051 | |||
| 9665dde678 | |||
| 768f4cb7bc | |||
| b15bc194ef | |||
| be4fa03fac | |||
| 164a77e7ad | |||
| 6174f62710 | |||
| d715badbde | |||
| 912de363f4 | |||
| 66e09bc9a4 | |||
| cd7526c973 | |||
| c24f10d647 | |||
| 4bee238cf8 | |||
| f503515082 | |||
| e307065c8e | |||
| 6185f7209e | |||
| a2811d93dd | |||
| 9c5b231b2d | |||
| f2070c9f5d | |||
| 34e414dc31 | |||
| 92d23fb1a8 | |||
| f8b14a1612 | |||
| 8f1345091e | |||
| 17dcf0e82d | |||
| d329674f68 | |||
| cadd1a0074 | |||
| 1625ffa2cf | |||
| 72de03d749 | |||
| 0be1bf551b | |||
| ef0650179b | |||
| 38c62f6461 | |||
| 6fb9d42c3f | |||
| ef04ca9e0f | |||
| 6074f92d48 | |||
| 0b688cd23f | |||
| 59cbaca4d3 | |||
| 66feea6cac | |||
| 7707c9bfba | |||
| 85b1c4060c | |||
| 07bec6bdcd | |||
| 159ea22b6b | |||
| 682bd2eedf | |||
| d8a737b4b0 | |||
| af1ea1f7ac | |||
| 3a8a73ef6c | |||
| 4781f0a337 | |||
| 4b8275061e | |||
| 7933fff0dd | |||
| 2c4d3d92c7 | |||
| 15b909e80b | |||
| a82d2363f4 | |||
| 13c4a02157 | |||
| 0042bacd88 | |||
| ffe49bdebe | |||
| 4d721e368a | |||
| 7b7033ac60 | |||
| 552c3ba869 | |||
| 5b41599911 | |||
| b833d512ec | |||
| 5ce38e516e | |||
| 611cf8d86f | |||
| df5ec54fb8 | |||
| a3ec2ac3c5 | |||
| 69830b1851 | |||
| bbbec300a6 | |||
| 6d06fcb414 | |||
| 2aa380752c | |||
| 03850008b9 | |||
| fc9e031454 | |||
| 74d321d901 | |||
| 7bfb38055c | |||
| 81519537ae | |||
| 0f12351a41 | |||
| 7aadbc9607 | |||
| ce65975625 | |||
| a25c443d1f | |||
| c2c7333107 | |||
| cb9e110adb | |||
| 0595ab3eef | |||
| 800294ad4b | |||
| ac58405a71 | |||
| 9bf6ec6fe1 | |||
| 7ae19467b5 | |||
| fe95d5a720 | |||
| 0105518422 | |||
| 22c0bb7dc9 | |||
| b19f81b35b | |||
| 28717d0437 | |||
| 5ea50d1e8d | |||
| e703c3090a | |||
| a79d0e19ad | |||
| 872500c4a5 | |||
| 7eb1065944 | |||
| cdc2aca2cc | |||
| cc2ee923e4 | |||
| f5dba12762 | |||
| 86ff4a1ccf | |||
| 614e254331 | |||
| 6fe6436162 | |||
| 29e4a4940d | |||
| f7913e2c84 | |||
| 73ac5321f5 | |||
| 2e56a47f8c | |||
| 666fc0ba69 | |||
| cfd845ac07 | |||
| 2a8344f75b | |||
| 762138e77e | |||
| d381e499ea | |||
| 0ed3209b00 | |||
| bc547c4290 | |||
| 9e4a8a31e1 | |||
| b900496c40 | |||
| abad8977b6 | |||
| 6c135261b2 | |||
| a44573c43b | |||
| cd689c640d | |||
| 378e05c16b | |||
| 486cfd1040 | |||
| 3c795a0dab | |||
| 6fbf0758bc | |||
| 89d855c0b7 | |||
| 1f465a0ef9 | |||
| a47fbd2610 | |||
| 99ed085752 | |||
| c95bc0c7fd | |||
| 11ddb9332c | |||
| 606a5fd537 | |||
| c4b158ff91 | |||
| ec076bfba3 | |||
| 92be112388 | |||
| a83c12c3d5 | |||
| 7f554f3cc4 | |||
| 92b35e6758 | |||
| 91c1d7697f | |||
| 5b27fb506a | |||
| f2b3e5f517 | |||
| 807f5e33ad | |||
| 11330b9253 | |||
| 2af6f68452 | |||
| c38620e966 | |||
| 8254169cf5 | |||
| b6abf0d3f9 | |||
| bd6a6690f2 | |||
| cdbbccbef8 | |||
| cbf2b51e40 | |||
| 13f374660f | |||
| e34b64c979 | |||
| c180047bc1 | |||
| f071a48ec7 | |||
| a1479cc2c1 | |||
| 2feb0c2f61 | |||
| 107582c767 | |||
| 636d6368ee | |||
| 04edc8fe3a | |||
| 559235ac74 | |||
| 5d369afe27 | |||
| 49a5280198 | |||
| e5d1790b7b | |||
| 5b17410f7c | |||
| fed2a277e0 | |||
| d59472bf40 | |||
| 6f48dc2482 | |||
| 8082011546 | |||
| 7628c143f4 | |||
| 5d0a8d2aaf | |||
| 019de554a0 | |||
| 3ee8079f35 | |||
| e4aa2ccd66 | |||
| f37f4cf3b4 | |||
| e7d62d6ef3 | |||
| b29893b938 | |||
| 1c88a566e0 | |||
| 3f37be5a30 | |||
| 9db5cbf9a4 | |||
| 8e6280fc8e | |||
| f8ad289311 | |||
| a9b5233f67 | |||
| e57f22a386 | |||
| 12662e064b | |||
| 1c46034166 | |||
| 2178c5e95e | |||
| b3018ba89e | |||
| e75056a084 | |||
| 51fc891a5c | |||
| 0f34628af7 | |||
| c3cced0f89 | |||
| 397b57dd72 | |||
| 01b581048d | |||
| 438e456ce9 | |||
| b389c1cfe7 | |||
| f19f2bbcde | |||
| f6d927ef3b | |||
| 75b980ac64 | |||
| f723cede2e | |||
| 6c5dd5cf6d | |||
| 3a09da71d8 | |||
| 3cbe60cca2 | |||
| 2674c6b5e0 | |||
| 45d11dde57 | |||
| c7f1843584 | |||
| b1d208891b | |||
| 017a38a54e | |||
| b45403ed75 | |||
| f50ec229de | |||
| 3e33820ee5 | |||
| 73d4f12c14 | |||
| 20c08eab73 | |||
| eb136ebba6 | |||
| 1a9d8e9447 | |||
| 0eb1bfa874 | |||
| 5ebb234746 | |||
| 394101d6ed | |||
| 3c6983a2bd | |||
| 56bda8917d | |||
| 6936ec7dbd | |||
| e730048f69 | |||
| 751cee8e67 | |||
| 0608227e10 | |||
| 2210ed4fdd | |||
| 65061948af | |||
| 55dabd2858 | |||
| 88e6daa315 | |||
| baff521b63 | |||
| bbba9ac121 | |||
| 1fbdca83f5 | |||
| 3a0039d204 | |||
| aa70199ce1 | |||
| fcdd833059 | |||
| ba940dec38 | |||
| 42f449880c | |||
| 2610a47c89 | |||
| 55260a8d3c | |||
| 43e4e1b624 | |||
| e89501a3ad | |||
| 992a81dcaa | |||
| 2e772510ea | |||
| c6fb99357c | |||
| 7190028b23 | |||
| bafdc44d37 | |||
| 1af16afb89 | |||
| b9cf65e905 | |||
| 8a3a75cc16 | |||
| fbe18e80f6 | |||
| 06bda58a2c | |||
| e89ae986fa | |||
| 8f99083726 | |||
| 51cef2651e | |||
| 0205238dca | |||
| a0c658b012 | |||
| 22dfc1daf1 | |||
| e51a8e047c | |||
| 0a7c60b439 | |||
| a0e1def83b | |||
| 2fc1edfc96 | |||
| 3921fab285 | |||
| 48ed769b18 | |||
| bffe254a81 | |||
| 63fb79b519 | |||
| c51567ae45 | |||
| 97181a90ba | |||
| 981009ac1f | |||
| 96aebbe7f9 | |||
| ed71f62181 | |||
| 888d0cda40 | |||
| 4085bbf758 | |||
| 49f214b275 | |||
| 8e21f808be | |||
| ac22d3c817 | |||
| afa633b7bc | |||
| 62737c777c | |||
| 42d942e19c | |||
| 7267e94be7 | |||
| 184daa155f | |||
| d7a1d2230f | |||
| 9c4f0a984f | |||
| 8fb48c09f7 | |||
| 6e4f9433d0 | |||
| c624967049 | |||
| 20a2dc6ac5 | |||
| b1b2528e50 | |||
| 1bd865120c | |||
| bacc96f4e8 | |||
| cc3f9323bb | |||
| c964aa3333 | |||
| f9ac1665b6 | |||
| 942672ad91 | |||
| 9cceccd645 | |||
| 47ae5197a9 | |||
| c9c759f700 | |||
| 7db612a545 | |||
| 18a4ced07a | |||
| b9b553b8bc | |||
| 0c79f4a00f | |||
| cc626a3b5a | |||
| 14af2a0c0c | |||
| bc348eb8ab | |||
| 6e4dacc0b3 | |||
| e1ebc4e991 | |||
| 67acfc6e25 | |||
| 87984f2c6a | |||
| 15df161b22 | |||
| 988a5626f6 | |||
| 22496742b4 | |||
| bc9c9abab0 | |||
| c6fc7ccb5e | |||
| 93813fec6e | |||
| 7809c4156f | |||
| 37d99201ca | |||
| 5feb1c94a7 | |||
| fd1eb63fee | |||
| cd428fb798 | |||
| 476c513447 | |||
| 639b800787 | |||
| 712689e81a | |||
| 03cefa7bfe | |||
| 2dc76d5009 | |||
| def444d99f | |||
| 5f80e42dac | |||
| 7b0d2d189f | |||
| e0e40405ed | |||
| ff037ebe5f | |||
| 91c0b13743 | |||
| eb9fcf4f08 | |||
| 1f214d232d | |||
| ede39b85f6 | |||
| ff190b1ef4 | |||
| 1a495a5817 | |||
| 09d283a39d | |||
| 8b1b126e3e | |||
| 5384d2f090 | |||
| b4813e6bdf | |||
| 4b52b8df34 | |||
| 60cbc46da1 | |||
| 9e6ef99422 | |||
| 58a83e99c0 | |||
| cc9ab7e582 | |||
| bc93775385 | |||
| b4367c92f3 | |||
| 825c0ffdb4 | |||
| 69f2590359 | |||
| 7060ee4d00 | |||
| 390be6d5b5 | |||
| a385fff3bf | |||
| 7b8fb64f21 | |||
| 0c291c7768 | |||
| 5bf39ceb5d | |||
| 48e07437f0 | |||
| e5766513a4 | |||
| 9cdeb6dfbf | |||
| f9aa411c92 | |||
| 436a1f72a5 | |||
| 7e3e9144de | |||
| c704942b8a | |||
| acedb4a579 | |||
| db0a159229 | |||
| 2eb61a4a99 | |||
| 868ad16041 | |||
| 21c8e6d02d | |||
| fb5cd42c6b | |||
| a36ebaecdc | |||
| 9e9881aacc | |||
| dcaad315e7 | |||
| c95f3eff6e | |||
| d7cbe6e947 | |||
| ad051cdd99 | |||
| b1fe298764 | |||
| b903ff8992 | |||
| 8d5a5d5ceb | |||
| a3a446c197 | |||
| 3da9598add | |||
| 437da0a3d9 | |||
| d026d7dcfb | |||
| 2d8f2c2aea | |||
| 4566105578 | |||
| 4eb9f175a4 | |||
| b2b56b6896 | |||
| d4ef5bc16a | |||
| af4d6f34d8 | |||
| 8f05af8d05 | |||
| 3c229aa2eb |
+4
-4
@@ -1,10 +1,11 @@
|
|||||||
|
# ignore dot files/directories
|
||||||
|
.*
|
||||||
|
!.gitignore
|
||||||
|
|
||||||
*.autosave
|
*.autosave
|
||||||
*.pyc
|
*.pyc
|
||||||
*.user
|
*.user
|
||||||
*~
|
*~
|
||||||
.*.swp
|
|
||||||
.DS_Store
|
|
||||||
.sw[a-z]
|
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
tags
|
tags
|
||||||
tegra/
|
tegra/
|
||||||
@@ -21,4 +22,3 @@ bin/
|
|||||||
*.log
|
*.log
|
||||||
*.tlog
|
*.tlog
|
||||||
build
|
build
|
||||||
.cache
|
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
[tgit]
|
|
||||||
icon = doc/opencv.ico
|
|
||||||
Vendored
-2
@@ -37,6 +37,4 @@ if(WITH_NEON)
|
|||||||
target_compile_definitions(carotene_objs PRIVATE "-DWITH_NEON")
|
target_compile_definitions(carotene_objs PRIVATE "-DWITH_NEON")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(carotene_objs PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
||||||
|
|
||||||
add_library(carotene STATIC EXCLUDE_FROM_ALL "$<TARGET_OBJECTS:carotene_objs>")
|
add_library(carotene STATIC EXCLUDE_FROM_ALL "$<TARGET_OBJECTS:carotene_objs>")
|
||||||
|
|||||||
Vendored
-3
@@ -3,8 +3,6 @@ cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
|
|||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
set(TEGRA_HAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
set(TEGRA_HAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
set(CAROTENE_DIR "${TEGRA_HAL_DIR}/../")
|
set(CAROTENE_DIR "${TEGRA_HAL_DIR}/../")
|
||||||
|
|
||||||
@@ -95,7 +93,6 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${carotene_defs})
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(tegra_hal STATIC $<TARGET_OBJECTS:carotene_objs>)
|
add_library(tegra_hal STATIC $<TARGET_OBJECTS:carotene_objs>)
|
||||||
set_target_properties(tegra_hal PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
||||||
set_target_properties(tegra_hal PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH})
|
set_target_properties(tegra_hal PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH})
|
||||||
set(OPENCV_SRC_DIR "${CMAKE_SOURCE_DIR}")
|
set(OPENCV_SRC_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
|
|||||||
Vendored
+2
-1
@@ -106,7 +106,8 @@ bool isResizeLinearOpenCVSupported(const Size2D &ssize, const Size2D &dsize, u32
|
|||||||
&& !(ssize.width > 0xffffFFFF || ssize.height > 0xffffFFFF)// Restrict image size since internal index evaluation
|
&& !(ssize.width > 0xffffFFFF || ssize.height > 0xffffFFFF)// Restrict image size since internal index evaluation
|
||||||
// is performed with u32
|
// is performed with u32
|
||||||
#endif
|
#endif
|
||||||
&& dsize.width >= 2 && dsize.height >= 8)
|
&& dsize.width >= 2 && dsize.height >= 8
|
||||||
|
&& (2*dsize.width != ssize.width || 2*dsize.height != ssize.height)) // 2x downscaling is performed as area in OpenCV which differs from this implementation
|
||||||
return isSupportedConfiguration();
|
return isSupportedConfiguration();
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Vendored
+6
-6
@@ -1,9 +1,9 @@
|
|||||||
# Binary branch name: ffmpeg/master_20171009
|
# Binaries branch name: ffmpeg/master_20180220
|
||||||
# Binaries were created for OpenCV: 8ac2c5d620b467d3f22802e96c88ddde6da707af
|
# Binaries were created for OpenCV: 9819ebc0954c2df62943ebbd5936d325e5dc89e1
|
||||||
set(FFMPEG_BINARIES_COMMIT "66b1fed06cf3510235f367f96aa26da5cb234a15")
|
ocv_update(FFMPEG_BINARIES_COMMIT "0a0e88972a7ea97708378d0488a65f83e7cc5e69")
|
||||||
set(FFMPEG_FILE_HASH_BIN32 "3ae76b105113d944984b2351c61e21c6")
|
ocv_update(FFMPEG_FILE_HASH_BIN32 "b8120c07962d591e2e9071a1bf566fd0")
|
||||||
set(FFMPEG_FILE_HASH_BIN64 "cf3bb5bc9d393b022ea7a42eb63e794d")
|
ocv_update(FFMPEG_FILE_HASH_BIN64 "dc9c50e7b05482acc25d6ce0ac61bf1d")
|
||||||
set(FFMPEG_FILE_HASH_CMAKE "ec59008da403fb18ab3c1ed66aed583b")
|
ocv_update(FFMPEG_FILE_HASH_CMAKE "3b90f67f4b429e77d3da36698cef700c")
|
||||||
|
|
||||||
function(download_win_ffmpeg script_var)
|
function(download_win_ffmpeg script_var)
|
||||||
set(${script_var} "" PARENT_SCOPE)
|
set(${script_var} "" PARENT_SCOPE)
|
||||||
|
|||||||
Vendored
+1
-1
@@ -21,7 +21,7 @@ add_library(${IPP_IW_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
|||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
|
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wno-unused-function -Wno-missing-braces -Wno-missing-field-initializers")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-missing-braces -Wno-missing-field-initializers")
|
||||||
endif()
|
endif()
|
||||||
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
|
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-self-assign")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-self-assign")
|
||||||
|
|||||||
Vendored
-6
@@ -43,12 +43,6 @@ if(NOT WIN32)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${ITT_LIBRARY} PROPERTIES
|
set_target_properties(${ITT_LIBRARY} PROPERTIES
|
||||||
OUTPUT_NAME ${ITT_LIBRARY}
|
OUTPUT_NAME ${ITT_LIBRARY}
|
||||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||||
|
|||||||
Vendored
+4
-8
@@ -25,16 +25,12 @@ endif(WIN32 AND NOT MINGW)
|
|||||||
|
|
||||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes
|
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes
|
||||||
-Wno-unused-but-set-parameter -Wmissing-declarations -Wunused -Wshadow
|
-Wno-unused-but-set-parameter -Wmissing-declarations -Wunused -Wshadow
|
||||||
-Wsign-compare -Wstrict-overflow)
|
-Wsign-compare -Wstrict-overflow -Wpointer-compare
|
||||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
|
-Wabsolute-value # clang on Linux
|
||||||
|
)
|
||||||
|
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wstrict-prototypes) # clang
|
||||||
ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4018 /wd4101 /wd4244 /wd4267 /wd4715) # vs2005
|
ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4018 /wd4101 /wd4244 /wd4267 /wd4715) # vs2005
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${JASPER_LIBRARY}
|
set_target_properties(${JASPER_LIBRARY}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
OUTPUT_NAME ${JASPER_LIBRARY}
|
OUTPUT_NAME ${JASPER_LIBRARY}
|
||||||
|
|||||||
Vendored
-6
@@ -28,12 +28,6 @@ endif()
|
|||||||
|
|
||||||
add_library(${JPEG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
add_library(${JPEG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1")
|
set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Vendored
+66
-41
@@ -1,8 +1,8 @@
|
|||||||
The Independent JPEG Group's JPEG software
|
The Independent JPEG Group's JPEG software
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
README for release 9 of 13-Jan-2013
|
README for release 9b of 17-Jan-2016
|
||||||
===================================
|
====================================
|
||||||
|
|
||||||
This distribution contains the ninth public release of the Independent JPEG
|
This distribution contains the ninth public release of the Independent JPEG
|
||||||
Group's free JPEG software. You are welcome to redistribute this software and
|
Group's free JPEG software. You are welcome to redistribute this software and
|
||||||
@@ -14,7 +14,7 @@ Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers,
|
|||||||
and other members of the Independent JPEG Group.
|
and other members of the Independent JPEG Group.
|
||||||
|
|
||||||
IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
|
IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
|
||||||
(also known as JPEG, together with ITU-T SG16).
|
(previously known as JPEG, together with ITU-T SG16).
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION ROADMAP
|
DOCUMENTATION ROADMAP
|
||||||
@@ -60,7 +60,7 @@ OVERVIEW
|
|||||||
|
|
||||||
This package contains C software to implement JPEG image encoding, decoding,
|
This package contains C software to implement JPEG image encoding, decoding,
|
||||||
and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
|
and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
|
||||||
method for full-color and gray-scale images.
|
method for full-color and grayscale images.
|
||||||
|
|
||||||
This software implements JPEG baseline, extended-sequential, and progressive
|
This software implements JPEG baseline, extended-sequential, and progressive
|
||||||
compression processes. Provision is made for supporting all variants of these
|
compression processes. Provision is made for supporting all variants of these
|
||||||
@@ -115,7 +115,7 @@ with respect to this software, its quality, accuracy, merchantability, or
|
|||||||
fitness for a particular purpose. This software is provided "AS IS", and you,
|
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.
|
its user, assume the entire risk as to its quality and accuracy.
|
||||||
|
|
||||||
This software is copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding.
|
This software is copyright (C) 1991-2016, Thomas G. Lane, Guido Vollbeding.
|
||||||
All Rights Reserved except as specified below.
|
All Rights Reserved except as specified below.
|
||||||
|
|
||||||
Permission is hereby granted to use, copy, modify, and distribute this
|
Permission is hereby granted to use, copy, modify, and distribute this
|
||||||
@@ -153,16 +153,11 @@ ltmain.sh). Another support script, install-sh, is copyright by X Consortium
|
|||||||
but is also freely distributable.
|
but is also freely distributable.
|
||||||
|
|
||||||
The IJG distribution formerly included code to read and write GIF files.
|
The IJG distribution formerly included code to read and write GIF files.
|
||||||
To avoid entanglement with the Unisys LZW patent, GIF reading support has
|
To avoid entanglement with the Unisys LZW patent (now expired), GIF reading
|
||||||
been removed altogether, and the GIF writer has been simplified to produce
|
support has been removed altogether, and the GIF writer has been simplified
|
||||||
"uncompressed GIFs". This technique does not use the LZW algorithm; the
|
to produce "uncompressed GIFs". This technique does not use the LZW
|
||||||
resulting GIF files are larger than usual, but are readable by all standard
|
algorithm; the resulting GIF files are larger than usual, but are readable
|
||||||
GIF decoders.
|
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."
|
|
||||||
|
|
||||||
|
|
||||||
REFERENCES
|
REFERENCES
|
||||||
@@ -176,8 +171,8 @@ The best short technical introduction to the JPEG compression algorithm is
|
|||||||
Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
|
Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
|
||||||
(Adjacent articles in that issue discuss MPEG motion picture compression,
|
(Adjacent articles in that issue discuss MPEG motion picture compression,
|
||||||
applications of JPEG, and related topics.) If you don't have the CACM issue
|
applications of JPEG, and related topics.) If you don't have the CACM issue
|
||||||
handy, a PostScript file containing a revised version of Wallace's article is
|
handy, a PDF file containing a revised version of Wallace's article is
|
||||||
available at http://www.ijg.org/files/wallace.ps.gz. The file (actually
|
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)
|
a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
|
||||||
omits the sample images that appeared in CACM, but it includes corrections
|
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 some added material. Note: the Wallace article is copyright ACM and IEEE,
|
||||||
@@ -225,14 +220,13 @@ WG1 N 6080 with title "JPEG 9 Lossless Coding", June/July 2012, Paris,
|
|||||||
France.
|
France.
|
||||||
|
|
||||||
The JPEG standard does not specify all details of an interchangeable file
|
The JPEG standard does not specify all details of an interchangeable file
|
||||||
format. For the omitted details we follow the "JFIF" conventions, revision
|
format. For the omitted details we follow the "JFIF" conventions, version 2.
|
||||||
1.02. JFIF 1.02 has been adopted as an Ecma International Technical Report
|
JFIF version 1 has been adopted as Recommendation ITU-T T.871 (05/2011) :
|
||||||
and thus received a formal publication status. It is available as a free
|
Information technology - Digital compression and coding of continuous-tone
|
||||||
download in PDF format from
|
still images: JPEG File Interchange Format (JFIF). It is available as a
|
||||||
http://www.ecma-international.org/publications/techreports/E-TR-098.htm.
|
free download in PDF file format from http://www.itu.int/rec/T-REC-T.871.
|
||||||
A PostScript version of the JFIF document is available at
|
A PDF file of the older JFIF document is available at
|
||||||
http://www.ijg.org/files/jfif.ps.gz. There is also a plain text version at
|
http://www.w3.org/Graphics/JPEG/jfif3.pdf.
|
||||||
http://www.ijg.org/files/jfif.txt.gz, but it is missing the figures.
|
|
||||||
|
|
||||||
The TIFF 6.0 file format specification can be obtained by FTP from
|
The TIFF 6.0 file format specification can be obtained by FTP from
|
||||||
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
|
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
|
||||||
@@ -252,8 +246,8 @@ ARCHIVE LOCATIONS
|
|||||||
The "official" archive site for this software is www.ijg.org.
|
The "official" archive site for this software is www.ijg.org.
|
||||||
The most recent released version can always be found there in
|
The most recent released version can always be found there in
|
||||||
directory "files". This particular version will be archived as
|
directory "files". This particular version will be archived as
|
||||||
http://www.ijg.org/files/jpegsrc.v9.tar.gz, and in Windows-compatible
|
http://www.ijg.org/files/jpegsrc.v9b.tar.gz, and in Windows-compatible
|
||||||
"zip" archive format as http://www.ijg.org/files/jpegsr9.zip.
|
"zip" archive format as http://www.ijg.org/files/jpegsr9b.zip.
|
||||||
|
|
||||||
The JPEG FAQ (Frequently Asked Questions) article is a source of some
|
The JPEG FAQ (Frequently Asked Questions) article is a source of some
|
||||||
general information about JPEG.
|
general information about JPEG.
|
||||||
@@ -280,7 +274,7 @@ Thank to Thomas Wiegand and Gary Sullivan for inviting me to the
|
|||||||
Joint Video Team (MPEG & ITU) meeting in Geneva, Switzerland.
|
Joint Video Team (MPEG & ITU) meeting in Geneva, Switzerland.
|
||||||
|
|
||||||
Thank to Thomas Richter and Daniel Lee for inviting me to the
|
Thank to Thomas Richter and Daniel Lee for inviting me to the
|
||||||
ISO/IEC JTC1/SC29/WG1 (also known as JPEG, together with ITU-T SG16)
|
ISO/IEC JTC1/SC29/WG1 (previously known as JPEG, together with ITU-T SG16)
|
||||||
meeting in Berlin, Germany.
|
meeting in Berlin, Germany.
|
||||||
|
|
||||||
Thank to John Korejwa and Massimo Ballerini for inviting me to
|
Thank to John Korejwa and Massimo Ballerini for inviting me to
|
||||||
@@ -306,10 +300,10 @@ design and development of this singular software package.
|
|||||||
FILE FORMAT WARS
|
FILE FORMAT WARS
|
||||||
================
|
================
|
||||||
|
|
||||||
The ISO/IEC JTC1/SC29/WG1 standards committee (also known as JPEG, together
|
The ISO/IEC JTC1/SC29/WG1 standards committee (previously known as JPEG,
|
||||||
with ITU-T SG16) currently promotes different formats containing the name
|
together with ITU-T SG16) currently promotes different formats containing
|
||||||
"JPEG" which is misleading because these formats are incompatible with
|
the name "JPEG" which is misleading because these formats are incompatible
|
||||||
original DCT-based JPEG and are based on faulty technologies.
|
with original DCT-based JPEG and are based on faulty technologies.
|
||||||
IJG therefore does not and will not support such momentary mistakes
|
IJG therefore does not and will not support such momentary mistakes
|
||||||
(see REFERENCES).
|
(see REFERENCES).
|
||||||
There exist also distributions under the name "OpenJPEG" promoting such
|
There exist also distributions under the name "OpenJPEG" promoting such
|
||||||
@@ -322,9 +316,13 @@ Don't use an incompatible file format!
|
|||||||
(In any case, our decoder will remain capable of reading existing JPEG
|
(In any case, our decoder will remain capable of reading existing JPEG
|
||||||
image files indefinitely.)
|
image files indefinitely.)
|
||||||
|
|
||||||
Furthermore, the ISO committee pretends to be "responsible for the popular
|
The ISO committee pretends to be "responsible for the popular JPEG" in their
|
||||||
JPEG" in their public reports which is not true because they don't respond to
|
public reports which is not true because they don't respond to actual
|
||||||
actual requirements for the maintenance of the original JPEG specification.
|
requirements for the maintenance of the original JPEG specification.
|
||||||
|
Furthermore, the ISO committee pretends to "ensure interoperability" with
|
||||||
|
their standards which is not true because their "standards" support only
|
||||||
|
application-specific and proprietary use cases and contain mathematically
|
||||||
|
incorrect code.
|
||||||
|
|
||||||
There are currently different distributions in circulation containing the
|
There are currently different distributions in circulation containing the
|
||||||
name "libjpeg" which is misleading because they don't have the features and
|
name "libjpeg" which is misleading because they don't have the features and
|
||||||
@@ -332,19 +330,46 @@ are incompatible with formats supported by actual IJG libjpeg distributions.
|
|||||||
One of those fakes is released by members of the ISO committee and just uses
|
One of those fakes is released by members of the ISO committee and just uses
|
||||||
the name of libjpeg for misdirection of people, similar to the abuse of the
|
the name of libjpeg for misdirection of people, similar to the abuse of the
|
||||||
name JPEG as described above, while having nothing in common with actual IJG
|
name JPEG as described above, while having nothing in common with actual IJG
|
||||||
libjpeg distributions.
|
libjpeg distributions and containing mathematically incorrect code.
|
||||||
The other one claims to be a "derivative" or "fork" of the original libjpeg
|
The other one claims to be a "derivative" or "fork" of the original libjpeg,
|
||||||
and violates the license conditions as described under LEGAL ISSUES above.
|
but violates the license conditions as described under LEGAL ISSUES above
|
||||||
We have no sympathy for the release of misleading and illegal distributions
|
and violates basic C programming properties.
|
||||||
derived from obsolete code bases.
|
We have no sympathy for the release of misleading, incorrect and illegal
|
||||||
|
distributions derived from obsolete code bases.
|
||||||
Don't use an obsolete code base!
|
Don't use an obsolete code base!
|
||||||
|
|
||||||
|
According to the UCC (Uniform Commercial Code) law, IJG has the lawful and
|
||||||
|
legal right to foreclose on certain standardization bodies and other
|
||||||
|
institutions or corporations that knowingly perform substantial and
|
||||||
|
systematic deceptive acts and practices, fraud, theft, and damaging of the
|
||||||
|
value of the people of this planet without their knowing, willing and
|
||||||
|
intentional consent.
|
||||||
|
The titles, ownership, and rights of these institutions and all their assets
|
||||||
|
are now duly secured and held in trust for the free people of this planet.
|
||||||
|
People of the planet, on every country, may have a financial interest in
|
||||||
|
the assets of these former principals, agents, and beneficiaries of the
|
||||||
|
foreclosed institutions and corporations.
|
||||||
|
IJG asserts what is: that each man, woman, and child has unalienable value
|
||||||
|
and rights granted and deposited in them by the Creator and not any one of
|
||||||
|
the people is subordinate to any artificial principality, corporate fiction
|
||||||
|
or the special interest of another without their appropriate knowing,
|
||||||
|
willing and intentional consent made by contract or accommodation agreement.
|
||||||
|
IJG expresses that which already was.
|
||||||
|
The people have already determined and demanded that public administration
|
||||||
|
entities, national governments, and their supporting judicial systems must
|
||||||
|
be fully transparent, accountable, and liable.
|
||||||
|
IJG has secured the value for all concerned free people of the planet.
|
||||||
|
|
||||||
|
A partial list of foreclosed institutions and corporations ("Hall of Shame")
|
||||||
|
is currently prepared and will be published later.
|
||||||
|
|
||||||
|
|
||||||
TO DO
|
TO DO
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Version 9 is the second release of a new generation JPEG standard
|
Version 9 is the second release of a new generation JPEG standard
|
||||||
to overcome the limitations of the original JPEG specification.
|
to overcome the limitations of the original JPEG specification,
|
||||||
|
and is the first true source reference JPEG codec.
|
||||||
More features are being prepared for coming releases...
|
More features are being prepared for coming releases...
|
||||||
|
|
||||||
Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org.
|
Please send bug reports, offers of help, etc. to jpeg-info@jpegclub.org.
|
||||||
|
|||||||
Vendored
+50
@@ -1,6 +1,56 @@
|
|||||||
CHANGE LOG for Independent JPEG Group's JPEG software
|
CHANGE LOG for Independent JPEG Group's JPEG software
|
||||||
|
|
||||||
|
|
||||||
|
Version 9b 17-Jan-2016
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Improvements and optimizations in DCT and color calculations.
|
||||||
|
Normalize range limit array composition and access pattern.
|
||||||
|
Thank to Sia Furler and Maddie Ziegler for inspiration.
|
||||||
|
|
||||||
|
Use merged upsample with scaled DCT sizes larger than 8.
|
||||||
|
Thank to Taylor Hatala for inspiration.
|
||||||
|
|
||||||
|
Check for excessive comment lengths in argument parsing in wrjpgcom.c.
|
||||||
|
Thank to Julian Cohen for hint.
|
||||||
|
|
||||||
|
Add makefile.b32 for use with Borland C++ 32-bit (bcc32).
|
||||||
|
Thank to Joe Slater for contribution.
|
||||||
|
|
||||||
|
Document 'f' specifier for jpegtran -crop specification.
|
||||||
|
Thank to Michele Martone for suggestion.
|
||||||
|
|
||||||
|
Use defined value from header instead of hardwired number in rdswitch.c.
|
||||||
|
Thank to Robert Sprowson for hint.
|
||||||
|
|
||||||
|
|
||||||
|
Version 9a 19-Jan-2014
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
Add support for wide gamut color spaces (JFIF version 2).
|
||||||
|
Improve clarity and accuracy in color conversion modules.
|
||||||
|
Note: Requires rebuild of test images.
|
||||||
|
|
||||||
|
Extend the bit depth support to all values from 8 to 12
|
||||||
|
(BITS_IN_JSAMPLE configuration option in jmorecfg.h).
|
||||||
|
jpegtran now supports N bits sample data precision with all N from 8 to 12
|
||||||
|
in a single instance. Thank to Roland Fassauer for inspiration.
|
||||||
|
|
||||||
|
Try to resolve issues with new boolean type definition.
|
||||||
|
Thank also to v4hn for suggestion.
|
||||||
|
|
||||||
|
Enable option to use default Huffman tables for lossless compression
|
||||||
|
(for hardware solution), and in this case improve lossless RGB compression
|
||||||
|
with reversible color transform. Thank to Benny Alexandar for hint.
|
||||||
|
|
||||||
|
Extend the entropy decoding structure, so that extraneous bytes between
|
||||||
|
compressed scan data and following marker can be reported correctly.
|
||||||
|
Thank to Nigel Tao for hint.
|
||||||
|
|
||||||
|
Add jpegtran -wipe option and extension for -crop.
|
||||||
|
Thank to Andrew Senior, David Clunie, and Josef Schmid for suggestion.
|
||||||
|
|
||||||
|
|
||||||
Version 9 13-Jan-2013
|
Version 9 13-Jan-2013
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
-1
@@ -2,6 +2,7 @@
|
|||||||
* jcapistd.c
|
* jcapistd.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
|
* Modified 2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -145,7 +146,7 @@ jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
|||||||
(*cinfo->master->pass_startup) (cinfo);
|
(*cinfo->master->pass_startup) (cinfo);
|
||||||
|
|
||||||
/* Verify that at least one iMCU row has been passed. */
|
/* Verify that at least one iMCU row has been passed. */
|
||||||
lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE;
|
lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size;
|
||||||
if (num_lines < lines_per_iMCU_row)
|
if (num_lines < lines_per_iMCU_row)
|
||||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||||
|
|
||||||
|
|||||||
Vendored
+10
-9
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jcarith.c
|
* jcarith.c
|
||||||
*
|
*
|
||||||
* Developed 1997-2012 by Guido Vollbeding.
|
* Developed 1997-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -362,7 +362,6 @@ METHODDEF(boolean)
|
|||||||
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
JBLOCKROW block;
|
|
||||||
unsigned char *st;
|
unsigned char *st;
|
||||||
int blkn, ci, tbl;
|
int blkn, ci, tbl;
|
||||||
int v, v2, m;
|
int v, v2, m;
|
||||||
@@ -381,14 +380,13 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/* Encode the MCU data blocks */
|
/* Encode the MCU data blocks */
|
||||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||||
block = MCU_data[blkn];
|
|
||||||
ci = cinfo->MCU_membership[blkn];
|
ci = cinfo->MCU_membership[blkn];
|
||||||
tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
|
tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
|
||||||
|
|
||||||
/* Compute the DC value after the required point transform by Al.
|
/* Compute the DC value after the required point transform by Al.
|
||||||
* This is simply an arithmetic right shift.
|
* This is simply an arithmetic right shift.
|
||||||
*/
|
*/
|
||||||
m = IRIGHT_SHIFT((int) ((*block)[0]), cinfo->Al);
|
m = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al);
|
||||||
|
|
||||||
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
|
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
|
||||||
|
|
||||||
@@ -453,11 +451,11 @@ METHODDEF(boolean)
|
|||||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
|
const int * natural_order;
|
||||||
JBLOCKROW block;
|
JBLOCKROW block;
|
||||||
unsigned char *st;
|
unsigned char *st;
|
||||||
int tbl, k, ke;
|
int tbl, k, ke;
|
||||||
int v, v2, m;
|
int v, v2, m;
|
||||||
const int * natural_order;
|
|
||||||
|
|
||||||
/* Emit restart marker if needed */
|
/* Emit restart marker if needed */
|
||||||
if (cinfo->restart_interval) {
|
if (cinfo->restart_interval) {
|
||||||
@@ -552,6 +550,8 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* MCU encoding for DC successive approximation refinement scan.
|
* 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)
|
METHODDEF(boolean)
|
||||||
@@ -593,11 +593,11 @@ METHODDEF(boolean)
|
|||||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
|
const int * natural_order;
|
||||||
JBLOCKROW block;
|
JBLOCKROW block;
|
||||||
unsigned char *st;
|
unsigned char *st;
|
||||||
int tbl, k, ke, kex;
|
int tbl, k, ke, kex;
|
||||||
int v;
|
int v;
|
||||||
const int * natural_order;
|
|
||||||
|
|
||||||
/* Emit restart marker if needed */
|
/* Emit restart marker if needed */
|
||||||
if (cinfo->restart_interval) {
|
if (cinfo->restart_interval) {
|
||||||
@@ -692,12 +692,13 @@ METHODDEF(boolean)
|
|||||||
encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
jpeg_component_info * compptr;
|
const int * natural_order;
|
||||||
JBLOCKROW block;
|
JBLOCKROW block;
|
||||||
unsigned char *st;
|
unsigned char *st;
|
||||||
int blkn, ci, tbl, k, ke;
|
int tbl, k, ke;
|
||||||
int v, v2, m;
|
int v, v2, m;
|
||||||
const int * natural_order;
|
int blkn, ci;
|
||||||
|
jpeg_component_info * compptr;
|
||||||
|
|
||||||
/* Emit restart marker if needed */
|
/* Emit restart marker if needed */
|
||||||
if (cinfo->restart_interval) {
|
if (cinfo->restart_interval) {
|
||||||
|
|||||||
Vendored
+98
-35
@@ -2,7 +2,7 @@
|
|||||||
* jccolor.c
|
* jccolor.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* Modified 2011-2012 by Guido Vollbeding.
|
* Modified 2011-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -29,13 +29,25 @@ typedef my_color_converter * my_cconvert_ptr;
|
|||||||
/**************** RGB -> YCbCr conversion: most common case **************/
|
/**************** RGB -> YCbCr conversion: most common case **************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* YCbCr is defined per CCIR 601-1, except that Cb and Cr are
|
* YCbCr is defined per Recommendation ITU-R BT.601-7 (03/2011),
|
||||||
* normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
|
* previously known as Recommendation CCIR 601-1, except that Cb and Cr
|
||||||
* The conversion equations to be implemented are therefore
|
* are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
|
||||||
* Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
|
* sRGB (standard RGB color space) is defined per IEC 61966-2-1:1999.
|
||||||
* Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE
|
* sYCC (standard luma-chroma-chroma color space with extended gamut)
|
||||||
* Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE
|
* is defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex F.
|
||||||
* (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
|
* bg-sRGB and bg-sYCC (big gamut standard color spaces)
|
||||||
|
* are defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex G.
|
||||||
|
* Note that the derived conversion coefficients given in some of these
|
||||||
|
* documents are imprecise. The general conversion equations are
|
||||||
|
* Y = Kr * R + (1 - Kr - Kb) * G + Kb * B
|
||||||
|
* Cb = 0.5 * (B - Y) / (1 - Kb)
|
||||||
|
* Cr = 0.5 * (R - Y) / (1 - Kr)
|
||||||
|
* With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993
|
||||||
|
* from the 1953 FCC NTSC primaries and CIE Illuminant C),
|
||||||
|
* the conversion equations to be implemented are therefore
|
||||||
|
* Y = 0.299 * R + 0.587 * G + 0.114 * B
|
||||||
|
* Cb = -0.168735892 * R - 0.331264108 * G + 0.5 * B + CENTERJSAMPLE
|
||||||
|
* Cr = 0.5 * R - 0.418687589 * G - 0.081312411 * B + CENTERJSAMPLE
|
||||||
* Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2,
|
* 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
|
* 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)
|
* negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0)
|
||||||
@@ -49,9 +61,9 @@ typedef my_color_converter * my_cconvert_ptr;
|
|||||||
* For even more speed, we avoid doing any multiplications in the inner loop
|
* 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.
|
* 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 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
|
* for 9-bit to 12-bit samples it is still acceptable. It's not very
|
||||||
* 16-bit samples, but if you want lossless storage you shouldn't be changing
|
* reasonable for 16-bit samples, but if you want lossless storage you
|
||||||
* colorspace anyway.
|
* shouldn't be changing colorspace anyway.
|
||||||
* The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
|
* 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.
|
* in the tables to save adding them separately in the inner loop.
|
||||||
*/
|
*/
|
||||||
@@ -96,21 +108,21 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
|||||||
(TABLE_SIZE * SIZEOF(INT32)));
|
(TABLE_SIZE * SIZEOF(INT32)));
|
||||||
|
|
||||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||||
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
||||||
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i;
|
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.587) * i;
|
||||||
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
|
||||||
rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i;
|
rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.168735892)) * i;
|
||||||
rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i;
|
rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.331264108)) * i;
|
||||||
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
|
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
|
||||||
* This ensures that the maximum output will round to MAXJSAMPLE
|
* This ensures that the maximum output will round to MAXJSAMPLE
|
||||||
* not MAXJSAMPLE+1, and thus that we don't have to range-limit.
|
* 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;
|
rgb_ycc_tab[i+B_CB_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||||
/* B=>Cb and R=>Cr tables are the same
|
/* 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+R_CR_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1;
|
||||||
*/
|
*/
|
||||||
rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i;
|
rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.418687589)) * i;
|
||||||
rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i;
|
rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.081312411)) * i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,6 +286,9 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
|||||||
* Convert some rows of samples to the JPEG colorspace.
|
* Convert some rows of samples to the JPEG colorspace.
|
||||||
* [R,G,B] to [R-G,G,B-G] conversion with modulo calculation
|
* [R,G,B] to [R-G,G,B-G] conversion with modulo calculation
|
||||||
* (forward reversible color transform).
|
* (forward reversible color transform).
|
||||||
|
* This can be seen as an adaption of the general RGB->YCbCr
|
||||||
|
* conversion equation with Kr = Kb = 0, while replacing the
|
||||||
|
* normalization by modulo calculation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
@@ -312,7 +327,7 @@ rgb_rgb1_convert (j_compress_ptr cinfo,
|
|||||||
/*
|
/*
|
||||||
* Convert some rows of samples to the JPEG colorspace.
|
* Convert some rows of samples to the JPEG colorspace.
|
||||||
* This version handles grayscale output with no conversion.
|
* This version handles grayscale output with no conversion.
|
||||||
* The source can be either plain grayscale or YCbCr (since Y == gray).
|
* The source can be either plain grayscale or YCC (since Y == gray).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
@@ -439,11 +454,13 @@ jinit_color_converter (j_compress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
|
case JCS_BG_RGB:
|
||||||
if (cinfo->input_components != RGB_PIXELSIZE)
|
if (cinfo->input_components != RGB_PIXELSIZE)
|
||||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_YCbCr:
|
case JCS_YCbCr:
|
||||||
|
case JCS_BG_YCC:
|
||||||
if (cinfo->input_components != 3)
|
if (cinfo->input_components != 3)
|
||||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||||
break;
|
break;
|
||||||
@@ -460,8 +477,10 @@ jinit_color_converter (j_compress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Support color transform only for RGB colorspace */
|
/* Support color transform only for RGB colorspaces */
|
||||||
if (cinfo->color_transform && cinfo->jpeg_color_space != JCS_RGB)
|
if (cinfo->color_transform &&
|
||||||
|
cinfo->jpeg_color_space != JCS_RGB &&
|
||||||
|
cinfo->jpeg_color_space != JCS_BG_RGB)
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
|
||||||
/* Check num_components, set conversion method based on requested space */
|
/* Check num_components, set conversion method based on requested space */
|
||||||
@@ -469,20 +488,26 @@ jinit_color_converter (j_compress_ptr cinfo)
|
|||||||
case JCS_GRAYSCALE:
|
case JCS_GRAYSCALE:
|
||||||
if (cinfo->num_components != 1)
|
if (cinfo->num_components != 1)
|
||||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||||
if (cinfo->in_color_space == JCS_GRAYSCALE ||
|
switch (cinfo->in_color_space) {
|
||||||
cinfo->in_color_space == JCS_YCbCr)
|
case JCS_GRAYSCALE:
|
||||||
|
case JCS_YCbCr:
|
||||||
|
case JCS_BG_YCC:
|
||||||
cconvert->pub.color_convert = grayscale_convert;
|
cconvert->pub.color_convert = grayscale_convert;
|
||||||
else if (cinfo->in_color_space == JCS_RGB) {
|
break;
|
||||||
|
case JCS_RGB:
|
||||||
cconvert->pub.start_pass = rgb_ycc_start;
|
cconvert->pub.start_pass = rgb_ycc_start;
|
||||||
cconvert->pub.color_convert = rgb_gray_convert;
|
cconvert->pub.color_convert = rgb_gray_convert;
|
||||||
} else
|
break;
|
||||||
|
default:
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
|
case JCS_BG_RGB:
|
||||||
if (cinfo->num_components != 3)
|
if (cinfo->num_components != 3)
|
||||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||||
if (cinfo->in_color_space == JCS_RGB) {
|
if (cinfo->in_color_space == cinfo->jpeg_color_space) {
|
||||||
switch (cinfo->color_transform) {
|
switch (cinfo->color_transform) {
|
||||||
case JCT_NONE:
|
case JCT_NONE:
|
||||||
cconvert->pub.color_convert = rgb_convert;
|
cconvert->pub.color_convert = rgb_convert;
|
||||||
@@ -492,7 +517,6 @@ jinit_color_converter (j_compress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
@@ -501,13 +525,48 @@ jinit_color_converter (j_compress_ptr cinfo)
|
|||||||
case JCS_YCbCr:
|
case JCS_YCbCr:
|
||||||
if (cinfo->num_components != 3)
|
if (cinfo->num_components != 3)
|
||||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||||
if (cinfo->in_color_space == JCS_RGB) {
|
switch (cinfo->in_color_space) {
|
||||||
|
case JCS_RGB:
|
||||||
cconvert->pub.start_pass = rgb_ycc_start;
|
cconvert->pub.start_pass = rgb_ycc_start;
|
||||||
cconvert->pub.color_convert = rgb_ycc_convert;
|
cconvert->pub.color_convert = rgb_ycc_convert;
|
||||||
} else if (cinfo->in_color_space == JCS_YCbCr)
|
break;
|
||||||
|
case JCS_YCbCr:
|
||||||
cconvert->pub.color_convert = null_convert;
|
cconvert->pub.color_convert = null_convert;
|
||||||
else
|
break;
|
||||||
|
default:
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JCS_BG_YCC:
|
||||||
|
if (cinfo->num_components != 3)
|
||||||
|
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||||
|
switch (cinfo->in_color_space) {
|
||||||
|
case JCS_RGB:
|
||||||
|
/* For conversion from normal RGB input to BG_YCC representation,
|
||||||
|
* the Cb/Cr values are first computed as usual, and then
|
||||||
|
* quantized further after DCT processing by a factor of
|
||||||
|
* 2 in reference to the nominal quantization factor.
|
||||||
|
*/
|
||||||
|
/* need quantization scale by factor of 2 after DCT */
|
||||||
|
cinfo->comp_info[1].component_needed = TRUE;
|
||||||
|
cinfo->comp_info[2].component_needed = TRUE;
|
||||||
|
/* compute normal YCC first */
|
||||||
|
cconvert->pub.start_pass = rgb_ycc_start;
|
||||||
|
cconvert->pub.color_convert = rgb_ycc_convert;
|
||||||
|
break;
|
||||||
|
case JCS_YCbCr:
|
||||||
|
/* need quantization scale by factor of 2 after DCT */
|
||||||
|
cinfo->comp_info[1].component_needed = TRUE;
|
||||||
|
cinfo->comp_info[2].component_needed = TRUE;
|
||||||
|
/*FALLTHROUGH*/
|
||||||
|
case JCS_BG_YCC:
|
||||||
|
/* Pass through for BG_YCC input */
|
||||||
|
cconvert->pub.color_convert = null_convert;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_CMYK:
|
case JCS_CMYK:
|
||||||
@@ -522,13 +581,17 @@ jinit_color_converter (j_compress_ptr cinfo)
|
|||||||
case JCS_YCCK:
|
case JCS_YCCK:
|
||||||
if (cinfo->num_components != 4)
|
if (cinfo->num_components != 4)
|
||||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||||
if (cinfo->in_color_space == JCS_CMYK) {
|
switch (cinfo->in_color_space) {
|
||||||
|
case JCS_CMYK:
|
||||||
cconvert->pub.start_pass = rgb_ycc_start;
|
cconvert->pub.start_pass = rgb_ycc_start;
|
||||||
cconvert->pub.color_convert = cmyk_ycck_convert;
|
cconvert->pub.color_convert = cmyk_ycck_convert;
|
||||||
} else if (cinfo->in_color_space == JCS_YCCK)
|
break;
|
||||||
|
case JCS_YCCK:
|
||||||
cconvert->pub.color_convert = null_convert;
|
cconvert->pub.color_convert = null_convert;
|
||||||
else
|
break;
|
||||||
|
default:
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* allow null conversion of JCS_UNKNOWN */
|
default: /* allow null conversion of JCS_UNKNOWN */
|
||||||
|
|||||||
Vendored
+37
-42
@@ -2,6 +2,7 @@
|
|||||||
* jcdctmgr.c
|
* jcdctmgr.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
|
* Modified 2003-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -25,22 +26,30 @@ typedef struct {
|
|||||||
/* Pointer to the DCT routine actually in use */
|
/* Pointer to the DCT routine actually in use */
|
||||||
forward_DCT_method_ptr do_dct[MAX_COMPONENTS];
|
forward_DCT_method_ptr do_dct[MAX_COMPONENTS];
|
||||||
|
|
||||||
/* 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];
|
|
||||||
|
|
||||||
#ifdef DCT_FLOAT_SUPPORTED
|
#ifdef DCT_FLOAT_SUPPORTED
|
||||||
/* Same as above for the floating-point case. */
|
/* Same as above for the floating-point case. */
|
||||||
float_DCT_method_ptr do_float_dct[MAX_COMPONENTS];
|
float_DCT_method_ptr do_float_dct[MAX_COMPONENTS];
|
||||||
FAST_FLOAT * float_divisors[NUM_QUANT_TBLS];
|
|
||||||
#endif
|
#endif
|
||||||
} my_fdct_controller;
|
} my_fdct_controller;
|
||||||
|
|
||||||
typedef my_fdct_controller * my_fdct_ptr;
|
typedef my_fdct_controller * my_fdct_ptr;
|
||||||
|
|
||||||
|
|
||||||
|
/* The allocated post-DCT divisor tables -- big enough for any
|
||||||
|
* supported variant and not identical to the quant table entries,
|
||||||
|
* because of scaling (especially for an unnormalized DCT) --
|
||||||
|
* are pointed to by dct_table in the per-component comp_info
|
||||||
|
* structures. Each table is given in normal array order.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
DCTELEM int_array[DCTSIZE2];
|
||||||
|
#ifdef DCT_FLOAT_SUPPORTED
|
||||||
|
FAST_FLOAT float_array[DCTSIZE2];
|
||||||
|
#endif
|
||||||
|
} divisor_table;
|
||||||
|
|
||||||
|
|
||||||
/* The current scaled-DCT routines require ISLOW-style divisor tables,
|
/* The current scaled-DCT routines require ISLOW-style divisor tables,
|
||||||
* so be sure to compile that code if either ISLOW or SCALING is requested.
|
* so be sure to compile that code if either ISLOW or SCALING is requested.
|
||||||
*/
|
*/
|
||||||
@@ -71,7 +80,7 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||||
forward_DCT_method_ptr do_dct = fdct->do_dct[compptr->component_index];
|
forward_DCT_method_ptr do_dct = fdct->do_dct[compptr->component_index];
|
||||||
DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no];
|
DCTELEM * divisors = (DCTELEM *) compptr->dct_table;
|
||||||
DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
||||||
JDIMENSION bi;
|
JDIMENSION bi;
|
||||||
|
|
||||||
@@ -134,7 +143,7 @@ forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||||
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
|
||||||
float_DCT_method_ptr do_dct = fdct->do_float_dct[compptr->component_index];
|
float_DCT_method_ptr do_dct = fdct->do_float_dct[compptr->component_index];
|
||||||
FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no];
|
FAST_FLOAT * divisors = (FAST_FLOAT *) compptr->dct_table;
|
||||||
FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
||||||
JDIMENSION bi;
|
JDIMENSION bi;
|
||||||
|
|
||||||
@@ -352,22 +361,17 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
|||||||
cinfo->quant_tbl_ptrs[qtblno] == NULL)
|
cinfo->quant_tbl_ptrs[qtblno] == NULL)
|
||||||
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
|
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
|
||||||
qtbl = cinfo->quant_tbl_ptrs[qtblno];
|
qtbl = cinfo->quant_tbl_ptrs[qtblno];
|
||||||
/* Compute divisors for this quant table */
|
/* Create divisor table from quant table */
|
||||||
/* We may do this more than once for same table, but it's not a big deal */
|
|
||||||
switch (method) {
|
switch (method) {
|
||||||
#ifdef PROVIDE_ISLOW_TABLES
|
#ifdef PROVIDE_ISLOW_TABLES
|
||||||
case JDCT_ISLOW:
|
case JDCT_ISLOW:
|
||||||
/* For LL&M IDCT method, divisors are equal to raw quantization
|
/* For LL&M IDCT method, divisors are equal to raw quantization
|
||||||
* coefficients multiplied by 8 (to counteract scaling).
|
* coefficients multiplied by 8 (to counteract scaling).
|
||||||
*/
|
*/
|
||||||
if (fdct->divisors[qtblno] == NULL) {
|
dtbl = (DCTELEM *) compptr->dct_table;
|
||||||
fdct->divisors[qtblno] = (DCTELEM *)
|
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
||||||
DCTSIZE2 * SIZEOF(DCTELEM));
|
|
||||||
}
|
|
||||||
dtbl = fdct->divisors[qtblno];
|
|
||||||
for (i = 0; i < DCTSIZE2; i++) {
|
for (i = 0; i < DCTSIZE2; i++) {
|
||||||
dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3;
|
dtbl[i] =
|
||||||
|
((DCTELEM) qtbl->quantval[i]) << (compptr->component_needed ? 4 : 3);
|
||||||
}
|
}
|
||||||
fdct->pub.forward_DCT[ci] = forward_DCT;
|
fdct->pub.forward_DCT[ci] = forward_DCT;
|
||||||
break;
|
break;
|
||||||
@@ -395,17 +399,12 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
|||||||
};
|
};
|
||||||
SHIFT_TEMPS
|
SHIFT_TEMPS
|
||||||
|
|
||||||
if (fdct->divisors[qtblno] == NULL) {
|
dtbl = (DCTELEM *) compptr->dct_table;
|
||||||
fdct->divisors[qtblno] = (DCTELEM *)
|
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
||||||
DCTSIZE2 * SIZEOF(DCTELEM));
|
|
||||||
}
|
|
||||||
dtbl = fdct->divisors[qtblno];
|
|
||||||
for (i = 0; i < DCTSIZE2; i++) {
|
for (i = 0; i < DCTSIZE2; i++) {
|
||||||
dtbl[i] = (DCTELEM)
|
dtbl[i] = (DCTELEM)
|
||||||
DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
|
DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
|
||||||
(INT32) aanscales[i]),
|
(INT32) aanscales[i]),
|
||||||
CONST_BITS-3);
|
compptr->component_needed ? CONST_BITS-4 : CONST_BITS-3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fdct->pub.forward_DCT[ci] = forward_DCT;
|
fdct->pub.forward_DCT[ci] = forward_DCT;
|
||||||
@@ -422,25 +421,20 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
|||||||
* What's actually stored is 1/divisor so that the inner loop can
|
* What's actually stored is 1/divisor so that the inner loop can
|
||||||
* use a multiplication rather than a division.
|
* use a multiplication rather than a division.
|
||||||
*/
|
*/
|
||||||
FAST_FLOAT * fdtbl;
|
FAST_FLOAT * fdtbl = (FAST_FLOAT *) compptr->dct_table;
|
||||||
int row, col;
|
int row, col;
|
||||||
static const double aanscalefactor[DCTSIZE] = {
|
static const double aanscalefactor[DCTSIZE] = {
|
||||||
1.0, 1.387039845, 1.306562965, 1.175875602,
|
1.0, 1.387039845, 1.306562965, 1.175875602,
|
||||||
1.0, 0.785694958, 0.541196100, 0.275899379
|
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;
|
i = 0;
|
||||||
for (row = 0; row < DCTSIZE; row++) {
|
for (row = 0; row < DCTSIZE; row++) {
|
||||||
for (col = 0; col < DCTSIZE; col++) {
|
for (col = 0; col < DCTSIZE; col++) {
|
||||||
fdtbl[i] = (FAST_FLOAT)
|
fdtbl[i] = (FAST_FLOAT)
|
||||||
(1.0 / (((double) qtbl->quantval[i] *
|
(1.0 / ((double) qtbl->quantval[i] *
|
||||||
aanscalefactor[row] * aanscalefactor[col] * 8.0)));
|
aanscalefactor[row] * aanscalefactor[col] *
|
||||||
|
(compptr->component_needed ? 16.0 : 8.0)));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,19 +458,20 @@ GLOBAL(void)
|
|||||||
jinit_forward_dct (j_compress_ptr cinfo)
|
jinit_forward_dct (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_fdct_ptr fdct;
|
my_fdct_ptr fdct;
|
||||||
int i;
|
int ci;
|
||||||
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
fdct = (my_fdct_ptr)
|
fdct = (my_fdct_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
SIZEOF(my_fdct_controller));
|
SIZEOF(my_fdct_controller));
|
||||||
cinfo->fdct = (struct jpeg_forward_dct *) fdct;
|
cinfo->fdct = &fdct->pub;
|
||||||
fdct->pub.start_pass = start_pass_fdctmgr;
|
fdct->pub.start_pass = start_pass_fdctmgr;
|
||||||
|
|
||||||
/* Mark divisor tables unallocated */
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
for (i = 0; i < NUM_QUANT_TBLS; i++) {
|
ci++, compptr++) {
|
||||||
fdct->divisors[i] = NULL;
|
/* Allocate a divisor table for each component */
|
||||||
#ifdef DCT_FLOAT_SUPPORTED
|
compptr->dct_table =
|
||||||
fdct->float_divisors[i] = NULL;
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
#endif
|
SIZEOF(divisor_table));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+40
-43
@@ -2,7 +2,7 @@
|
|||||||
* jchuff.c
|
* jchuff.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2006-2009 by Guido Vollbeding.
|
* Modified 2006-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -308,20 +308,23 @@ emit_bits_s (working_state * state, unsigned int code, int size)
|
|||||||
/* Emit some bits; return TRUE if successful, FALSE if must suspend */
|
/* Emit some bits; return TRUE if successful, FALSE if must suspend */
|
||||||
{
|
{
|
||||||
/* This routine is heavily used, so it's worth coding tightly. */
|
/* This routine is heavily used, so it's worth coding tightly. */
|
||||||
register INT32 put_buffer = (INT32) code;
|
register INT32 put_buffer;
|
||||||
register int put_bits = state->cur.put_bits;
|
register int put_bits;
|
||||||
|
|
||||||
/* if size is 0, caller used an invalid Huffman table entry */
|
/* if size is 0, caller used an invalid Huffman table entry */
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE);
|
ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE);
|
||||||
|
|
||||||
put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */
|
/* mask off any extra bits in code */
|
||||||
|
put_buffer = ((INT32) code) & ((((INT32) 1) << size) - 1);
|
||||||
|
|
||||||
put_bits += size; /* new number of bits in buffer */
|
/* new number of bits in buffer */
|
||||||
|
put_bits = size + state->cur.put_bits;
|
||||||
|
|
||||||
put_buffer <<= 24 - put_bits; /* align incoming bits */
|
put_buffer <<= 24 - put_bits; /* align incoming bits */
|
||||||
|
|
||||||
put_buffer |= state->cur.put_buffer; /* and merge with old buffer contents */
|
/* and merge with old buffer contents */
|
||||||
|
put_buffer |= state->cur.put_buffer;
|
||||||
|
|
||||||
while (put_bits >= 8) {
|
while (put_bits >= 8) {
|
||||||
int c = (int) ((put_buffer >> 16) & 0xFF);
|
int c = (int) ((put_buffer >> 16) & 0xFF);
|
||||||
@@ -347,8 +350,8 @@ emit_bits_e (huff_entropy_ptr entropy, unsigned int code, int size)
|
|||||||
/* Emit some bits, unless we are in gather mode */
|
/* Emit some bits, unless we are in gather mode */
|
||||||
{
|
{
|
||||||
/* This routine is heavily used, so it's worth coding tightly. */
|
/* This routine is heavily used, so it's worth coding tightly. */
|
||||||
register INT32 put_buffer = (INT32) code;
|
register INT32 put_buffer;
|
||||||
register int put_bits = entropy->saved.put_bits;
|
register int put_bits;
|
||||||
|
|
||||||
/* if size is 0, caller used an invalid Huffman table entry */
|
/* if size is 0, caller used an invalid Huffman table entry */
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
@@ -357,9 +360,11 @@ emit_bits_e (huff_entropy_ptr entropy, unsigned int code, int size)
|
|||||||
if (entropy->gather_statistics)
|
if (entropy->gather_statistics)
|
||||||
return; /* do nothing if we're only getting stats */
|
return; /* do nothing if we're only getting stats */
|
||||||
|
|
||||||
put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */
|
/* mask off any extra bits in code */
|
||||||
|
put_buffer = ((INT32) code) & ((((INT32) 1) << size) - 1);
|
||||||
|
|
||||||
put_bits += size; /* new number of bits in buffer */
|
/* new number of bits in buffer */
|
||||||
|
put_bits = size + entropy->saved.put_bits;
|
||||||
|
|
||||||
put_buffer <<= 24 - put_bits; /* align incoming bits */
|
put_buffer <<= 24 - put_bits; /* align incoming bits */
|
||||||
|
|
||||||
@@ -543,10 +548,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
register int temp, temp2;
|
register int temp, temp2;
|
||||||
register int nbits;
|
register int nbits;
|
||||||
int blkn, ci;
|
int blkn, ci, tbl;
|
||||||
int Al = cinfo->Al;
|
|
||||||
JBLOCKROW block;
|
|
||||||
jpeg_component_info * compptr;
|
|
||||||
ISHIFT_TEMPS
|
ISHIFT_TEMPS
|
||||||
|
|
||||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||||
@@ -559,21 +561,20 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/* Encode the MCU data blocks */
|
/* Encode the MCU data blocks */
|
||||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||||
block = MCU_data[blkn];
|
|
||||||
ci = cinfo->MCU_membership[blkn];
|
ci = cinfo->MCU_membership[blkn];
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
|
||||||
|
|
||||||
/* Compute the DC value after the required point transform by Al.
|
/* Compute the DC value after the required point transform by Al.
|
||||||
* This is simply an arithmetic right shift.
|
* This is simply an arithmetic right shift.
|
||||||
*/
|
*/
|
||||||
temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al);
|
temp = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al);
|
||||||
|
|
||||||
/* DC differences are figured on the point-transformed values. */
|
/* DC differences are figured on the point-transformed values. */
|
||||||
temp = temp2 - entropy->saved.last_dc_val[ci];
|
temp2 = temp - entropy->saved.last_dc_val[ci];
|
||||||
entropy->saved.last_dc_val[ci] = temp2;
|
entropy->saved.last_dc_val[ci] = temp;
|
||||||
|
|
||||||
/* Encode the DC coefficient difference per section G.1.2.1 */
|
/* Encode the DC coefficient difference per section G.1.2.1 */
|
||||||
temp2 = temp;
|
temp = temp2;
|
||||||
if (temp < 0) {
|
if (temp < 0) {
|
||||||
temp = -temp; /* temp is abs value of input */
|
temp = -temp; /* temp is abs value of input */
|
||||||
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
||||||
@@ -594,7 +595,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
/* Count/emit the Huffman-coded symbol for the number of bits */
|
/* Count/emit the Huffman-coded symbol for the number of bits */
|
||||||
emit_dc_symbol(entropy, compptr->dc_tbl_no, nbits);
|
emit_dc_symbol(entropy, tbl, nbits);
|
||||||
|
|
||||||
/* Emit that number of bits of the value, if positive, */
|
/* Emit that number of bits of the value, if positive, */
|
||||||
/* or the complement of its magnitude, if negative. */
|
/* or the complement of its magnitude, if negative. */
|
||||||
@@ -628,12 +629,12 @@ METHODDEF(boolean)
|
|||||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
|
const int * natural_order;
|
||||||
|
JBLOCKROW block;
|
||||||
register int temp, temp2;
|
register int temp, temp2;
|
||||||
register int nbits;
|
register int nbits;
|
||||||
register int r, k;
|
register int r, k;
|
||||||
int Se, Al;
|
int Se, Al;
|
||||||
const int * natural_order;
|
|
||||||
JBLOCKROW block;
|
|
||||||
|
|
||||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||||
@@ -731,18 +732,15 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* MCU encoding for DC successive approximation refinement scan.
|
* MCU encoding for DC successive approximation refinement scan.
|
||||||
* Note: we assume such scans can be multi-component, although the spec
|
* Note: we assume such scans can be multi-component,
|
||||||
* is not very clear on the point.
|
* although the spec is not very clear on the point.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
register int temp;
|
int Al, blkn;
|
||||||
int blkn;
|
|
||||||
int Al = cinfo->Al;
|
|
||||||
JBLOCKROW block;
|
|
||||||
|
|
||||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||||
@@ -752,13 +750,12 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
if (entropy->restarts_to_go == 0)
|
if (entropy->restarts_to_go == 0)
|
||||||
emit_restart_e(entropy, entropy->next_restart_num);
|
emit_restart_e(entropy, entropy->next_restart_num);
|
||||||
|
|
||||||
|
Al = cinfo->Al;
|
||||||
|
|
||||||
/* Encode the MCU data blocks */
|
/* Encode the MCU data blocks */
|
||||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
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. */
|
/* We simply emit the Al'th bit of the DC coefficient value. */
|
||||||
temp = (*block)[0];
|
emit_bits_e(entropy, (unsigned int) (MCU_data[blkn][0][0] >> Al), 1);
|
||||||
emit_bits_e(entropy, (unsigned int) (temp >> Al), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||||
@@ -786,14 +783,14 @@ METHODDEF(boolean)
|
|||||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
|
const int * natural_order;
|
||||||
|
JBLOCKROW block;
|
||||||
register int temp;
|
register int temp;
|
||||||
register int r, k;
|
register int r, k;
|
||||||
|
int Se, Al;
|
||||||
int EOB;
|
int EOB;
|
||||||
char *BR_buffer;
|
char *BR_buffer;
|
||||||
unsigned int BR;
|
unsigned int BR;
|
||||||
int Se, Al;
|
|
||||||
const int * natural_order;
|
|
||||||
JBLOCKROW block;
|
|
||||||
int absvalues[DCTSIZE2];
|
int absvalues[DCTSIZE2];
|
||||||
|
|
||||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||||
@@ -918,7 +915,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
|||||||
{
|
{
|
||||||
register int temp, temp2;
|
register int temp, temp2;
|
||||||
register int nbits;
|
register int nbits;
|
||||||
register int k, r, i;
|
register int r, k;
|
||||||
int Se = state->cinfo->lim_Se;
|
int Se = state->cinfo->lim_Se;
|
||||||
const int * natural_order = state->cinfo->natural_order;
|
const int * natural_order = state->cinfo->natural_order;
|
||||||
|
|
||||||
@@ -960,7 +957,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
|||||||
r = 0; /* r = run length of zeros */
|
r = 0; /* r = run length of zeros */
|
||||||
|
|
||||||
for (k = 1; k <= Se; k++) {
|
for (k = 1; k <= Se; k++) {
|
||||||
if ((temp = block[natural_order[k]]) == 0) {
|
if ((temp2 = block[natural_order[k]]) == 0) {
|
||||||
r++;
|
r++;
|
||||||
} else {
|
} else {
|
||||||
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
|
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
|
||||||
@@ -970,7 +967,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
|||||||
r -= 16;
|
r -= 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp2 = temp;
|
temp = temp2;
|
||||||
if (temp < 0) {
|
if (temp < 0) {
|
||||||
temp = -temp; /* temp is abs value of input */
|
temp = -temp; /* temp is abs value of input */
|
||||||
/* This code assumes we are on a two's complement machine */
|
/* This code assumes we are on a two's complement machine */
|
||||||
@@ -986,8 +983,8 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
|||||||
ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
|
ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
/* Emit Huffman symbol for run length / number of bits */
|
/* Emit Huffman symbol for run length / number of bits */
|
||||||
i = (r << 4) + nbits;
|
temp = (r << 4) + nbits;
|
||||||
if (! emit_bits_s(state, actbl->ehufco[i], actbl->ehufsi[i]))
|
if (! emit_bits_s(state, actbl->ehufco[temp], actbl->ehufsi[temp]))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Emit that number of bits of the value, if positive, */
|
/* Emit that number of bits of the value, if positive, */
|
||||||
@@ -1124,7 +1121,7 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
|||||||
{
|
{
|
||||||
register int temp;
|
register int temp;
|
||||||
register int nbits;
|
register int nbits;
|
||||||
register int k, r;
|
register int r, k;
|
||||||
int Se = cinfo->lim_Se;
|
int Se = cinfo->lim_Se;
|
||||||
const int * natural_order = cinfo->natural_order;
|
const int * natural_order = cinfo->natural_order;
|
||||||
|
|
||||||
@@ -1562,7 +1559,7 @@ jinit_huff_encoder (j_compress_ptr cinfo)
|
|||||||
entropy = (huff_entropy_ptr)
|
entropy = (huff_entropy_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
SIZEOF(huff_entropy_encoder));
|
SIZEOF(huff_entropy_encoder));
|
||||||
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
cinfo->entropy = &entropy->pub;
|
||||||
entropy->pub.start_pass = start_pass_huff;
|
entropy->pub.start_pass = start_pass_huff;
|
||||||
|
|
||||||
/* Mark tables unallocated */
|
/* Mark tables unallocated */
|
||||||
|
|||||||
Vendored
+19
@@ -2,6 +2,7 @@
|
|||||||
* jcinit.c
|
* jcinit.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
|
* Modified 2003-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -29,6 +30,24 @@
|
|||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jinit_compress_master (j_compress_ptr cinfo)
|
jinit_compress_master (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
|
long samplesperrow;
|
||||||
|
JDIMENSION jd_samplesperrow;
|
||||||
|
|
||||||
|
/* For now, precision must match compiled-in value... */
|
||||||
|
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
||||||
|
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
||||||
|
|
||||||
|
/* Sanity check on image dimensions */
|
||||||
|
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
|
||||||
|
cinfo->input_components <= 0)
|
||||||
|
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
/* Initialize master control (includes parameter checking/processing) */
|
/* Initialize master control (includes parameter checking/processing) */
|
||||||
jinit_c_master_control(cinfo, FALSE /* full compression */);
|
jinit_c_master_control(cinfo, FALSE /* full compression */);
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
-3
@@ -2,7 +2,7 @@
|
|||||||
* jcmarker.c
|
* jcmarker.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2003-2012 by Guido Vollbeding.
|
* Modified 2003-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -508,8 +508,8 @@ write_marker_byte (j_compress_ptr cinfo, int val)
|
|||||||
* Write datastream header.
|
* Write datastream header.
|
||||||
* This consists of an SOI and optional APPn markers.
|
* This consists of an SOI and optional APPn markers.
|
||||||
* We recommend use of the JFIF marker, but not the Adobe marker,
|
* We recommend use of the JFIF marker, but not the Adobe marker,
|
||||||
* when using YCbCr or grayscale data. The JFIF marker should NOT
|
* when using YCbCr or grayscale data. The JFIF marker is also used
|
||||||
* be used for any other JPEG colorspace. The Adobe marker is helpful
|
* for other standard JPEG colorspaces. The Adobe marker is helpful
|
||||||
* to distinguish RGB, CMYK, and YCCK colorspaces.
|
* to distinguish RGB, CMYK, and YCCK colorspaces.
|
||||||
* Note that an application can write additional header markers after
|
* Note that an application can write additional header markers after
|
||||||
* jpeg_start_compress returns.
|
* jpeg_start_compress returns.
|
||||||
|
|||||||
Vendored
+17
-19
@@ -2,7 +2,7 @@
|
|||||||
* jcmaster.c
|
* jcmaster.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2003-2011 by Guido Vollbeding.
|
* Modified 2003-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -222,8 +222,6 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
{
|
{
|
||||||
int ci, ssize;
|
int ci, ssize;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
long samplesperrow;
|
|
||||||
JDIMENSION jd_samplesperrow;
|
|
||||||
|
|
||||||
if (transcode_only)
|
if (transcode_only)
|
||||||
jpeg_calc_trans_dimensions(cinfo);
|
jpeg_calc_trans_dimensions(cinfo);
|
||||||
@@ -251,7 +249,7 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
|
|
||||||
/* Sanity check on image dimensions */
|
/* Sanity check on image dimensions */
|
||||||
if (cinfo->jpeg_height <= 0 || cinfo->jpeg_width <= 0 ||
|
if (cinfo->jpeg_height <= 0 || cinfo->jpeg_width <= 0 ||
|
||||||
cinfo->num_components <= 0 || cinfo->input_components <= 0)
|
cinfo->num_components <= 0)
|
||||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||||
|
|
||||||
/* Make sure image isn't bigger than I can handle */
|
/* Make sure image isn't bigger than I can handle */
|
||||||
@@ -259,14 +257,8 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
(long) cinfo->jpeg_width > (long) JPEG_MAX_DIMENSION)
|
(long) cinfo->jpeg_width > (long) JPEG_MAX_DIMENSION)
|
||||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||||
|
|
||||||
/* Width of an input scanline must be representable as JDIMENSION. */
|
/* Only 8 to 12 bits data precision are supported for DCT based JPEG */
|
||||||
samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
|
if (cinfo->data_precision < 8 || cinfo->data_precision > 12)
|
||||||
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);
|
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
||||||
|
|
||||||
/* Check that number of components won't exceed internal array sizes */
|
/* Check that number of components won't exceed internal array sizes */
|
||||||
@@ -339,8 +331,10 @@ initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
jdiv_round_up((long) cinfo->jpeg_height *
|
jdiv_round_up((long) cinfo->jpeg_height *
|
||||||
(long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
|
(long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
|
||||||
(long) (cinfo->max_v_samp_factor * cinfo->block_size));
|
(long) (cinfo->max_v_samp_factor * cinfo->block_size));
|
||||||
/* Mark component needed (this flag isn't actually used for compression) */
|
/* Don't need quantization scale after DCT,
|
||||||
compptr->component_needed = TRUE;
|
* until color conversion says otherwise.
|
||||||
|
*/
|
||||||
|
compptr->component_needed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute number of fully interleaved MCU rows (number of times that
|
/* Compute number of fully interleaved MCU rows (number of times that
|
||||||
@@ -811,7 +805,7 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
master = (my_master_ptr)
|
master = (my_master_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
SIZEOF(my_comp_master));
|
SIZEOF(my_comp_master));
|
||||||
cinfo->master = (struct jpeg_comp_master *) master;
|
cinfo->master = &master->pub;
|
||||||
master->pub.prepare_for_pass = prepare_for_pass;
|
master->pub.prepare_for_pass = prepare_for_pass;
|
||||||
master->pub.pass_startup = pass_startup;
|
master->pub.pass_startup = pass_startup;
|
||||||
master->pub.finish_pass = finish_pass_master;
|
master->pub.finish_pass = finish_pass_master;
|
||||||
@@ -833,10 +827,14 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
cinfo->num_scans = 1;
|
cinfo->num_scans = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cinfo->progressive_mode || cinfo->block_size < DCTSIZE) &&
|
if (cinfo->optimize_coding)
|
||||||
!cinfo->arith_code) /* TEMPORARY HACK ??? */
|
cinfo->arith_code = FALSE; /* disable arithmetic coding */
|
||||||
/* assume default tables no good for progressive or downscale mode */
|
else if (! cinfo->arith_code &&
|
||||||
cinfo->optimize_coding = TRUE;
|
(cinfo->progressive_mode ||
|
||||||
|
(cinfo->block_size > 1 && cinfo->block_size < DCTSIZE)))
|
||||||
|
/* TEMPORARY HACK ??? */
|
||||||
|
/* assume default tables no good for progressive or reduced AC mode */
|
||||||
|
cinfo->optimize_coding = TRUE; /* force Huffman optimization */
|
||||||
|
|
||||||
/* Initialize my private state */
|
/* Initialize my private state */
|
||||||
if (transcode_only) {
|
if (transcode_only) {
|
||||||
|
|||||||
Vendored
+15
-99
@@ -1,136 +1,52 @@
|
|||||||
|
/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 9x or NT. */
|
||||||
|
/* This file also works for Borland C++ 32-bit (bcc32) on Windows 9x or NT. */
|
||||||
|
/* see jconfig.txt for explanations */
|
||||||
|
|
||||||
#define HAVE_PROTOTYPES
|
#define HAVE_PROTOTYPES
|
||||||
#define HAVE_UNSIGNED_CHAR
|
#define HAVE_UNSIGNED_CHAR
|
||||||
#define HAVE_UNSIGNED_SHORT
|
#define HAVE_UNSIGNED_SHORT
|
||||||
|
/* #define void char */
|
||||||
/* Define this if an ordinary "char" type is unsigned.
|
/* #define const */
|
||||||
* If you're not sure, leaving it undefined will work at some cost in speed.
|
|
||||||
* If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal.
|
|
||||||
*/
|
|
||||||
#undef CHAR_IS_UNSIGNED
|
#undef CHAR_IS_UNSIGNED
|
||||||
|
|
||||||
#if defined __MINGW__ || defined __MINGW32__ || (!defined WIN32 && !defined _WIN32)
|
|
||||||
/* Define this if your system has an ANSI-conforming <stddef.h> file.
|
|
||||||
*/
|
|
||||||
#define HAVE_STDDEF_H
|
#define HAVE_STDDEF_H
|
||||||
|
|
||||||
/* Define this if your system has an ANSI-conforming <stdlib.h> file.
|
|
||||||
*/
|
|
||||||
#define HAVE_STDLIB_H
|
#define HAVE_STDLIB_H
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Define this if your system does not have an ANSI/SysV <string.h>,
|
|
||||||
* but does have a BSD-style <strings.h>.
|
|
||||||
*/
|
|
||||||
#undef NEED_BSD_STRINGS
|
#undef NEED_BSD_STRINGS
|
||||||
|
|
||||||
/* Define this if your system does not provide typedef size_t in any of the
|
|
||||||
* ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in
|
|
||||||
* <sys/types.h> instead.
|
|
||||||
*/
|
|
||||||
#undef NEED_SYS_TYPES_H
|
#undef NEED_SYS_TYPES_H
|
||||||
|
#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */
|
||||||
/* For 80x86 machines, you need to define NEED_FAR_POINTERS,
|
|
||||||
* unless you are using a large-data memory model or 80386 flat-memory mode.
|
|
||||||
* On less brain-damaged CPUs this symbol must not be defined.
|
|
||||||
* (Defining this symbol causes large data structures to be referenced through
|
|
||||||
* "far" pointers and to be allocated with a special version of malloc.)
|
|
||||||
*/
|
|
||||||
#undef NEED_FAR_POINTERS
|
|
||||||
|
|
||||||
/* Define this if your linker needs global names to be unique in less
|
|
||||||
* than the first 15 characters.
|
|
||||||
*/
|
|
||||||
#undef NEED_SHORT_EXTERNAL_NAMES
|
#undef NEED_SHORT_EXTERNAL_NAMES
|
||||||
|
|
||||||
/* Although a real ANSI C compiler can deal perfectly well with pointers to
|
|
||||||
* unspecified structures (see "incomplete types" in the spec), a few pre-ANSI
|
|
||||||
* and pseudo-ANSI compilers get confused. To keep one of these bozos happy,
|
|
||||||
* define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you
|
|
||||||
* actually get "missing structure definition" warnings or errors while
|
|
||||||
* compiling the JPEG code.
|
|
||||||
*/
|
|
||||||
#undef INCOMPLETE_TYPES_BROKEN
|
#undef INCOMPLETE_TYPES_BROKEN
|
||||||
|
|
||||||
/* Define "boolean" as unsigned char, not int, on Windows systems.
|
/* Define "boolean" as unsigned char, not enum, per Windows custom */
|
||||||
*/
|
|
||||||
#ifdef _WIN32
|
|
||||||
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
||||||
typedef unsigned char boolean;
|
typedef unsigned char boolean;
|
||||||
#endif
|
#endif
|
||||||
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
#ifndef FALSE /* in case these macros already exist */
|
||||||
|
#define FALSE 0 /* values of boolean */
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following options affect code selection within the JPEG library,
|
|
||||||
* but they don't need to be visible to applications using the library.
|
|
||||||
* To minimize application namespace pollution, the symbols won't be
|
|
||||||
* defined unless JPEG_INTERNALS has been defined.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef JPEG_INTERNALS
|
#ifdef JPEG_INTERNALS
|
||||||
|
|
||||||
/* Define this if your compiler implements ">>" on signed values as a logical
|
|
||||||
* (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift,
|
|
||||||
* which is the normal and rational definition.
|
|
||||||
*/
|
|
||||||
#undef RIGHT_SHIFT_IS_UNSIGNED
|
#undef RIGHT_SHIFT_IS_UNSIGNED
|
||||||
|
|
||||||
/* These are for configuring the JPEG memory manager. */
|
|
||||||
#define DEFAULT_MAX_MEM 1073741824 /*1Gb*/
|
|
||||||
|
|
||||||
#if !defined WIN32 && !defined _WIN32
|
|
||||||
#define INLINE __inline__
|
|
||||||
#undef NO_MKTEMP
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* JPEG_INTERNALS */
|
#endif /* JPEG_INTERNALS */
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The remaining options do not affect the JPEG library proper,
|
|
||||||
* but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c).
|
|
||||||
* Other applications can ignore these.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef JPEG_CJPEG_DJPEG
|
#ifdef JPEG_CJPEG_DJPEG
|
||||||
|
|
||||||
/* These defines indicate which image (non-JPEG) file formats are allowed. */
|
|
||||||
|
|
||||||
#define BMP_SUPPORTED /* BMP image file format */
|
#define BMP_SUPPORTED /* BMP image file format */
|
||||||
#define GIF_SUPPORTED /* GIF image file format */
|
#define GIF_SUPPORTED /* GIF image file format */
|
||||||
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
||||||
#undef RLE_SUPPORTED /* Utah RLE image file format */
|
#undef RLE_SUPPORTED /* Utah RLE image file format */
|
||||||
#define TARGA_SUPPORTED /* Targa image file format */
|
#define TARGA_SUPPORTED /* Targa image file format */
|
||||||
|
|
||||||
/* Define this if you want to name both input and output files on the command
|
|
||||||
* line, rather than using stdout and optionally stdin. You MUST do this if
|
|
||||||
* your system can't cope with binary I/O to stdin/stdout. See comments at
|
|
||||||
* head of cjpeg.c or djpeg.c.
|
|
||||||
*/
|
|
||||||
#if defined WIN32 || defined _WIN32
|
|
||||||
#define TWO_FILE_COMMANDLINE /* optional */
|
#define TWO_FILE_COMMANDLINE /* optional */
|
||||||
#define USE_SETMODE /* Microsoft has setmode() */
|
#define USE_SETMODE /* Microsoft has setmode() */
|
||||||
#else
|
|
||||||
#undef TWO_FILE_COMMANDLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Define this if your system needs explicit cleanup of temporary files.
|
|
||||||
* This is crucial under MS-DOS, where the temporary "files" may be areas
|
|
||||||
* of extended memory; on most other systems it's not as important.
|
|
||||||
*/
|
|
||||||
#undef NEED_SIGNAL_CATCHER
|
#undef NEED_SIGNAL_CATCHER
|
||||||
|
|
||||||
/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
|
|
||||||
* This is necessary on systems that distinguish text files from binary files,
|
|
||||||
* and is harmless on most systems that don't. If you have one of the rare
|
|
||||||
* systems that complains about the "b" spec, define this symbol.
|
|
||||||
*/
|
|
||||||
#undef DONT_USE_B_MODE
|
#undef DONT_USE_B_MODE
|
||||||
|
#undef PROGRESS_REPORT /* optional */
|
||||||
/* Define this if you want percent-done progress reports from cjpeg/djpeg.
|
|
||||||
*/
|
|
||||||
#undef PROGRESS_REPORT
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* JPEG_CJPEG_DJPEG */
|
#endif /* JPEG_CJPEG_DJPEG */
|
||||||
|
|||||||
Vendored
+74
-36
@@ -2,7 +2,7 @@
|
|||||||
* jcparam.c
|
* jcparam.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2003-2012 by Guido Vollbeding.
|
* Modified 2003-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -323,18 +323,17 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
|||||||
/* Expect normal source image, not raw downsampled data */
|
/* Expect normal source image, not raw downsampled data */
|
||||||
cinfo->raw_data_in = FALSE;
|
cinfo->raw_data_in = FALSE;
|
||||||
|
|
||||||
/* Use Huffman coding, not arithmetic coding, by default */
|
/* The standard Huffman tables are only valid for 8-bit data precision.
|
||||||
cinfo->arith_code = FALSE;
|
* If the precision is higher, use arithmetic coding.
|
||||||
|
* (Alternatively, using Huffman coding would be possible with forcing
|
||||||
|
* optimization on so that usable tables will be computed, or by
|
||||||
|
* supplying default tables that are valid for the desired precision.)
|
||||||
|
* Otherwise, use Huffman coding by default.
|
||||||
|
*/
|
||||||
|
cinfo->arith_code = cinfo->data_precision > 8 ? TRUE : FALSE;
|
||||||
|
|
||||||
/* By default, don't do extra passes to optimize entropy coding */
|
/* By default, don't do extra passes to optimize entropy coding */
|
||||||
cinfo->optimize_coding = FALSE;
|
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 */
|
/* By default, use the simpler non-cosited sampling alignment */
|
||||||
cinfo->CCIR601_sampling = FALSE;
|
cinfo->CCIR601_sampling = FALSE;
|
||||||
@@ -360,6 +359,9 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
|||||||
* JFIF_minor_version to 2. We could probably get away with just defaulting
|
* 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
|
* to 1.02, but there may still be some decoders in use that will complain
|
||||||
* about that; saying 1.01 should minimize compatibility problems.
|
* about that; saying 1.01 should minimize compatibility problems.
|
||||||
|
*
|
||||||
|
* For wide gamut colorspaces (BG_RGB and BG_YCC), the major version will be
|
||||||
|
* overridden by jpeg_set_colorspace and set to 2.
|
||||||
*/
|
*/
|
||||||
cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */
|
cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */
|
||||||
cinfo->JFIF_minor_version = 1;
|
cinfo->JFIF_minor_version = 1;
|
||||||
@@ -384,6 +386,9 @@ GLOBAL(void)
|
|||||||
jpeg_default_colorspace (j_compress_ptr cinfo)
|
jpeg_default_colorspace (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
switch (cinfo->in_color_space) {
|
switch (cinfo->in_color_space) {
|
||||||
|
case JCS_UNKNOWN:
|
||||||
|
jpeg_set_colorspace(cinfo, JCS_UNKNOWN);
|
||||||
|
break;
|
||||||
case JCS_GRAYSCALE:
|
case JCS_GRAYSCALE:
|
||||||
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
||||||
break;
|
break;
|
||||||
@@ -399,8 +404,12 @@ jpeg_default_colorspace (j_compress_ptr cinfo)
|
|||||||
case JCS_YCCK:
|
case JCS_YCCK:
|
||||||
jpeg_set_colorspace(cinfo, JCS_YCCK);
|
jpeg_set_colorspace(cinfo, JCS_YCCK);
|
||||||
break;
|
break;
|
||||||
case JCS_UNKNOWN:
|
case JCS_BG_RGB:
|
||||||
jpeg_set_colorspace(cinfo, JCS_UNKNOWN);
|
/* No translation for now -- conversion to BG_YCC not yet supportet */
|
||||||
|
jpeg_set_colorspace(cinfo, JCS_BG_RGB);
|
||||||
|
break;
|
||||||
|
case JCS_BG_YCC:
|
||||||
|
jpeg_set_colorspace(cinfo, JCS_BG_YCC);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||||
@@ -441,29 +450,40 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
|||||||
cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */
|
cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */
|
||||||
|
|
||||||
switch (colorspace) {
|
switch (colorspace) {
|
||||||
|
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;
|
||||||
case JCS_GRAYSCALE:
|
case JCS_GRAYSCALE:
|
||||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||||
cinfo->num_components = 1;
|
cinfo->num_components = 1;
|
||||||
/* JFIF specifies component ID 1 */
|
/* JFIF specifies component ID 1 */
|
||||||
SET_COMP(0, 1, 1,1, 0, 0,0);
|
SET_COMP(0, 0x01, 1,1, 0, 0,0);
|
||||||
break;
|
break;
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
||||||
cinfo->num_components = 3;
|
cinfo->num_components = 3;
|
||||||
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0);
|
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0,
|
||||||
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0,
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||||
|
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);
|
||||||
|
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||||
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0);
|
|
||||||
break;
|
break;
|
||||||
case JCS_YCbCr:
|
case JCS_YCbCr:
|
||||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||||
cinfo->num_components = 3;
|
cinfo->num_components = 3;
|
||||||
/* JFIF specifies component IDs 1,2,3 */
|
/* JFIF specifies component IDs 1,2,3 */
|
||||||
/* We default to 2x2 subsamples of chrominance */
|
/* We default to 2x2 subsamples of chrominance */
|
||||||
SET_COMP(0, 1, 2,2, 0, 0,0);
|
SET_COMP(0, 0x01, 2,2, 0, 0,0);
|
||||||
SET_COMP(1, 2, 1,1, 1, 1,1);
|
SET_COMP(1, 0x02, 1,1, 1, 1,1);
|
||||||
SET_COMP(2, 3, 1,1, 1, 1,1);
|
SET_COMP(2, 0x03, 1,1, 1, 1,1);
|
||||||
break;
|
break;
|
||||||
case JCS_CMYK:
|
case JCS_CMYK:
|
||||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
|
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
|
||||||
@@ -476,19 +496,33 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
|||||||
case JCS_YCCK:
|
case JCS_YCCK:
|
||||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
|
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
|
||||||
cinfo->num_components = 4;
|
cinfo->num_components = 4;
|
||||||
SET_COMP(0, 1, 2,2, 0, 0,0);
|
SET_COMP(0, 0x01, 2,2, 0, 0,0);
|
||||||
SET_COMP(1, 2, 1,1, 1, 1,1);
|
SET_COMP(1, 0x02, 1,1, 1, 1,1);
|
||||||
SET_COMP(2, 3, 1,1, 1, 1,1);
|
SET_COMP(2, 0x03, 1,1, 1, 1,1);
|
||||||
SET_COMP(3, 4, 2,2, 0, 0,0);
|
SET_COMP(3, 0x04, 2,2, 0, 0,0);
|
||||||
break;
|
break;
|
||||||
case JCS_UNKNOWN:
|
case JCS_BG_RGB:
|
||||||
cinfo->num_components = cinfo->input_components;
|
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||||
if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS)
|
cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */
|
||||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
cinfo->num_components = 3;
|
||||||
MAX_COMPONENTS);
|
/* Add offset 0x20 to the normal R/G/B component IDs */
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
SET_COMP(0, 0x72 /* 'r' */, 1,1, 0,
|
||||||
SET_COMP(ci, ci, 1,1, 0, 0,0);
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
}
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||||
|
SET_COMP(1, 0x67 /* 'g' */, 1,1, 0, 0,0);
|
||||||
|
SET_COMP(2, 0x62 /* 'b' */, 1,1, 0,
|
||||||
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||||
|
break;
|
||||||
|
case JCS_BG_YCC:
|
||||||
|
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||||
|
cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */
|
||||||
|
cinfo->num_components = 3;
|
||||||
|
/* Add offset 0x20 to the normal Cb/Cr component IDs */
|
||||||
|
/* We default to 2x2 subsamples of chrominance */
|
||||||
|
SET_COMP(0, 0x01, 2,2, 0, 0,0);
|
||||||
|
SET_COMP(1, 0x22, 1,1, 1, 1,1);
|
||||||
|
SET_COMP(2, 0x23, 1,1, 1, 1,1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||||
@@ -572,8 +606,10 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
|||||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||||
|
|
||||||
/* Figure space needed for script. Calculation must match code below! */
|
/* Figure space needed for script. Calculation must match code below! */
|
||||||
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
if (ncomps == 3 &&
|
||||||
/* Custom script for YCbCr color images. */
|
(cinfo->jpeg_color_space == JCS_YCbCr ||
|
||||||
|
cinfo->jpeg_color_space == JCS_BG_YCC)) {
|
||||||
|
/* Custom script for YCC color images. */
|
||||||
nscans = 10;
|
nscans = 10;
|
||||||
} else {
|
} else {
|
||||||
/* All-purpose script for other color spaces. */
|
/* All-purpose script for other color spaces. */
|
||||||
@@ -588,7 +624,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
|||||||
* multiple compressions without changing the settings. To avoid a memory
|
* multiple compressions without changing the settings. To avoid a memory
|
||||||
* leak if jpeg_simple_progression is called repeatedly for the same JPEG
|
* leak if jpeg_simple_progression is called repeatedly for the same JPEG
|
||||||
* object, we try to re-use previously allocated space, and we allocate
|
* object, we try to re-use previously allocated space, and we allocate
|
||||||
* enough space to handle YCbCr even if initially asked for grayscale.
|
* enough space to handle YCC even if initially asked for grayscale.
|
||||||
*/
|
*/
|
||||||
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
|
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
|
||||||
cinfo->script_space_size = MAX(nscans, 10);
|
cinfo->script_space_size = MAX(nscans, 10);
|
||||||
@@ -600,8 +636,10 @@ jpeg_simple_progression (j_compress_ptr cinfo)
|
|||||||
cinfo->scan_info = scanptr;
|
cinfo->scan_info = scanptr;
|
||||||
cinfo->num_scans = nscans;
|
cinfo->num_scans = nscans;
|
||||||
|
|
||||||
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
if (ncomps == 3 &&
|
||||||
/* Custom script for YCbCr color images. */
|
(cinfo->jpeg_color_space == JCS_YCbCr ||
|
||||||
|
cinfo->jpeg_color_space == JCS_BG_YCC)) {
|
||||||
|
/* Custom script for YCC color images. */
|
||||||
/* Initial DC scan */
|
/* Initial DC scan */
|
||||||
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
||||||
/* Initial AC scan: get some luma data out in a hurry */
|
/* Initial AC scan: get some luma data out in a hurry */
|
||||||
|
|||||||
Vendored
+3
-3
@@ -2,7 +2,7 @@
|
|||||||
* jctrans.c
|
* jctrans.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1995-1998, Thomas G. Lane.
|
* Copyright (C) 1995-1998, Thomas G. Lane.
|
||||||
* Modified 2000-2012 by Guido Vollbeding.
|
* Modified 2000-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -143,10 +143,10 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
|||||||
* if the application chooses to copy JFIF 1.02 extension markers from
|
* 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
|
* 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.
|
* 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->saw_JFIF_marker) {
|
||||||
if (srcinfo->JFIF_major_version == 1) {
|
if (srcinfo->JFIF_major_version == 1 ||
|
||||||
|
srcinfo->JFIF_major_version == 2) {
|
||||||
dstinfo->JFIF_major_version = srcinfo->JFIF_major_version;
|
dstinfo->JFIF_major_version = srcinfo->JFIF_major_version;
|
||||||
dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version;
|
dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+19
-16
@@ -2,7 +2,7 @@
|
|||||||
* jdapimin.c
|
* jdapimin.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||||
* Modified 2009 by Guido Vollbeding.
|
* Modified 2009-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -114,8 +114,9 @@ jpeg_abort_decompress (j_decompress_ptr cinfo)
|
|||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
default_decompress_parms (j_decompress_ptr cinfo)
|
default_decompress_parms (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
|
int cid0, cid1, cid2;
|
||||||
|
|
||||||
/* Guess the input colorspace, and set output colorspace accordingly. */
|
/* 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. */
|
/* Note application may override our guesses. */
|
||||||
switch (cinfo->num_components) {
|
switch (cinfo->num_components) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -124,9 +125,22 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (cinfo->saw_JFIF_marker) {
|
cid0 = cinfo->comp_info[0].component_id;
|
||||||
cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
|
cid1 = cinfo->comp_info[1].component_id;
|
||||||
} else if (cinfo->saw_Adobe_marker) {
|
cid2 = cinfo->comp_info[2].component_id;
|
||||||
|
|
||||||
|
/* First try to guess from the component IDs */
|
||||||
|
if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03)
|
||||||
|
cinfo->jpeg_color_space = JCS_YCbCr;
|
||||||
|
else if (cid0 == 0x01 && cid1 == 0x22 && cid2 == 0x23)
|
||||||
|
cinfo->jpeg_color_space = JCS_BG_YCC;
|
||||||
|
else if (cid0 == 0x52 && cid1 == 0x47 && cid2 == 0x42)
|
||||||
|
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
|
||||||
|
else if (cid0 == 0x72 && cid1 == 0x67 && cid2 == 0x62)
|
||||||
|
cinfo->jpeg_color_space = JCS_BG_RGB; /* ASCII 'r', 'g', 'b' */
|
||||||
|
else if (cinfo->saw_JFIF_marker)
|
||||||
|
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
||||||
|
else if (cinfo->saw_Adobe_marker) {
|
||||||
switch (cinfo->Adobe_transform) {
|
switch (cinfo->Adobe_transform) {
|
||||||
case 0:
|
case 0:
|
||||||
cinfo->jpeg_color_space = JCS_RGB;
|
cinfo->jpeg_color_space = JCS_RGB;
|
||||||
@@ -140,20 +154,9 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
|
||||||
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/* Always guess RGB is proper output colorspace. */
|
/* Always guess RGB is proper output colorspace. */
|
||||||
cinfo->out_color_space = JCS_RGB;
|
cinfo->out_color_space = JCS_RGB;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Vendored
+1
@@ -2,6 +2,7 @@
|
|||||||
* jdapistd.c
|
* jdapistd.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
|
* Modified 2002-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
|
|||||||
Vendored
+16
-2
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jdarith.c
|
* jdarith.c
|
||||||
*
|
*
|
||||||
* Developed 1997-2012 by Guido Vollbeding.
|
* Developed 1997-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -94,7 +94,7 @@ get_byte (j_decompress_ptr cinfo)
|
|||||||
* (instead of fixed) with the bit shift counter CT.
|
* (instead of fixed) with the bit shift counter CT.
|
||||||
* Thus, we also need only one (variable instead of
|
* Thus, we also need only one (variable instead of
|
||||||
* fixed size) shift for the LPS/MPS decision, and
|
* fixed size) shift for the LPS/MPS decision, and
|
||||||
* we can get away with any renormalization update
|
* we can do away with any renormalization update
|
||||||
* of C (except for new data insertion, of course).
|
* of C (except for new data insertion, of course).
|
||||||
*
|
*
|
||||||
* I've also introduced a new scheme for accessing
|
* I've also introduced a new scheme for accessing
|
||||||
@@ -395,6 +395,8 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* MCU decoding for DC successive approximation refinement scan.
|
* 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)
|
METHODDEF(boolean)
|
||||||
@@ -743,6 +745,17 @@ start_pass (j_decompress_ptr cinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finish up at the end of an arithmetic-compressed scan.
|
||||||
|
*/
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
finish_pass (j_decompress_ptr cinfo)
|
||||||
|
{
|
||||||
|
/* no work necessary here */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Module initialization routine for arithmetic entropy decoding.
|
* Module initialization routine for arithmetic entropy decoding.
|
||||||
*/
|
*/
|
||||||
@@ -758,6 +771,7 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
|||||||
SIZEOF(arith_entropy_decoder));
|
SIZEOF(arith_entropy_decoder));
|
||||||
cinfo->entropy = &entropy->pub;
|
cinfo->entropy = &entropy->pub;
|
||||||
entropy->pub.start_pass = start_pass;
|
entropy->pub.start_pass = start_pass;
|
||||||
|
entropy->pub.finish_pass = finish_pass;
|
||||||
|
|
||||||
/* Mark tables unallocated */
|
/* Mark tables unallocated */
|
||||||
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
||||||
|
|||||||
Vendored
+3
-3
@@ -2,7 +2,7 @@
|
|||||||
* jdatasrc.c
|
* jdatasrc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2009-2011 by Guido Vollbeding.
|
* Modified 2009-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -247,7 +247,7 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
|
|||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_mem_src (j_decompress_ptr cinfo,
|
jpeg_mem_src (j_decompress_ptr cinfo,
|
||||||
unsigned char * inbuffer, unsigned long insize)
|
const unsigned char * inbuffer, unsigned long insize)
|
||||||
{
|
{
|
||||||
struct jpeg_source_mgr * src;
|
struct jpeg_source_mgr * src;
|
||||||
|
|
||||||
@@ -271,5 +271,5 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
|||||||
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
|
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
|
||||||
src->term_source = term_source;
|
src->term_source = term_source;
|
||||||
src->bytes_in_buffer = (size_t) insize;
|
src->bytes_in_buffer = (size_t) insize;
|
||||||
src->next_input_byte = (JOCTET *) inbuffer;
|
src->next_input_byte = (const JOCTET *) inbuffer;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+152
-45
@@ -2,7 +2,7 @@
|
|||||||
* jdcolor.c
|
* jdcolor.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2011-2012 by Guido Vollbeding.
|
* Modified 2011-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
struct jpeg_color_deconverter pub; /* public fields */
|
struct jpeg_color_deconverter pub; /* public fields */
|
||||||
|
|
||||||
/* Private state for YCC->RGB conversion */
|
/* Private state for YCbCr->RGB and BG_YCC->RGB conversion */
|
||||||
int * Cr_r_tab; /* => table for Cr to R conversion */
|
int * Cr_r_tab; /* => table for Cr to R conversion */
|
||||||
int * Cb_b_tab; /* => table for Cb to B conversion */
|
int * Cb_b_tab; /* => table for Cb to B conversion */
|
||||||
INT32 * Cr_g_tab; /* => table for Cr to G conversion */
|
INT32 * Cr_g_tab; /* => table for Cr to G conversion */
|
||||||
@@ -32,22 +32,44 @@ typedef struct {
|
|||||||
typedef my_color_deconverter * my_cconvert_ptr;
|
typedef my_color_deconverter * my_cconvert_ptr;
|
||||||
|
|
||||||
|
|
||||||
/**************** YCbCr -> RGB conversion: most common case **************/
|
/*************** YCbCr -> RGB conversion: most common case **************/
|
||||||
/**************** RGB -> Y conversion: less common case **************/
|
/*************** BG_YCC -> RGB conversion: less common case **************/
|
||||||
|
/*************** RGB -> Y conversion: less common case **************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* YCbCr is defined per CCIR 601-1, except that Cb and Cr are
|
* YCbCr is defined per Recommendation ITU-R BT.601-7 (03/2011),
|
||||||
* normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
|
* previously known as Recommendation CCIR 601-1, except that Cb and Cr
|
||||||
* The conversion equations to be implemented are therefore
|
* are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
|
||||||
|
* sRGB (standard RGB color space) is defined per IEC 61966-2-1:1999.
|
||||||
|
* sYCC (standard luma-chroma-chroma color space with extended gamut)
|
||||||
|
* is defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex F.
|
||||||
|
* bg-sRGB and bg-sYCC (big gamut standard color spaces)
|
||||||
|
* are defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex G.
|
||||||
|
* Note that the derived conversion coefficients given in some of these
|
||||||
|
* documents are imprecise. The general conversion equations are
|
||||||
*
|
*
|
||||||
* R = Y + 1.40200 * Cr
|
* R = Y + K * (1 - Kr) * Cr
|
||||||
* G = Y - 0.34414 * Cb - 0.71414 * Cr
|
* G = Y - K * (Kb * (1 - Kb) * Cb + Kr * (1 - Kr) * Cr) / (1 - Kr - Kb)
|
||||||
* B = Y + 1.77200 * Cb
|
* B = Y + K * (1 - Kb) * Cb
|
||||||
*
|
*
|
||||||
* Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
|
* Y = Kr * R + (1 - Kr - Kb) * G + Kb * B
|
||||||
|
*
|
||||||
|
* With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993
|
||||||
|
* from the 1953 FCC NTSC primaries and CIE Illuminant C), K = 2 for sYCC,
|
||||||
|
* the conversion equations to be implemented are therefore
|
||||||
|
*
|
||||||
|
* R = Y + 1.402 * Cr
|
||||||
|
* G = Y - 0.344136286 * Cb - 0.714136286 * Cr
|
||||||
|
* B = Y + 1.772 * Cb
|
||||||
|
*
|
||||||
|
* Y = 0.299 * R + 0.587 * G + 0.114 * B
|
||||||
*
|
*
|
||||||
* where Cb and Cr represent the incoming values less CENTERJSAMPLE.
|
* where Cb and Cr represent the incoming values less CENTERJSAMPLE.
|
||||||
* (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
|
* For bg-sYCC, with K = 4, the equations are
|
||||||
|
*
|
||||||
|
* R = Y + 2.804 * Cr
|
||||||
|
* G = Y - 0.688272572 * Cb - 1.428272572 * Cr
|
||||||
|
* B = Y + 3.544 * Cb
|
||||||
*
|
*
|
||||||
* To avoid floating-point arithmetic, we represent the fractional constants
|
* 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
|
* as integers scaled up by 2^16 (about 4 digits precision); we have to divide
|
||||||
@@ -58,9 +80,9 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
|||||||
* For even more speed, we avoid doing any multiplications in the inner loop
|
* 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.
|
* 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 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
|
* for 9-bit to 12-bit samples it is still acceptable. It's not very
|
||||||
* 16-bit samples, but if you want lossless storage you shouldn't be changing
|
* reasonable for 16-bit samples, but if you want lossless storage you
|
||||||
* colorspace anyway.
|
* shouldn't be changing colorspace anyway.
|
||||||
* The Cr=>R and Cb=>B values can be rounded to integers in advance; the
|
* 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
|
* values for the G calculation are left scaled up, since we must add them
|
||||||
* together before rounding.
|
* together before rounding.
|
||||||
@@ -84,11 +106,12 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize tables for YCC->RGB colorspace conversion.
|
* Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||||
|
/* Normal case, sYCC */
|
||||||
{
|
{
|
||||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||||
int i;
|
int i;
|
||||||
@@ -111,17 +134,57 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
|||||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
/* 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 */
|
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
|
||||||
/* Cr=>R value is nearest int to 1.40200 * x */
|
/* Cr=>R value is nearest int to 1.402 * x */
|
||||||
cconvert->Cr_r_tab[i] = (int)
|
cconvert->Cr_r_tab[i] = (int)
|
||||||
RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
|
RIGHT_SHIFT(FIX(1.402) * x + ONE_HALF, SCALEBITS);
|
||||||
/* Cb=>B value is nearest int to 1.77200 * x */
|
/* Cb=>B value is nearest int to 1.772 * x */
|
||||||
cconvert->Cb_b_tab[i] = (int)
|
cconvert->Cb_b_tab[i] = (int)
|
||||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
RIGHT_SHIFT(FIX(1.772) * x + ONE_HALF, SCALEBITS);
|
||||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
/* Cr=>G value is scaled-up -0.714136286 * x */
|
||||||
cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
cconvert->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
|
||||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
/* Cb=>G value is scaled-up -0.344136286 * x */
|
||||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
/* 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;
|
cconvert->Cb_g_tab[i] = (- FIX(0.344136286)) * x + ONE_HALF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL(void)
|
||||||
|
build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||||
|
/* Wide gamut case, bg-sYCC */
|
||||||
|
{
|
||||||
|
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||||
|
int i;
|
||||||
|
INT32 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 = (INT32 *)
|
||||||
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||||
|
cconvert->Cb_g_tab = (INT32 *)
|
||||||
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||||
|
|
||||||
|
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 2.804 * x */
|
||||||
|
cconvert->Cr_r_tab[i] = (int)
|
||||||
|
RIGHT_SHIFT(FIX(2.804) * x + ONE_HALF, SCALEBITS);
|
||||||
|
/* Cb=>B value is nearest int to 3.544 * x */
|
||||||
|
cconvert->Cb_b_tab[i] = (int)
|
||||||
|
RIGHT_SHIFT(FIX(3.544) * x + ONE_HALF, SCALEBITS);
|
||||||
|
/* Cr=>G value is scaled-up -1.428272572 * x */
|
||||||
|
cconvert->Cr_g_tab[i] = (- FIX(1.428272572)) * x;
|
||||||
|
/* Cb=>G value is scaled-up -0.688272572 * x */
|
||||||
|
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||||
|
cconvert->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +229,9 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
|
|||||||
y = GETJSAMPLE(inptr0[col]);
|
y = GETJSAMPLE(inptr0[col]);
|
||||||
cb = GETJSAMPLE(inptr1[col]);
|
cb = GETJSAMPLE(inptr1[col]);
|
||||||
cr = GETJSAMPLE(inptr2[col]);
|
cr = GETJSAMPLE(inptr2[col]);
|
||||||
/* Range-limiting is essential due to noise introduced by DCT losses. */
|
/* Range-limiting is essential due to noise introduced by DCT losses,
|
||||||
|
* for extended gamut (sYCC) and wide gamut (bg-sYCC) encodings.
|
||||||
|
*/
|
||||||
outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
|
outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
|
||||||
outptr[RGB_GREEN] = range_limit[y +
|
outptr[RGB_GREEN] = range_limit[y +
|
||||||
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||||
@@ -178,7 +243,7 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************** Cases other than YCbCr -> RGB **************/
|
/**************** Cases other than YCC -> RGB ****************/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -198,9 +263,9 @@ build_rgb_y_table (j_decompress_ptr cinfo)
|
|||||||
(TABLE_SIZE * SIZEOF(INT32)));
|
(TABLE_SIZE * SIZEOF(INT32)));
|
||||||
|
|
||||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||||
rgb_y_tab[i+R_Y_OFF] = FIX(0.29900) * i;
|
rgb_y_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
||||||
rgb_y_tab[i+G_Y_OFF] = FIX(0.58700) * i;
|
rgb_y_tab[i+G_Y_OFF] = FIX(0.587) * i;
|
||||||
rgb_y_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF;
|
rgb_y_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,6 +309,9 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
|||||||
/*
|
/*
|
||||||
* [R-G,G,B-G] to [R,G,B] conversion with modulo calculation
|
* [R-G,G,B-G] to [R,G,B] conversion with modulo calculation
|
||||||
* (inverse color transform).
|
* (inverse color transform).
|
||||||
|
* This can be seen as an adaption of the general YCbCr->RGB
|
||||||
|
* conversion equation with Kr = Kb = 0, while replacing the
|
||||||
|
* normalization by modulo calculation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
@@ -387,7 +455,7 @@ null_convert (j_decompress_ptr cinfo,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Color conversion for grayscale: just copy the data.
|
* Color conversion for grayscale: just copy the data.
|
||||||
* This also works for YCbCr -> grayscale conversion, in which
|
* This also works for YCC -> grayscale conversion, in which
|
||||||
* we just copy the Y (luminance) component and ignore chrominance.
|
* we just copy the Y (luminance) component and ignore chrominance.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -466,7 +534,9 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
|
|||||||
y = GETJSAMPLE(inptr0[col]);
|
y = GETJSAMPLE(inptr0[col]);
|
||||||
cb = GETJSAMPLE(inptr1[col]);
|
cb = GETJSAMPLE(inptr1[col]);
|
||||||
cr = GETJSAMPLE(inptr2[col]);
|
cr = GETJSAMPLE(inptr2[col]);
|
||||||
/* Range-limiting is essential due to noise introduced by DCT losses. */
|
/* Range-limiting is essential due to noise introduced by DCT losses,
|
||||||
|
* and for extended gamut encodings (sYCC).
|
||||||
|
*/
|
||||||
outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
|
outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
|
||||||
outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */
|
outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */
|
||||||
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||||
@@ -516,6 +586,8 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
case JCS_YCbCr:
|
case JCS_YCbCr:
|
||||||
|
case JCS_BG_RGB:
|
||||||
|
case JCS_BG_YCC:
|
||||||
if (cinfo->num_components != 3)
|
if (cinfo->num_components != 3)
|
||||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||||
break;
|
break;
|
||||||
@@ -532,8 +604,10 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Support color transform only for RGB colorspace */
|
/* Support color transform only for RGB colorspaces */
|
||||||
if (cinfo->color_transform && cinfo->jpeg_color_space != JCS_RGB)
|
if (cinfo->color_transform &&
|
||||||
|
cinfo->jpeg_color_space != JCS_RGB &&
|
||||||
|
cinfo->jpeg_color_space != JCS_BG_RGB)
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
|
||||||
/* Set out_color_components and conversion method based on requested space.
|
/* Set out_color_components and conversion method based on requested space.
|
||||||
@@ -544,13 +618,16 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
switch (cinfo->out_color_space) {
|
switch (cinfo->out_color_space) {
|
||||||
case JCS_GRAYSCALE:
|
case JCS_GRAYSCALE:
|
||||||
cinfo->out_color_components = 1;
|
cinfo->out_color_components = 1;
|
||||||
if (cinfo->jpeg_color_space == JCS_GRAYSCALE ||
|
switch (cinfo->jpeg_color_space) {
|
||||||
cinfo->jpeg_color_space == JCS_YCbCr) {
|
case JCS_GRAYSCALE:
|
||||||
|
case JCS_YCbCr:
|
||||||
|
case JCS_BG_YCC:
|
||||||
cconvert->pub.color_convert = grayscale_convert;
|
cconvert->pub.color_convert = grayscale_convert;
|
||||||
/* For color->grayscale conversion, only the Y (0) component is needed */
|
/* For color->grayscale conversion, only the Y (0) component is needed */
|
||||||
for (ci = 1; ci < cinfo->num_components; ci++)
|
for (ci = 1; ci < cinfo->num_components; ci++)
|
||||||
cinfo->comp_info[ci].component_needed = FALSE;
|
cinfo->comp_info[ci].component_needed = FALSE;
|
||||||
} else if (cinfo->jpeg_color_space == JCS_RGB) {
|
break;
|
||||||
|
case JCS_RGB:
|
||||||
switch (cinfo->color_transform) {
|
switch (cinfo->color_transform) {
|
||||||
case JCT_NONE:
|
case JCT_NONE:
|
||||||
cconvert->pub.color_convert = rgb_gray_convert;
|
cconvert->pub.color_convert = rgb_gray_convert;
|
||||||
@@ -560,21 +637,29 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
build_rgb_y_table(cinfo);
|
build_rgb_y_table(cinfo);
|
||||||
} else
|
break;
|
||||||
|
default:
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
cinfo->out_color_components = RGB_PIXELSIZE;
|
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||||
if (cinfo->jpeg_color_space == JCS_YCbCr) {
|
switch (cinfo->jpeg_color_space) {
|
||||||
|
case JCS_GRAYSCALE:
|
||||||
|
cconvert->pub.color_convert = gray_rgb_convert;
|
||||||
|
break;
|
||||||
|
case JCS_YCbCr:
|
||||||
cconvert->pub.color_convert = ycc_rgb_convert;
|
cconvert->pub.color_convert = ycc_rgb_convert;
|
||||||
build_ycc_rgb_table(cinfo);
|
build_ycc_rgb_table(cinfo);
|
||||||
} else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) {
|
break;
|
||||||
cconvert->pub.color_convert = gray_rgb_convert;
|
case JCS_BG_YCC:
|
||||||
} else if (cinfo->jpeg_color_space == JCS_RGB) {
|
cconvert->pub.color_convert = ycc_rgb_convert;
|
||||||
|
build_bg_ycc_rgb_table(cinfo);
|
||||||
|
break;
|
||||||
|
case JCS_RGB:
|
||||||
switch (cinfo->color_transform) {
|
switch (cinfo->color_transform) {
|
||||||
case JCT_NONE:
|
case JCT_NONE:
|
||||||
cconvert->pub.color_convert = rgb_convert;
|
cconvert->pub.color_convert = rgb_convert;
|
||||||
@@ -584,7 +669,25 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JCS_BG_RGB:
|
||||||
|
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||||
|
if (cinfo->jpeg_color_space == JCS_BG_RGB) {
|
||||||
|
switch (cinfo->color_transform) {
|
||||||
|
case JCT_NONE:
|
||||||
|
cconvert->pub.color_convert = rgb_convert;
|
||||||
|
break;
|
||||||
|
case JCT_SUBTRACT_GREEN:
|
||||||
|
cconvert->pub.color_convert = rgb1_rgb_convert;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
@@ -592,13 +695,17 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
case JCS_CMYK:
|
case JCS_CMYK:
|
||||||
cinfo->out_color_components = 4;
|
cinfo->out_color_components = 4;
|
||||||
if (cinfo->jpeg_color_space == JCS_YCCK) {
|
switch (cinfo->jpeg_color_space) {
|
||||||
|
case JCS_YCCK:
|
||||||
cconvert->pub.color_convert = ycck_cmyk_convert;
|
cconvert->pub.color_convert = ycck_cmyk_convert;
|
||||||
build_ycc_rgb_table(cinfo);
|
build_ycc_rgb_table(cinfo);
|
||||||
} else if (cinfo->jpeg_color_space == JCS_CMYK) {
|
break;
|
||||||
|
case JCS_CMYK:
|
||||||
cconvert->pub.color_convert = null_convert;
|
cconvert->pub.color_convert = null_convert;
|
||||||
} else
|
break;
|
||||||
|
default:
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Vendored
+28
-4
@@ -2,6 +2,7 @@
|
|||||||
* jdct.h
|
* jdct.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
|
* Modified 2002-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -78,13 +79,16 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
|
|||||||
* converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
|
* 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
|
* 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
|
* range-limiting step is required. We use a mask-and-table-lookup method
|
||||||
* to do the combined operations quickly. See the comments with
|
* to do the combined operations quickly, assuming that MAXJSAMPLE+1
|
||||||
* prepare_range_limit_table (in jdmaster.c) for more info.
|
* is a power of 2. 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 */
|
#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
|
||||||
|
#define RANGE_CENTER (MAXJSAMPLE * 2 + 2)
|
||||||
|
#define RANGE_SUBSET (RANGE_CENTER - CENTERJSAMPLE)
|
||||||
|
|
||||||
|
#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit - RANGE_SUBSET)
|
||||||
|
|
||||||
|
|
||||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||||
@@ -391,3 +395,23 @@ EXTERN(void) jpeg_idct_1x2
|
|||||||
#ifndef MULTIPLY16V16 /* default definition */
|
#ifndef MULTIPLY16V16 /* default definition */
|
||||||
#define MULTIPLY16V16(var1,var2) ((var1) * (var2))
|
#define MULTIPLY16V16(var1,var2) ((var1) * (var2))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Like RIGHT_SHIFT, but applies to a DCTELEM.
|
||||||
|
* We assume that int right shift is unsigned if INT32 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
|
||||||
|
|||||||
Vendored
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
* jddctmgr.c
|
* jddctmgr.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2002-2010 by Guido Vollbeding.
|
* Modified 2002-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -368,7 +368,7 @@ jinit_inverse_dct (j_decompress_ptr cinfo)
|
|||||||
idct = (my_idct_ptr)
|
idct = (my_idct_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
SIZEOF(my_idct_controller));
|
SIZEOF(my_idct_controller));
|
||||||
cinfo->idct = (struct jpeg_inverse_dct *) idct;
|
cinfo->idct = &idct->pub;
|
||||||
idct->pub.start_pass = start_pass;
|
idct->pub.start_pass = start_pass;
|
||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
|
|||||||
Vendored
+25
-13
@@ -2,7 +2,7 @@
|
|||||||
* jdhuff.c
|
* jdhuff.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2006-2012 by Guido Vollbeding.
|
* Modified 2006-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -627,6 +627,22 @@ jpeg_huff_decode (bitread_working_state * state,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finish up at the end of a Huffman-compressed scan.
|
||||||
|
*/
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
finish_pass_huff (j_decompress_ptr cinfo)
|
||||||
|
{
|
||||||
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for a restart marker & resynchronize decoder.
|
* Check for a restart marker & resynchronize decoder.
|
||||||
* Returns FALSE if must suspend.
|
* Returns FALSE if must suspend.
|
||||||
@@ -638,10 +654,7 @@ process_restart (j_decompress_ptr cinfo)
|
|||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
int ci;
|
int ci;
|
||||||
|
|
||||||
/* Throw away any unused bits remaining in bit buffer; */
|
finish_pass_huff(cinfo);
|
||||||
/* 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 */
|
/* Advance past the RSTn marker */
|
||||||
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
if (! (*cinfo->marker->read_restart_marker) (cinfo))
|
||||||
@@ -846,17 +859,15 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* MCU decoding for DC successive approximation refinement scan.
|
* MCU decoding for DC successive approximation refinement scan.
|
||||||
* Note: we assume such scans can be multi-component, although the spec
|
* Note: we assume such scans can be multi-component,
|
||||||
* is not very clear on the point.
|
* although the spec is not very clear on the point.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
int p1, blkn;
|
||||||
int blkn;
|
|
||||||
JBLOCKROW block;
|
|
||||||
BITREAD_STATE_VARS;
|
BITREAD_STATE_VARS;
|
||||||
|
|
||||||
/* Process restart marker if needed; may have to suspend */
|
/* Process restart marker if needed; may have to suspend */
|
||||||
@@ -873,15 +884,15 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
/* Load up working state */
|
/* Load up working state */
|
||||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||||
|
|
||||||
|
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||||
|
|
||||||
/* Outer loop handles each block in the MCU */
|
/* Outer loop handles each block in the MCU */
|
||||||
|
|
||||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
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 */
|
/* Encoded data is simply the next bit of the two's-complement DC value */
|
||||||
CHECK_BIT_BUFFER(br_state, 1, return FALSE);
|
CHECK_BIT_BUFFER(br_state, 1, return FALSE);
|
||||||
if (GET_BITS(1))
|
if (GET_BITS(1))
|
||||||
(*block)[0] |= p1;
|
MCU_data[blkn][0][0] |= p1;
|
||||||
/* Note: since we use |=, repeating the assignment later is safe */
|
/* Note: since we use |=, repeating the assignment later is safe */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1517,6 +1528,7 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
|||||||
SIZEOF(huff_entropy_decoder));
|
SIZEOF(huff_entropy_decoder));
|
||||||
cinfo->entropy = &entropy->pub;
|
cinfo->entropy = &entropy->pub;
|
||||||
entropy->pub.start_pass = start_pass_huff_decoder;
|
entropy->pub.start_pass = start_pass_huff_decoder;
|
||||||
|
entropy->pub.finish_pass = finish_pass_huff;
|
||||||
|
|
||||||
if (cinfo->progressive_mode) {
|
if (cinfo->progressive_mode) {
|
||||||
/* Create progression status table */
|
/* Create progression status table */
|
||||||
|
|||||||
Vendored
+6
-5
@@ -2,7 +2,7 @@
|
|||||||
* jdinput.c
|
* jdinput.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2002-2009 by Guido Vollbeding.
|
* Modified 2002-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -196,7 +196,7 @@ jpeg_core_output_dimensions (j_decompress_ptr cinfo)
|
|||||||
/* Hardwire it to "no scaling" */
|
/* Hardwire it to "no scaling" */
|
||||||
cinfo->output_width = cinfo->image_width;
|
cinfo->output_width = cinfo->image_width;
|
||||||
cinfo->output_height = cinfo->image_height;
|
cinfo->output_height = cinfo->image_height;
|
||||||
/* jdinput.c has already initialized DCT_scaled_size,
|
/* initial_setup has already initialized DCT_scaled_size,
|
||||||
* and has computed unscaled downsampled_width and downsampled_height.
|
* and has computed unscaled downsampled_width and downsampled_height.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -216,8 +216,8 @@ initial_setup (j_decompress_ptr cinfo)
|
|||||||
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
|
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
|
||||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||||
|
|
||||||
/* For now, precision must match compiled-in value... */
|
/* Only 8 to 12 bits data precision are supported for DCT based JPEG */
|
||||||
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
if (cinfo->data_precision < 8 || cinfo->data_precision > 12)
|
||||||
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
||||||
|
|
||||||
/* Check that number of components won't exceed internal array sizes */
|
/* Check that number of components won't exceed internal array sizes */
|
||||||
@@ -537,6 +537,7 @@ start_input_pass (j_decompress_ptr cinfo)
|
|||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
finish_input_pass (j_decompress_ptr cinfo)
|
finish_input_pass (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
|
(*cinfo->entropy->finish_pass) (cinfo);
|
||||||
cinfo->inputctl->consume_input = consume_markers;
|
cinfo->inputctl->consume_input = consume_markers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +647,7 @@ jinit_input_controller (j_decompress_ptr cinfo)
|
|||||||
inputctl = (my_inputctl_ptr)
|
inputctl = (my_inputctl_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
SIZEOF(my_input_controller));
|
SIZEOF(my_input_controller));
|
||||||
cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
|
cinfo->inputctl = &inputctl->pub;
|
||||||
/* Initialize method pointers */
|
/* Initialize method pointers */
|
||||||
inputctl->pub.consume_input = consume_markers;
|
inputctl->pub.consume_input = consume_markers;
|
||||||
inputctl->pub.reset_input_controller = reset_input_controller;
|
inputctl->pub.reset_input_controller = reset_input_controller;
|
||||||
|
|||||||
Vendored
+11
-5
@@ -2,7 +2,7 @@
|
|||||||
* jdmarker.c
|
* jdmarker.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2009-2012 by Guido Vollbeding.
|
* Modified 2009-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -269,8 +269,8 @@ get_sof (j_decompress_ptr cinfo, boolean is_baseline, boolean is_prog,
|
|||||||
/* We don't support files in which the image height is initially specified */
|
/* 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, */
|
/* as 0 and is later redefined by DNL. As long as we have to check that, */
|
||||||
/* might as well have a general sanity check. */
|
/* might as well have a general sanity check. */
|
||||||
if (cinfo->image_height <= 0 || cinfo->image_width <= 0
|
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
|
||||||
|| cinfo->num_components <= 0)
|
cinfo->num_components <= 0)
|
||||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||||
|
|
||||||
if (length != (cinfo->num_components * 3))
|
if (length != (cinfo->num_components * 3))
|
||||||
@@ -350,6 +350,9 @@ get_sos (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
/* Detect the case where component id's are not unique, and, if so, */
|
/* Detect the case where component id's are not unique, and, if so, */
|
||||||
/* create a fake component id using the same logic as in get_sof. */
|
/* create a fake component id using the same logic as in get_sof. */
|
||||||
|
/* Note: This also ensures that all of the SOF components are */
|
||||||
|
/* referenced in the single scan case, which prevents access to */
|
||||||
|
/* uninitialized memory in later decoding stages. */
|
||||||
for (ci = 0; ci < i; ci++) {
|
for (ci = 0; ci < i; ci++) {
|
||||||
if (c == cinfo->cur_comp_info[ci]->component_id) {
|
if (c == cinfo->cur_comp_info[ci]->component_id) {
|
||||||
c = cinfo->cur_comp_info[0]->component_id;
|
c = cinfo->cur_comp_info[0]->component_id;
|
||||||
@@ -493,6 +496,8 @@ get_dht (j_decompress_ptr cinfo)
|
|||||||
if (count > 256 || ((INT32) count) > length)
|
if (count > 256 || ((INT32) count) > length)
|
||||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||||
|
|
||||||
|
MEMZERO(huffval, SIZEOF(huffval)); /* pre-zero array for later copy */
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
INPUT_BYTE(cinfo, huffval[i], return FALSE);
|
INPUT_BYTE(cinfo, huffval[i], return FALSE);
|
||||||
|
|
||||||
@@ -735,12 +740,13 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
|
|||||||
cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]);
|
cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]);
|
||||||
cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]);
|
cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]);
|
||||||
/* Check version.
|
/* Check version.
|
||||||
* Major version must be 1, anything else signals an incompatible change.
|
* Major version must be 1 or 2, anything else signals an incompatible
|
||||||
|
* change.
|
||||||
* (We used to treat this as an error, but now it's a nonfatal warning,
|
* (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.)
|
* because some bozo at Hijaak couldn't read the spec.)
|
||||||
* Minor version should be 0..2, but process anyway if newer.
|
* Minor version should be 0..2, but process anyway if newer.
|
||||||
*/
|
*/
|
||||||
if (cinfo->JFIF_major_version != 1)
|
if (cinfo->JFIF_major_version != 1 && cinfo->JFIF_major_version != 2)
|
||||||
WARNMS2(cinfo, JWRN_JFIF_MAJOR,
|
WARNMS2(cinfo, JWRN_JFIF_MAJOR,
|
||||||
cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
|
cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
|
||||||
/* Generate trace messages */
|
/* Generate trace messages */
|
||||||
|
|||||||
Vendored
+43
-35
@@ -2,7 +2,7 @@
|
|||||||
* jdmaster.c
|
* jdmaster.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2002-2011 by Guido Vollbeding.
|
* Modified 2002-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -45,13 +45,26 @@ LOCAL(boolean)
|
|||||||
use_merged_upsample (j_decompress_ptr cinfo)
|
use_merged_upsample (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||||
/* Merging is the equivalent of plain box-filter upsampling */
|
/* Merging is the equivalent of plain box-filter upsampling. */
|
||||||
if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
|
/* The following condition is only needed if fancy shall select
|
||||||
|
* a different upsampling method. In our current implementation
|
||||||
|
* fancy only affects the DCT scaling, thus we can use fancy
|
||||||
|
* upsampling and merged upsample simultaneously, in particular
|
||||||
|
* with scaled DCT sizes larger than the default DCTSIZE.
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
if (cinfo->do_fancy_upsampling)
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
if (cinfo->CCIR601_sampling)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
/* jdmerge.c only supports YCC=>RGB color conversion */
|
/* jdmerge.c only supports YCC=>RGB color conversion */
|
||||||
if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
|
if ((cinfo->jpeg_color_space != JCS_YCbCr &&
|
||||||
|
cinfo->jpeg_color_space != JCS_BG_YCC) ||
|
||||||
|
cinfo->num_components != 3 ||
|
||||||
cinfo->out_color_space != JCS_RGB ||
|
cinfo->out_color_space != JCS_RGB ||
|
||||||
cinfo->out_color_components != RGB_PIXELSIZE)
|
cinfo->out_color_components != RGB_PIXELSIZE ||
|
||||||
|
cinfo->color_transform)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
/* and it only handles 2h1v or 2h2v sampling ratios */
|
/* and it only handles 2h1v or 2h2v sampling ratios */
|
||||||
if (cinfo->comp_info[0].h_samp_factor != 2 ||
|
if (cinfo->comp_info[0].h_samp_factor != 2 ||
|
||||||
@@ -158,9 +171,11 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
|||||||
cinfo->out_color_components = 1;
|
cinfo->out_color_components = 1;
|
||||||
break;
|
break;
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
|
case JCS_BG_RGB:
|
||||||
cinfo->out_color_components = RGB_PIXELSIZE;
|
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||||
break;
|
break;
|
||||||
case JCS_YCbCr:
|
case JCS_YCbCr:
|
||||||
|
case JCS_BG_YCC:
|
||||||
cinfo->out_color_components = 3;
|
cinfo->out_color_components = 3;
|
||||||
break;
|
break;
|
||||||
case JCS_CMYK:
|
case JCS_CMYK:
|
||||||
@@ -196,30 +211,20 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
|||||||
* These processes all use a common table prepared by the routine below.
|
* These processes all use a common table prepared by the routine below.
|
||||||
*
|
*
|
||||||
* For most steps we can mathematically guarantee that the initial value
|
* 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
|
* of x is within 2*(MAXJSAMPLE+1) of the legal range, so a table running
|
||||||
* -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial
|
* from -2*(MAXJSAMPLE+1) to 3*MAXJSAMPLE+2 is sufficient. But for the
|
||||||
* limiting step (just after the IDCT), a wildly out-of-range value is
|
* initial limiting step (just after the IDCT), a wildly out-of-range value
|
||||||
* possible if the input data is corrupt. To avoid any chance of indexing
|
* 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
|
* off the end of memory and getting a bad-pointer trap, we perform the
|
||||||
* post-IDCT limiting thus:
|
* post-IDCT limiting thus:
|
||||||
* x = range_limit[x & MASK];
|
* x = (sample_range_limit - SUBSET)[(x + CENTER) & MASK];
|
||||||
* where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
|
* 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
|
* samples. Under normal circumstances this is more than enough range and
|
||||||
* a correct output will be generated; with bogus input data the mask will
|
* 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.
|
* 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
|
* 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.
|
* representation by adding CENTERJSAMPLE at the same time that we limit it.
|
||||||
* So the post-IDCT limiting table ends up looking like this:
|
* This is accomplished with SUBSET = CENTER - CENTERJSAMPLE.
|
||||||
* 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.
|
|
||||||
*
|
*
|
||||||
* Note that the table is allocated in near data space on PCs; it's small
|
* Note that the table is allocated in near data space on PCs; it's small
|
||||||
* enough and used often enough to justify this.
|
* enough and used often enough to justify this.
|
||||||
@@ -234,23 +239,17 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
table = (JSAMPLE *)
|
table = (JSAMPLE *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
|
5 * (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
|
||||||
table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
|
/* First segment of range limit table: limit[x] = 0 for x < 0 */
|
||||||
|
MEMZERO(table, 2 * (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
|
||||||
|
table += 2 * (MAXJSAMPLE+1); /* allow negative subscripts of table */
|
||||||
cinfo->sample_range_limit = table;
|
cinfo->sample_range_limit = table;
|
||||||
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
|
/* Main part of range limit table: limit[x] = x */
|
||||||
MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
|
|
||||||
/* Main part of "simple" table: limit[x] = x */
|
|
||||||
for (i = 0; i <= MAXJSAMPLE; i++)
|
for (i = 0; i <= MAXJSAMPLE; i++)
|
||||||
table[i] = (JSAMPLE) i;
|
table[i] = (JSAMPLE) i;
|
||||||
table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
|
/* End of range limit table: limit[x] = MAXJSAMPLE for x > MAXJSAMPLE */
|
||||||
/* End of simple table, rest of first half of post-IDCT table */
|
for (; i < 3 * (MAXJSAMPLE+1); i++)
|
||||||
for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
|
|
||||||
table[i] = MAXJSAMPLE;
|
table[i] = MAXJSAMPLE;
|
||||||
/* Second half of post-IDCT table */
|
|
||||||
MEMZERO(table + (2 * (MAXJSAMPLE+1)),
|
|
||||||
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
|
|
||||||
MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
|
|
||||||
cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -273,10 +272,19 @@ master_selection (j_decompress_ptr cinfo)
|
|||||||
long samplesperrow;
|
long samplesperrow;
|
||||||
JDIMENSION jd_samplesperrow;
|
JDIMENSION jd_samplesperrow;
|
||||||
|
|
||||||
|
/* For now, precision must match compiled-in value... */
|
||||||
|
if (cinfo->data_precision != BITS_IN_JSAMPLE)
|
||||||
|
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
|
||||||
|
|
||||||
/* Initialize dimensions and other stuff */
|
/* Initialize dimensions and other stuff */
|
||||||
jpeg_calc_output_dimensions(cinfo);
|
jpeg_calc_output_dimensions(cinfo);
|
||||||
prepare_range_limit_table(cinfo);
|
prepare_range_limit_table(cinfo);
|
||||||
|
|
||||||
|
/* Sanity check on image dimensions */
|
||||||
|
if (cinfo->output_height <= 0 || cinfo->output_width <= 0 ||
|
||||||
|
cinfo->out_color_components <= 0)
|
||||||
|
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||||
|
|
||||||
/* Width of an output scanline must be representable as JDIMENSION. */
|
/* Width of an output scanline must be representable as JDIMENSION. */
|
||||||
samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
|
samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
|
||||||
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||||
@@ -521,7 +529,7 @@ jinit_master_decompress (j_decompress_ptr cinfo)
|
|||||||
master = (my_master_ptr)
|
master = (my_master_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
SIZEOF(my_decomp_master));
|
SIZEOF(my_decomp_master));
|
||||||
cinfo->master = (struct jpeg_decomp_master *) master;
|
cinfo->master = &master->pub;
|
||||||
master->pub.prepare_for_output_pass = prepare_for_output_pass;
|
master->pub.prepare_for_output_pass = prepare_for_output_pass;
|
||||||
master->pub.finish_output_pass = finish_output_pass;
|
master->pub.finish_output_pass = finish_output_pass;
|
||||||
|
|
||||||
|
|||||||
Vendored
+56
-11
@@ -2,6 +2,7 @@
|
|||||||
* jdmerge.c
|
* jdmerge.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
|
* Modified 2013-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
* multiplications needed for color conversion.
|
* multiplications needed for color conversion.
|
||||||
*
|
*
|
||||||
* This file currently provides implementations for the following cases:
|
* This file currently provides implementations for the following cases:
|
||||||
* YCbCr => RGB color conversion only.
|
* YCC => RGB color conversion only (YCbCr or BG_YCC).
|
||||||
* Sampling ratios of 2h1v or 2h2v.
|
* Sampling ratios of 2h1v or 2h2v.
|
||||||
* No scaling needed at upsample time.
|
* No scaling needed at upsample time.
|
||||||
* Corner-aligned (non-CCIR601) sampling alignment.
|
* Corner-aligned (non-CCIR601) sampling alignment.
|
||||||
@@ -75,12 +76,13 @@ typedef my_upsampler * my_upsample_ptr;
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize tables for YCC->RGB colorspace conversion.
|
* Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion.
|
||||||
* This is taken directly from jdcolor.c; see that file for more info.
|
* This is taken directly from jdcolor.c; see that file for more info.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||||
|
/* Normal case, sYCC */
|
||||||
{
|
{
|
||||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||||
int i;
|
int i;
|
||||||
@@ -103,17 +105,57 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
|||||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
/* 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 */
|
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
|
||||||
/* Cr=>R value is nearest int to 1.40200 * x */
|
/* Cr=>R value is nearest int to 1.402 * x */
|
||||||
upsample->Cr_r_tab[i] = (int)
|
upsample->Cr_r_tab[i] = (int)
|
||||||
RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
|
RIGHT_SHIFT(FIX(1.402) * x + ONE_HALF, SCALEBITS);
|
||||||
/* Cb=>B value is nearest int to 1.77200 * x */
|
/* Cb=>B value is nearest int to 1.772 * x */
|
||||||
upsample->Cb_b_tab[i] = (int)
|
upsample->Cb_b_tab[i] = (int)
|
||||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
RIGHT_SHIFT(FIX(1.772) * x + ONE_HALF, SCALEBITS);
|
||||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
/* Cr=>G value is scaled-up -0.714136286 * x */
|
||||||
upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
upsample->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
|
||||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
/* Cb=>G value is scaled-up -0.344136286 * x */
|
||||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
/* 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;
|
upsample->Cb_g_tab[i] = (- FIX(0.344136286)) * x + ONE_HALF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL(void)
|
||||||
|
build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||||
|
/* Wide gamut case, bg-sYCC */
|
||||||
|
{
|
||||||
|
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||||
|
int i;
|
||||||
|
INT32 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 = (INT32 *)
|
||||||
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||||
|
upsample->Cb_g_tab = (INT32 *)
|
||||||
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
(MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||||
|
|
||||||
|
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 2.804 * x */
|
||||||
|
upsample->Cr_r_tab[i] = (int)
|
||||||
|
RIGHT_SHIFT(FIX(2.804) * x + ONE_HALF, SCALEBITS);
|
||||||
|
/* Cb=>B value is nearest int to 3.544 * x */
|
||||||
|
upsample->Cb_b_tab[i] = (int)
|
||||||
|
RIGHT_SHIFT(FIX(3.544) * x + ONE_HALF, SCALEBITS);
|
||||||
|
/* Cr=>G value is scaled-up -1.428272572 * x */
|
||||||
|
upsample->Cr_g_tab[i] = (- FIX(1.428272572)) * x;
|
||||||
|
/* Cb=>G value is scaled-up -0.688272572 * x */
|
||||||
|
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||||
|
upsample->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +416,7 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
|||||||
upsample = (my_upsample_ptr)
|
upsample = (my_upsample_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
SIZEOF(my_upsampler));
|
SIZEOF(my_upsampler));
|
||||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
cinfo->upsample = &upsample->pub;
|
||||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||||
upsample->pub.need_context_rows = FALSE;
|
upsample->pub.need_context_rows = FALSE;
|
||||||
|
|
||||||
@@ -394,6 +436,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
|||||||
upsample->spare_row = NULL;
|
upsample->spare_row = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cinfo->jpeg_color_space == JCS_BG_YCC)
|
||||||
|
build_bg_ycc_rgb_table(cinfo);
|
||||||
|
else
|
||||||
build_ycc_rgb_table(cinfo);
|
build_ycc_rgb_table(cinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+8
-11
@@ -2,7 +2,7 @@
|
|||||||
* jdsample.c
|
* jdsample.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* Modified 2002-2008 by Guido Vollbeding.
|
* Modified 2002-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -296,13 +296,12 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
|||||||
my_upsample_ptr upsample;
|
my_upsample_ptr upsample;
|
||||||
int ci;
|
int ci;
|
||||||
jpeg_component_info * compptr;
|
jpeg_component_info * compptr;
|
||||||
boolean need_buffer;
|
|
||||||
int h_in_group, v_in_group, h_out_group, v_out_group;
|
int h_in_group, v_in_group, h_out_group, v_out_group;
|
||||||
|
|
||||||
upsample = (my_upsample_ptr)
|
upsample = (my_upsample_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
SIZEOF(my_upsampler));
|
SIZEOF(my_upsampler));
|
||||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
cinfo->upsample = &upsample->pub;
|
||||||
upsample->pub.start_pass = start_pass_upsample;
|
upsample->pub.start_pass = start_pass_upsample;
|
||||||
upsample->pub.upsample = sep_upsample;
|
upsample->pub.upsample = sep_upsample;
|
||||||
upsample->pub.need_context_rows = FALSE; /* until we find out differently */
|
upsample->pub.need_context_rows = FALSE; /* until we find out differently */
|
||||||
@@ -325,17 +324,17 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
|||||||
h_out_group = cinfo->max_h_samp_factor;
|
h_out_group = cinfo->max_h_samp_factor;
|
||||||
v_out_group = cinfo->max_v_samp_factor;
|
v_out_group = cinfo->max_v_samp_factor;
|
||||||
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
|
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
|
||||||
need_buffer = TRUE;
|
|
||||||
if (! compptr->component_needed) {
|
if (! compptr->component_needed) {
|
||||||
/* Don't bother to upsample an uninteresting component. */
|
/* Don't bother to upsample an uninteresting component. */
|
||||||
upsample->methods[ci] = noop_upsample;
|
upsample->methods[ci] = noop_upsample;
|
||||||
need_buffer = FALSE;
|
continue; /* don't need to allocate buffer */
|
||||||
} else if (h_in_group == h_out_group && v_in_group == v_out_group) {
|
}
|
||||||
|
if (h_in_group == h_out_group && v_in_group == v_out_group) {
|
||||||
/* Fullsize components can be processed without any work. */
|
/* Fullsize components can be processed without any work. */
|
||||||
upsample->methods[ci] = fullsize_upsample;
|
upsample->methods[ci] = fullsize_upsample;
|
||||||
need_buffer = FALSE;
|
continue; /* don't need to allocate buffer */
|
||||||
} else if (h_in_group * 2 == h_out_group &&
|
}
|
||||||
v_in_group == v_out_group) {
|
if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
|
||||||
/* Special case for 2h1v upsampling */
|
/* Special case for 2h1v upsampling */
|
||||||
upsample->methods[ci] = h2v1_upsample;
|
upsample->methods[ci] = h2v1_upsample;
|
||||||
} else if (h_in_group * 2 == h_out_group &&
|
} else if (h_in_group * 2 == h_out_group &&
|
||||||
@@ -350,7 +349,6 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
|||||||
upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
|
upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
|
||||||
} else
|
} else
|
||||||
ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
|
ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
|
||||||
if (need_buffer) {
|
|
||||||
upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
|
upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
|
||||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
(JDIMENSION) jround_up((long) cinfo->output_width,
|
(JDIMENSION) jround_up((long) cinfo->output_width,
|
||||||
@@ -358,4 +356,3 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
|||||||
(JDIMENSION) cinfo->max_v_samp_factor);
|
(JDIMENSION) cinfo->max_v_samp_factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Vendored
+5
-5
@@ -2,7 +2,7 @@
|
|||||||
* jerror.c
|
* jerror.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2012 by Guido Vollbeding.
|
* Modified 2012-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -19,16 +19,16 @@
|
|||||||
* These routines are used by both the compression and decompression code.
|
* These routines are used by both the compression and decompression code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef USE_WINDOWS_MESSAGEBOX
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
|
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
|
||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jversion.h"
|
#include "jversion.h"
|
||||||
#include "jerror.h"
|
#include "jerror.h"
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_MESSAGEBOX
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
|
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
|
||||||
#define EXIT_FAILURE 1
|
#define EXIT_FAILURE 1
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Vendored
+4
-2
@@ -2,7 +2,7 @@
|
|||||||
* jfdctflt.c
|
* jfdctflt.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2003-2009 by Guido Vollbeding.
|
* Modified 2003-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -54,6 +54,8 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform the forward DCT on one block of samples.
|
* Perform the forward DCT on one block of samples.
|
||||||
|
*
|
||||||
|
* cK represents cos(K*pi/16).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
@@ -89,7 +91,7 @@ jpeg_fdct_float (FAST_FLOAT * data, JSAMPARRAY sample_data, JDIMENSION start_col
|
|||||||
tmp11 = tmp1 + tmp2;
|
tmp11 = tmp1 + tmp2;
|
||||||
tmp12 = tmp1 - tmp2;
|
tmp12 = tmp1 - tmp2;
|
||||||
|
|
||||||
/* Apply unsigned->signed conversion */
|
/* Apply unsigned->signed conversion. */
|
||||||
dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */
|
dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */
|
||||||
dataptr[4] = tmp10 - tmp11;
|
dataptr[4] = tmp10 - tmp11;
|
||||||
|
|
||||||
|
|||||||
Vendored
+4
-2
@@ -2,7 +2,7 @@
|
|||||||
* jfdctfst.c
|
* jfdctfst.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2003-2009 by Guido Vollbeding.
|
* Modified 2003-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -109,6 +109,8 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform the forward DCT on one block of samples.
|
* Perform the forward DCT on one block of samples.
|
||||||
|
*
|
||||||
|
* cK represents cos(K*pi/16).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
@@ -145,7 +147,7 @@ jpeg_fdct_ifast (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
|
|||||||
tmp11 = tmp1 + tmp2;
|
tmp11 = tmp1 + tmp2;
|
||||||
tmp12 = tmp1 - tmp2;
|
tmp12 = tmp1 - tmp2;
|
||||||
|
|
||||||
/* Apply unsigned->signed conversion */
|
/* Apply unsigned->signed conversion. */
|
||||||
dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */
|
dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */
|
||||||
dataptr[4] = tmp10 - tmp11;
|
dataptr[4] = tmp10 - tmp11;
|
||||||
|
|
||||||
|
|||||||
Vendored
+369
-308
File diff suppressed because it is too large
Load Diff
Vendored
+19
-16
@@ -2,7 +2,7 @@
|
|||||||
* jidctflt.c
|
* jidctflt.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||||
* Modified 2010 by Guido Vollbeding.
|
* Modified 2010-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -63,6 +63,8 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform dequantization and inverse DCT on one block of coefficients.
|
* Perform dequantization and inverse DCT on one block of coefficients.
|
||||||
|
*
|
||||||
|
* cK represents cos(K*pi/16).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
@@ -77,7 +79,7 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
FLOAT_MULT_TYPE * quantptr;
|
FLOAT_MULT_TYPE * quantptr;
|
||||||
FAST_FLOAT * wsptr;
|
FAST_FLOAT * wsptr;
|
||||||
JSAMPROW outptr;
|
JSAMPROW outptr;
|
||||||
JSAMPLE *range_limit = cinfo->sample_range_limit;
|
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
|
||||||
int ctr;
|
int ctr;
|
||||||
FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
|
FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
|
||||||
|
|
||||||
@@ -186,13 +188,14 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
|
|
||||||
/* Even part */
|
/* Even part */
|
||||||
|
|
||||||
/* Apply signed->unsigned and prepare float->int conversion */
|
/* Prepare range-limit and float->int conversion */
|
||||||
z5 = wsptr[0] + ((FAST_FLOAT) CENTERJSAMPLE + (FAST_FLOAT) 0.5);
|
z5 = wsptr[0] + (((FAST_FLOAT) RANGE_CENTER) + ((FAST_FLOAT) 0.5));
|
||||||
tmp10 = z5 + wsptr[4];
|
tmp10 = z5 + wsptr[4];
|
||||||
tmp11 = z5 - wsptr[4];
|
tmp11 = z5 - wsptr[4];
|
||||||
|
|
||||||
tmp13 = wsptr[2] + wsptr[6];
|
tmp13 = wsptr[2] + wsptr[6];
|
||||||
tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13;
|
tmp12 = (wsptr[2] - wsptr[6]) *
|
||||||
|
((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */
|
||||||
|
|
||||||
tmp0 = tmp10 + tmp13;
|
tmp0 = tmp10 + tmp13;
|
||||||
tmp3 = tmp10 - tmp13;
|
tmp3 = tmp10 - tmp13;
|
||||||
@@ -206,27 +209,27 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
z11 = wsptr[1] + wsptr[7];
|
z11 = wsptr[1] + wsptr[7];
|
||||||
z12 = wsptr[1] - wsptr[7];
|
z12 = wsptr[1] - wsptr[7];
|
||||||
|
|
||||||
tmp7 = z11 + z13;
|
tmp7 = z11 + z13; /* phase 5 */
|
||||||
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562);
|
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
|
||||||
|
|
||||||
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
|
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
|
||||||
tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
|
tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
|
||||||
tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
|
tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
|
||||||
|
|
||||||
tmp6 = tmp12 - tmp7;
|
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||||
tmp5 = tmp11 - tmp6;
|
tmp5 = tmp11 - tmp6;
|
||||||
tmp4 = tmp10 - tmp5;
|
tmp4 = tmp10 - tmp5;
|
||||||
|
|
||||||
/* Final output stage: float->int conversion and range-limit */
|
/* Final output stage: float->int conversion and range-limit */
|
||||||
|
|
||||||
outptr[0] = range_limit[((int) (tmp0 + tmp7)) & RANGE_MASK];
|
outptr[0] = range_limit[(int) (tmp0 + tmp7) & RANGE_MASK];
|
||||||
outptr[7] = 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[1] = range_limit[(int) (tmp1 + tmp6) & RANGE_MASK];
|
||||||
outptr[6] = 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[2] = range_limit[(int) (tmp2 + tmp5) & RANGE_MASK];
|
||||||
outptr[5] = 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[3] = range_limit[(int) (tmp3 + tmp4) & RANGE_MASK];
|
||||||
outptr[4] = range_limit[((int) (tmp3 - tmp4)) & RANGE_MASK];
|
outptr[4] = range_limit[(int) (tmp3 - tmp4) & RANGE_MASK];
|
||||||
|
|
||||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+36
-53
@@ -2,6 +2,7 @@
|
|||||||
* jidctfst.c
|
* jidctfst.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||||
|
* Modified 2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -133,35 +134,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Like DESCALE, but applies to a DCTELEM and produces an int.
|
|
||||||
* We assume that int right shift is unsigned if INT32 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.
|
* Perform dequantization and inverse DCT on one block of coefficients.
|
||||||
|
*
|
||||||
|
* cK represents cos(K*pi/16).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
@@ -180,7 +156,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
int ctr;
|
int ctr;
|
||||||
int workspace[DCTSIZE2]; /* buffers data between passes */
|
int workspace[DCTSIZE2]; /* buffers data between passes */
|
||||||
SHIFT_TEMPS /* for DESCALE */
|
SHIFT_TEMPS /* for DESCALE */
|
||||||
ISHIFT_TEMPS /* for IDESCALE */
|
ISHIFT_TEMPS /* for IRIGHT_SHIFT */
|
||||||
|
|
||||||
/* Pass 1: process columns from input, store into work array. */
|
/* Pass 1: process columns from input, store into work array. */
|
||||||
|
|
||||||
@@ -253,12 +229,12 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
|
tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
|
||||||
|
|
||||||
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
||||||
tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
|
tmp10 = z5 - MULTIPLY(z12, FIX_1_082392200); /* 2*(c2-c6) */
|
||||||
tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
tmp12 = z5 - MULTIPLY(z10, FIX_2_613125930); /* 2*(c2+c6) */
|
||||||
|
|
||||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||||
tmp5 = tmp11 - tmp6;
|
tmp5 = tmp11 - tmp6;
|
||||||
tmp4 = tmp10 + tmp5;
|
tmp4 = tmp10 - tmp5;
|
||||||
|
|
||||||
wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);
|
wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);
|
||||||
wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);
|
wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);
|
||||||
@@ -266,21 +242,28 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);
|
wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);
|
||||||
wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);
|
wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);
|
||||||
wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);
|
wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);
|
||||||
wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4);
|
wsptr[DCTSIZE*3] = (int) (tmp3 + tmp4);
|
||||||
wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4);
|
wsptr[DCTSIZE*4] = (int) (tmp3 - tmp4);
|
||||||
|
|
||||||
inptr++; /* advance pointers to next column */
|
inptr++; /* advance pointers to next column */
|
||||||
quantptr++;
|
quantptr++;
|
||||||
wsptr++;
|
wsptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass 2: process rows from work array, store into output array. */
|
/* 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, */
|
* Note that we must descale the results by a factor of 8 == 2**3,
|
||||||
/* and also undo the PASS1_BITS scaling. */
|
* and also undo the PASS1_BITS scaling.
|
||||||
|
*/
|
||||||
|
|
||||||
wsptr = workspace;
|
wsptr = workspace;
|
||||||
for (ctr = 0; ctr < DCTSIZE; ctr++) {
|
for (ctr = 0; ctr < DCTSIZE; ctr++) {
|
||||||
outptr = output_buf[ctr] + output_col;
|
outptr = output_buf[ctr] + output_col;
|
||||||
|
|
||||||
|
/* Add range center and fudge factor for final descale and range-limit. */
|
||||||
|
z5 = (DCTELEM) wsptr[0] +
|
||||||
|
((((DCTELEM) RANGE_CENTER) << (PASS1_BITS+3)) +
|
||||||
|
(1 << (PASS1_BITS+2)));
|
||||||
|
|
||||||
/* Rows of zeroes can be exploited in the same way as we did with columns.
|
/* 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
|
* However, the column calculation has created many nonzero AC terms, so
|
||||||
* the simplification applies less often (typically 5% to 10% of the time).
|
* the simplification applies less often (typically 5% to 10% of the time).
|
||||||
@@ -293,7 +276,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
|
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
|
||||||
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
|
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
|
||||||
/* AC terms all zero */
|
/* AC terms all zero */
|
||||||
JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)
|
JSAMPLE dcval = range_limit[(int) IRIGHT_SHIFT(z5, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
|
|
||||||
outptr[0] = dcval;
|
outptr[0] = dcval;
|
||||||
@@ -312,12 +295,12 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
|
|
||||||
/* Even part */
|
/* Even part */
|
||||||
|
|
||||||
tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
|
tmp10 = z5 + (DCTELEM) wsptr[4];
|
||||||
tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);
|
tmp11 = z5 - (DCTELEM) wsptr[4];
|
||||||
|
|
||||||
tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
|
tmp13 = (DCTELEM) wsptr[2] + (DCTELEM) wsptr[6];
|
||||||
tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562)
|
tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6],
|
||||||
- tmp13;
|
FIX_1_414213562) - tmp13; /* 2*c4 */
|
||||||
|
|
||||||
tmp0 = tmp10 + tmp13;
|
tmp0 = tmp10 + tmp13;
|
||||||
tmp3 = tmp10 - tmp13;
|
tmp3 = tmp10 - tmp13;
|
||||||
@@ -335,30 +318,30 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
|
tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
|
||||||
|
|
||||||
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
|
||||||
tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
|
tmp10 = z5 - MULTIPLY(z12, FIX_1_082392200); /* 2*(c2-c6) */
|
||||||
tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
|
tmp12 = z5 - MULTIPLY(z10, FIX_2_613125930); /* 2*(c2+c6) */
|
||||||
|
|
||||||
tmp6 = tmp12 - tmp7; /* phase 2 */
|
tmp6 = tmp12 - tmp7; /* phase 2 */
|
||||||
tmp5 = tmp11 - tmp6;
|
tmp5 = tmp11 - tmp6;
|
||||||
tmp4 = tmp10 + tmp5;
|
tmp4 = tmp10 - tmp5;
|
||||||
|
|
||||||
/* Final output stage: scale down by a factor of 8 and range-limit */
|
/* Final output stage: scale down by a factor of 8 and range-limit */
|
||||||
|
|
||||||
outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
|
outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp7, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
|
outptr[7] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp7, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
|
outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp1 + tmp6, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
|
outptr[6] = range_limit[(int) IRIGHT_SHIFT(tmp1 - tmp6, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
|
outptr[2] = range_limit[(int) IRIGHT_SHIFT(tmp2 + tmp5, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
|
outptr[5] = range_limit[(int) IRIGHT_SHIFT(tmp2 - tmp5, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
|
outptr[3] = range_limit[(int) IRIGHT_SHIFT(tmp3 + tmp4, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
|
outptr[4] = range_limit[(int) IRIGHT_SHIFT(tmp3 - tmp4, PASS1_BITS+3)
|
||||||
& RANGE_MASK];
|
& RANGE_MASK];
|
||||||
|
|
||||||
wsptr += DCTSIZE; /* advance pointer to next row */
|
wsptr += DCTSIZE; /* advance pointer to next row */
|
||||||
|
|||||||
Vendored
+312
-210
File diff suppressed because it is too large
Load Diff
Vendored
+68
-12
@@ -2,7 +2,7 @@
|
|||||||
* jmorecfg.h
|
* jmorecfg.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 1997-2012 by Guido Vollbeding.
|
* Modified 1997-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -15,13 +15,22 @@
|
|||||||
/*
|
/*
|
||||||
* Define BITS_IN_JSAMPLE as either
|
* Define BITS_IN_JSAMPLE as either
|
||||||
* 8 for 8-bit sample values (the usual setting)
|
* 8 for 8-bit sample values (the usual setting)
|
||||||
|
* 9 for 9-bit sample values
|
||||||
|
* 10 for 10-bit sample values
|
||||||
|
* 11 for 11-bit sample values
|
||||||
* 12 for 12-bit sample values
|
* 12 for 12-bit sample values
|
||||||
* Only 8 and 12 are legal data precisions for lossy JPEG according to the
|
* Only 8, 9, 10, 11, and 12 bits sample data precision are supported for
|
||||||
* JPEG standard, and the IJG code does not support anything else!
|
* full-feature DCT processing. Further depths up to 16-bit may be added
|
||||||
* We do not support run-time selection of data precision, sorry.
|
* later for the lossless modes of operation.
|
||||||
|
* Run-time selection and conversion of data precision will be added later
|
||||||
|
* and are currently not supported, sorry.
|
||||||
|
* Exception: The transcoding part (jpegtran) supports all settings in a
|
||||||
|
* single instance, since it operates on the level of DCT coefficients and
|
||||||
|
* not sample values. The DCT coefficients are of the same type (16 bits)
|
||||||
|
* in all cases (see below).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
|
#define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -77,6 +86,48 @@ typedef char JSAMPLE;
|
|||||||
#endif /* BITS_IN_JSAMPLE == 8 */
|
#endif /* BITS_IN_JSAMPLE == 8 */
|
||||||
|
|
||||||
|
|
||||||
|
#if BITS_IN_JSAMPLE == 9
|
||||||
|
/* JSAMPLE should be the smallest type that will hold the values 0..511.
|
||||||
|
* On nearly all machines "short" will do nicely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef short JSAMPLE;
|
||||||
|
#define GETJSAMPLE(value) ((int) (value))
|
||||||
|
|
||||||
|
#define MAXJSAMPLE 511
|
||||||
|
#define CENTERJSAMPLE 256
|
||||||
|
|
||||||
|
#endif /* BITS_IN_JSAMPLE == 9 */
|
||||||
|
|
||||||
|
|
||||||
|
#if BITS_IN_JSAMPLE == 10
|
||||||
|
/* JSAMPLE should be the smallest type that will hold the values 0..1023.
|
||||||
|
* On nearly all machines "short" will do nicely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef short JSAMPLE;
|
||||||
|
#define GETJSAMPLE(value) ((int) (value))
|
||||||
|
|
||||||
|
#define MAXJSAMPLE 1023
|
||||||
|
#define CENTERJSAMPLE 512
|
||||||
|
|
||||||
|
#endif /* BITS_IN_JSAMPLE == 10 */
|
||||||
|
|
||||||
|
|
||||||
|
#if BITS_IN_JSAMPLE == 11
|
||||||
|
/* JSAMPLE should be the smallest type that will hold the values 0..2047.
|
||||||
|
* On nearly all machines "short" will do nicely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef short JSAMPLE;
|
||||||
|
#define GETJSAMPLE(value) ((int) (value))
|
||||||
|
|
||||||
|
#define MAXJSAMPLE 2047
|
||||||
|
#define CENTERJSAMPLE 1024
|
||||||
|
|
||||||
|
#endif /* BITS_IN_JSAMPLE == 11 */
|
||||||
|
|
||||||
|
|
||||||
#if BITS_IN_JSAMPLE == 12
|
#if BITS_IN_JSAMPLE == 12
|
||||||
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
|
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
|
||||||
* On nearly all machines "short" will do nicely.
|
* On nearly all machines "short" will do nicely.
|
||||||
@@ -252,7 +303,10 @@ typedef void noreturn_t;
|
|||||||
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
|
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_BOOLEAN
|
#ifndef HAVE_BOOLEAN
|
||||||
|
#if defined FALSE || defined TRUE || defined QGLOBAL_H
|
||||||
|
/* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */
|
||||||
|
typedef int boolean;
|
||||||
#ifndef FALSE /* in case these macros already exist */
|
#ifndef FALSE /* in case these macros already exist */
|
||||||
#define FALSE 0 /* values of boolean */
|
#define FALSE 0 /* values of boolean */
|
||||||
#endif
|
#endif
|
||||||
@@ -262,6 +316,7 @@ typedef void noreturn_t;
|
|||||||
#else
|
#else
|
||||||
typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -299,11 +354,12 @@ typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
|||||||
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
||||||
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
|
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
|
||||||
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
|
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
|
||||||
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
|
/* Note: if you selected more than 8-bit data precision, it is dangerous to
|
||||||
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
|
* turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only
|
||||||
* precision, so jchuff.c normally uses entropy optimization to compute
|
* good for 8-bit precision, so arithmetic coding is recommended for higher
|
||||||
* usable tables for higher precision. If you don't want to do optimization,
|
* precision. The Huffman encoder normally uses entropy optimization to
|
||||||
* you'll have to supply different default Huffman tables.
|
* compute usable tables for higher precision. Otherwise, you'll have to
|
||||||
|
* supply different default Huffman tables.
|
||||||
* The exact same statements apply for progressive JPEG: the default tables
|
* The exact same statements apply for progressive JPEG: the default tables
|
||||||
* don't work for progressive mode. (This may get fixed, however.)
|
* don't work for progressive mode. (This may get fixed, however.)
|
||||||
*/
|
*/
|
||||||
@@ -314,7 +370,7 @@ typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
|||||||
#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
||||||
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
||||||
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
||||||
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
|
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/
|
||||||
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
|
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
|
||||||
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
|
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
|
||||||
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
|
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
|
||||||
|
|||||||
Vendored
+3
-3
@@ -2,7 +2,7 @@
|
|||||||
* jpegint.h
|
* jpegint.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 1997-2011 by Guido Vollbeding.
|
* Modified 1997-2013 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -211,8 +211,8 @@ struct jpeg_marker_reader {
|
|||||||
/* Entropy decoding */
|
/* Entropy decoding */
|
||||||
struct jpeg_entropy_decoder {
|
struct jpeg_entropy_decoder {
|
||||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
||||||
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo,
|
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JBLOCKROW *MCU_data));
|
||||||
JBLOCKROW *MCU_data));
|
JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Inverse DCT (also performs dequantization) */
|
/* Inverse DCT (also performs dequantization) */
|
||||||
|
|||||||
Vendored
+20
-13
@@ -2,7 +2,7 @@
|
|||||||
* jpeglib.h
|
* jpeglib.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2002-2012 by Guido Vollbeding.
|
* Modified 2002-2015 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -39,12 +39,12 @@ extern "C" {
|
|||||||
|
|
||||||
#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
|
#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
|
||||||
#define JPEG_LIB_VERSION_MAJOR 9
|
#define JPEG_LIB_VERSION_MAJOR 9
|
||||||
#define JPEG_LIB_VERSION_MINOR 0
|
#define JPEG_LIB_VERSION_MINOR 2
|
||||||
|
|
||||||
|
|
||||||
/* Various constants determining the sizes of things.
|
/* Various constants determining the sizes of things.
|
||||||
* All of these are specified by the JPEG standard, so don't change them
|
* All of these are specified by the JPEG standard,
|
||||||
* if you want to be compatible.
|
* so don't change them if you want to be compatible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DCTSIZE 8 /* The basic DCT block is 8x8 coefficients */
|
#define DCTSIZE 8 /* The basic DCT block is 8x8 coefficients */
|
||||||
@@ -157,16 +157,21 @@ typedef struct {
|
|||||||
/* The downsampled dimensions are the component's actual, unpadded number
|
/* The downsampled dimensions are the component's actual, unpadded number
|
||||||
* of samples at the main buffer (preprocessing/compression interface);
|
* of samples at the main buffer (preprocessing/compression interface);
|
||||||
* DCT scaling is included, so
|
* DCT scaling is included, so
|
||||||
* downsampled_width = ceil(image_width * Hi/Hmax * DCT_h_scaled_size/DCTSIZE)
|
* downsampled_width =
|
||||||
|
* ceil(image_width * Hi/Hmax * DCT_h_scaled_size/block_size)
|
||||||
* and similarly for height.
|
* and similarly for height.
|
||||||
*/
|
*/
|
||||||
JDIMENSION downsampled_width; /* actual width in samples */
|
JDIMENSION downsampled_width; /* actual width in samples */
|
||||||
JDIMENSION downsampled_height; /* actual height in samples */
|
JDIMENSION downsampled_height; /* actual height in samples */
|
||||||
/* This flag is used only for decompression. In cases where some of the
|
/* For decompression, in cases where some of the components will be
|
||||||
* components will be ignored (eg grayscale output from YCbCr image),
|
* ignored (eg grayscale output from YCbCr image), we can skip most
|
||||||
* we can skip most computations for the unused components.
|
* computations for the unused components.
|
||||||
|
* For compression, some of the components will need further quantization
|
||||||
|
* scale by factor of 2 after DCT (eg BG_YCC output from normal RGB input).
|
||||||
|
* The field is first set TRUE for decompression, FALSE for compression
|
||||||
|
* in initial_setup, and then adapted in color conversion setup.
|
||||||
*/
|
*/
|
||||||
boolean component_needed; /* do we need the value of this component? */
|
boolean component_needed;
|
||||||
|
|
||||||
/* These values are computed before starting a scan of the component. */
|
/* These values are computed before starting a scan of the component. */
|
||||||
/* The decompressor output side may not use these variables. */
|
/* The decompressor output side may not use these variables. */
|
||||||
@@ -215,10 +220,12 @@ struct jpeg_marker_struct {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
JCS_UNKNOWN, /* error/unspecified */
|
JCS_UNKNOWN, /* error/unspecified */
|
||||||
JCS_GRAYSCALE, /* monochrome */
|
JCS_GRAYSCALE, /* monochrome */
|
||||||
JCS_RGB, /* red/green/blue */
|
JCS_RGB, /* red/green/blue, standard RGB (sRGB) */
|
||||||
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */
|
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV), standard YCC */
|
||||||
JCS_CMYK, /* C/M/Y/K */
|
JCS_CMYK, /* C/M/Y/K */
|
||||||
JCS_YCCK /* Y/Cb/Cr/K */
|
JCS_YCCK, /* Y/Cb/Cr/K */
|
||||||
|
JCS_BG_RGB, /* big gamut red/green/blue, bg-sRGB */
|
||||||
|
JCS_BG_YCC /* big gamut Y/Cb/Cr, bg-sYCC */
|
||||||
} J_COLOR_SPACE;
|
} J_COLOR_SPACE;
|
||||||
|
|
||||||
/* Supported color transforms. */
|
/* Supported color transforms. */
|
||||||
@@ -972,7 +979,7 @@ EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
|
|||||||
unsigned char ** outbuffer,
|
unsigned char ** outbuffer,
|
||||||
unsigned long * outsize));
|
unsigned long * outsize));
|
||||||
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
|
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
|
||||||
unsigned char * inbuffer,
|
const unsigned char * inbuffer,
|
||||||
unsigned long insize));
|
unsigned long insize));
|
||||||
|
|
||||||
/* Default parameter setup for compression */
|
/* Default parameter setup for compression */
|
||||||
|
|||||||
Vendored
+3
-3
@@ -265,9 +265,9 @@ typedef struct {
|
|||||||
INT32 volume;
|
INT32 volume;
|
||||||
/* The number of nonzero histogram cells within this box */
|
/* The number of nonzero histogram cells within this box */
|
||||||
long colorcount;
|
long colorcount;
|
||||||
} _box;
|
} box;
|
||||||
|
|
||||||
typedef _box * boxptr;
|
typedef box * boxptr;
|
||||||
|
|
||||||
|
|
||||||
LOCAL(boxptr)
|
LOCAL(boxptr)
|
||||||
@@ -546,7 +546,7 @@ select_colors (j_decompress_ptr cinfo, int desired_colors)
|
|||||||
|
|
||||||
/* Allocate workspace for box list */
|
/* Allocate workspace for box list */
|
||||||
boxlist = (boxptr) (*cinfo->mem->alloc_small)
|
boxlist = (boxptr) (*cinfo->mem->alloc_small)
|
||||||
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(_box));
|
((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box));
|
||||||
/* Initialize one box containing whole space */
|
/* Initialize one box containing whole space */
|
||||||
numboxes = 1;
|
numboxes = 1;
|
||||||
boxlist[0].c0min = 0;
|
boxlist[0].c0min = 0;
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jversion.h
|
* jversion.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1991-2016, Thomas G. Lane, Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@@ -9,6 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define JVERSION "9 13-Jan-2013"
|
#define JVERSION "9b 17-Jan-2016"
|
||||||
|
|
||||||
#define JCOPYRIGHT "Copyright (C) 2013, Thomas G. Lane, Guido Vollbeding"
|
#define JCOPYRIGHT "Copyright (C) 2016, Thomas G. Lane, Guido Vollbeding"
|
||||||
|
|||||||
Vendored
+367
-1
@@ -833,7 +833,7 @@ Version 1.0.7beta11 [May 7, 2000]
|
|||||||
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
|
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
|
||||||
which are no longer used.
|
which are no longer used.
|
||||||
Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is
|
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
|
defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXt_SUPPORTED
|
||||||
is defined.
|
is defined.
|
||||||
Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory
|
Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory
|
||||||
overrun when old applications fill the info_ptr->text structure directly.
|
overrun when old applications fill the info_ptr->text structure directly.
|
||||||
@@ -5675,6 +5675,372 @@ Version 1.6.24rc03 [August 2, 2016]
|
|||||||
Version 1.6.24[August 4, 2016]
|
Version 1.6.24[August 4, 2016]
|
||||||
No changes.
|
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 accomodate
|
||||||
|
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 compatability.
|
||||||
|
|
||||||
|
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 these were incorrect and caused
|
||||||
|
test failures.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||||
|
|||||||
Vendored
+11
-8
@@ -37,12 +37,21 @@ if(ARM OR AARCH64)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_SSE
|
if(";${CPU_BASELINE_FINAL};" MATCHES "SSE2"
|
||||||
AND (NOT MSVC OR (MSVC_VERSION GREATER 1799))) # MSVS2013+ (issue #7232)
|
AND (NOT MSVC OR (MSVC_VERSION GREATER 1799))) # MSVS2013+ (issue #7232)
|
||||||
list(APPEND lib_srcs contrib/intel/intel_init.c contrib/intel/filter_sse2_intrinsics.c)
|
list(APPEND lib_srcs intel/intel_init.c intel/filter_sse2_intrinsics.c)
|
||||||
add_definitions(-DPNG_INTEL_SSE)
|
add_definitions(-DPNG_INTEL_SSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(PPC64LE OR PPC64)
|
||||||
|
if(ENABLE_VSX AND NOT PPC64)
|
||||||
|
list(APPEND lib_srcs powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c)
|
||||||
|
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
|
||||||
|
else()
|
||||||
|
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------
|
||||||
# Define the library target:
|
# Define the library target:
|
||||||
# ----------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------
|
||||||
@@ -54,12 +63,6 @@ endif(MSVC)
|
|||||||
add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||||
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES})
|
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES})
|
||||||
|
|
||||||
if(UNIX)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align)
|
ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align)
|
||||||
|
|
||||||
set_target_properties(${PNG_LIBRARY}
|
set_target_properties(${PNG_LIBRARY}
|
||||||
|
|||||||
Vendored
+6
-3
@@ -10,8 +10,8 @@ this sentence.
|
|||||||
|
|
||||||
This code is released under the libpng license.
|
This code is released under the libpng license.
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000 through 1.6.24, August 4, 2016 are
|
libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are
|
||||||
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||||
derived from libpng-1.0.6, and are distributed according to the same
|
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
|
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
added to the list of Contributing Authors:
|
added to the list of Contributing Authors:
|
||||||
@@ -22,6 +22,9 @@ added to the list of Contributing Authors:
|
|||||||
Cosmin Truta
|
Cosmin Truta
|
||||||
Gilles Vollant
|
Gilles Vollant
|
||||||
James Yu
|
James Yu
|
||||||
|
Mandar Sahastrabuddhe
|
||||||
|
Google Inc.
|
||||||
|
Vadim Barkov
|
||||||
|
|
||||||
and with the following additions to the disclaimer:
|
and with the following additions to the disclaimer:
|
||||||
|
|
||||||
@@ -127,4 +130,4 @@ any encryption software. See the EAR, paragraphs 734.3(b)(3) and
|
|||||||
|
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
glennrp at users.sourceforge.net
|
glennrp at users.sourceforge.net
|
||||||
August 4, 2016
|
September 29, 2017
|
||||||
|
|||||||
Vendored
+13
-6
@@ -1,4 +1,4 @@
|
|||||||
README for libpng version 1.6.24 - August 4, 2016 (shared library 16.0)
|
README for libpng version 1.6.34 - September 29, 2017 (shared library 16.0)
|
||||||
See the note about version numbers near the top of png.h
|
See the note about version numbers near the top of png.h
|
||||||
|
|
||||||
See INSTALL for instructions on how to install libpng.
|
See INSTALL for instructions on how to install libpng.
|
||||||
@@ -23,7 +23,7 @@ earlier versions if you are using a shared library. The type of the
|
|||||||
png_uint_32, which will affect shared-library applications that use
|
png_uint_32, which will affect shared-library applications that use
|
||||||
this function.
|
this function.
|
||||||
|
|
||||||
To avoid problems with changes to the internals of png info_struct,
|
To avoid problems with changes to the internals of the png info_struct,
|
||||||
new APIs have been made available in 0.95 to avoid direct application
|
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
|
access to info_ptr. These functions are the png_set_<chunk> and
|
||||||
png_get_<chunk> functions. These functions should be used when
|
png_get_<chunk> functions. These functions should be used when
|
||||||
@@ -88,11 +88,11 @@ zlib should be available at the same place that libpng is, or at zlib.net.
|
|||||||
|
|
||||||
You may also want a copy of the PNG specification. It is available
|
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
|
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||||
these at http://www.libpng.org/pub/png/documents/
|
these at http://www.libpng.org/pub/png/pngdocs.html .
|
||||||
|
|
||||||
This code is currently being archived at libpng.sf.net in the
|
This code is currently being archived at libpng.sourceforge.io in the
|
||||||
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
|
[DOWNLOAD] area, and at http://libpng.download/src . If you
|
||||||
in any of those places, e-mail me, and I'll help you find it.
|
can't find it in any of those places, e-mail me, and I'll help you find it.
|
||||||
|
|
||||||
I am not a lawyer, but I believe that the Export Control Classification
|
I am not a lawyer, but I believe that the Export Control Classification
|
||||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||||
@@ -179,18 +179,25 @@ Files in this distribution:
|
|||||||
pngwtran.c => Write data transformations
|
pngwtran.c => Write data transformations
|
||||||
pngwutil.c => Write utility functions
|
pngwutil.c => Write utility functions
|
||||||
arm => Contains optimized code for the ARM platform
|
arm => Contains optimized code for the ARM platform
|
||||||
|
powerpc => Contains optimized code for the PowerPC platform
|
||||||
contrib => Contributions
|
contrib => Contributions
|
||||||
|
arm-neon => Optimized code for ARM-NEON platform
|
||||||
|
powerpc-vsx => Optimized code for POWERPC-VSX platform
|
||||||
examples => Example programs
|
examples => Example programs
|
||||||
gregbook => source code for PNG reading and writing, from
|
gregbook => source code for PNG reading and writing, from
|
||||||
Greg Roelofs' "PNG: The Definitive Guide",
|
Greg Roelofs' "PNG: The Definitive Guide",
|
||||||
O'Reilly, 1999
|
O'Reilly, 1999
|
||||||
libtests => Test programs
|
libtests => Test programs
|
||||||
|
mips-msa => Optimized code for MIPS-MSA platform
|
||||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||||
programs demonstrating use of pngusr.dfa
|
programs demonstrating use of pngusr.dfa
|
||||||
pngminus => Simple pnm2png and png2pnm programs
|
pngminus => Simple pnm2png and png2pnm programs
|
||||||
pngsuite => Test images
|
pngsuite => Test images
|
||||||
|
testpngs
|
||||||
tools => Various tools
|
tools => Various tools
|
||||||
visupng => Contains a MSVC workspace for VisualPng
|
visupng => Contains a MSVC workspace for VisualPng
|
||||||
|
intel => Optimized code for INTEL-SSE2 platform
|
||||||
|
mips => Optimized code for MIPS platform
|
||||||
projects => Contains project files and workspaces for
|
projects => Contains project files and workspaces for
|
||||||
building a DLL
|
building a DLL
|
||||||
owatcom => Contains a WATCOM project for building libpng
|
owatcom => Contains a WATCOM project for building libpng
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* filter_neon.S - NEON optimised filter functions
|
/* filter_neon.S - NEON optimised filter functions
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
* Copyright (c) 2014,2017 Glenn Randers-Pehrson
|
||||||
* Written by Mans Rullgard, 2011.
|
* Written by Mans Rullgard, 2011.
|
||||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
#define PNG_VERSION_INFO_ONLY
|
#define PNG_VERSION_INFO_ONLY
|
||||||
#include "../pngpriv.h"
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
#if defined(__linux__) && defined(__ELF__)
|
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
|
||||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
-158
@@ -1,158 +0,0 @@
|
|||||||
Enabling SSE support
|
|
||||||
|
|
||||||
Copyright (c) 2016 Google, Inc.
|
|
||||||
Written by Mike Klein, Matt Sarett
|
|
||||||
|
|
||||||
This INSTALL file written by Glenn Randers-Pehrson, 2016.
|
|
||||||
|
|
||||||
If you have moved intel_init.c and filter_sse2_intrinsics.c to a different
|
|
||||||
directory, be sure to update the '#include "../../pngpriv.h"' line in both
|
|
||||||
files if necessary to point to the correct relative location of pngpriv.h
|
|
||||||
with respect to the new location of those files.
|
|
||||||
|
|
||||||
To enable SSE support in libpng, follow the instructions in I, II, or III,
|
|
||||||
below:
|
|
||||||
|
|
||||||
I. Using patched "configure" scripts:
|
|
||||||
|
|
||||||
First, apply intel_sse.patch in your build directory.
|
|
||||||
|
|
||||||
patch -i contrib/intel/intel_sse.patch -p1
|
|
||||||
|
|
||||||
Then, if you are not building in a new GIT clone, e.g., in a tar
|
|
||||||
distribution, remove any existing pre-built configure scripts:
|
|
||||||
|
|
||||||
./configure --enable-maintainer-mode
|
|
||||||
make maintainer-clean
|
|
||||||
./autogen.sh --maintainer --clean
|
|
||||||
|
|
||||||
Finally, configure libpng with -DPNG_INTEL_SSE in CPPFLAGS:
|
|
||||||
|
|
||||||
./autogen.sh --maintainer
|
|
||||||
CPPFLAGS="-DPNG_INTEL_SSE" ./configure [options]
|
|
||||||
make CPPFLAGS="-DPNG_INTEL_SSE" [options]
|
|
||||||
make
|
|
||||||
|
|
||||||
II. Using a custom makefile:
|
|
||||||
|
|
||||||
If you are using a custom makefile makefile, you will have to update it
|
|
||||||
manually to include contrib/intel/*.o in the dependencies, and to define
|
|
||||||
PNG_INTEL_SSE.
|
|
||||||
|
|
||||||
III. Using manually updated "configure" scripts:
|
|
||||||
|
|
||||||
If you prefer, manually edit pngpriv.h, configure.ac, and Makefile.am,
|
|
||||||
following the instructions below, then follow the instructions in
|
|
||||||
section II of INSTALL in the main libpng directory, then configure libpng
|
|
||||||
with -DPNG_INTEL_SSE in CPPFLAGS.
|
|
||||||
|
|
||||||
1. Add the following code to configure.ac under HOST SPECIFIC OPTIONS
|
|
||||||
directly beneath the section for ARM:
|
|
||||||
|
|
||||||
-----------------cut----------------
|
|
||||||
# INTEL
|
|
||||||
# =====
|
|
||||||
#
|
|
||||||
# INTEL SSE (SIMD) support.
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([intel-sse],
|
|
||||||
AS_HELP_STRING([[[--enable-intel-sse]]],
|
|
||||||
[Enable Intel SSE optimizations: =no/off, yes/on:]
|
|
||||||
[no/off: disable the optimizations;]
|
|
||||||
[yes/on: enable the optimizations.]
|
|
||||||
[If not specified: determined by the compiler.]),
|
|
||||||
[case "$enableval" in
|
|
||||||
no|off)
|
|
||||||
# disable the default enabling:
|
|
||||||
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
|
|
||||||
[Disable Intel SSE optimizations])
|
|
||||||
# Prevent inclusion of the assembler files below:
|
|
||||||
enable_intel_sse=no;;
|
|
||||||
yes|on)
|
|
||||||
AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
|
|
||||||
[Enable Intel SSE optimizations]);;
|
|
||||||
*)
|
|
||||||
AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
|
|
||||||
esac])
|
|
||||||
|
|
||||||
# Add Intel specific files to all builds where the host_cpu is Intel ('x86*')
|
|
||||||
# or where Intel optimizations were explicitly requested (this allows a
|
|
||||||
# fallback if a future host CPU does not match 'x86*')
|
|
||||||
AM_CONDITIONAL([PNG_INTEL_SSE],
|
|
||||||
[test "$enable_intel_sse" != 'no' &&
|
|
||||||
case "$host_cpu" in
|
|
||||||
i?86|x86_64) :;;
|
|
||||||
*) test "$enable_intel_sse" != '';;
|
|
||||||
esac])
|
|
||||||
-----------------cut----------------
|
|
||||||
|
|
||||||
2. Add the following code to Makefile.am under HOST SPECIFIC OPTIONS
|
|
||||||
directly beneath the "if PNG_ARM_NEON ... endif" statement:
|
|
||||||
|
|
||||||
-----------------cut----------------
|
|
||||||
if PNG_INTEL_SSE
|
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += contrib/intel/intel_init.c\
|
|
||||||
contrib/intel/filter_sse2_intrinsics.c
|
|
||||||
endif
|
|
||||||
-----------------cut----------------
|
|
||||||
|
|
||||||
3. Add the following lines to pngpriv.h, following the PNG_ARM_NEON_OPT
|
|
||||||
code:
|
|
||||||
|
|
||||||
-----------------cut----------------
|
|
||||||
#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
|
|
||||||
# endif
|
|
||||||
# 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
|
|
||||||
#endif
|
|
||||||
|
|
||||||
-----------------cut----------------
|
|
||||||
|
|
||||||
4. Add the following lines to pngpriv.h, following the prototype for
|
|
||||||
png_read_filter_row_paeth4_neon:
|
|
||||||
|
|
||||||
-----------------cut----------------
|
|
||||||
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);
|
|
||||||
|
|
||||||
-----------------cut----------------
|
|
||||||
-187
@@ -1,187 +0,0 @@
|
|||||||
diff --git a/configure.ac b/configure.ac
|
|
||||||
--- a/configure.ac 2016-05-25 18:59:10.000000000 -0400
|
|
||||||
+++ b/configure.ac 2016-05-25 19:48:10.631751170 -0400
|
|
||||||
@@ -341,16 +341,50 @@ AC_ARG_ENABLE([arm-neon],
|
|
||||||
|
|
||||||
AM_CONDITIONAL([PNG_ARM_NEON],
|
|
||||||
[test "$enable_arm_neon" != 'no' &&
|
|
||||||
case "$host_cpu" in
|
|
||||||
arm*|aarch64*) :;;
|
|
||||||
*) test "$enable_arm_neon" != '';;
|
|
||||||
esac])
|
|
||||||
|
|
||||||
+# INTEL
|
|
||||||
+# =====
|
|
||||||
+#
|
|
||||||
+# INTEL SSE (SIMD) support.
|
|
||||||
+
|
|
||||||
+AC_ARG_ENABLE([intel-sse],
|
|
||||||
+ AS_HELP_STRING([[[--enable-intel-sse]]],
|
|
||||||
+ [Enable Intel SSE optimizations: =no/off, yes/on:]
|
|
||||||
+ [no/off: disable the optimizations;]
|
|
||||||
+ [yes/on: enable the optimizations.]
|
|
||||||
+ [If not specified: determined by the compiler.]),
|
|
||||||
+ [case "$enableval" in
|
|
||||||
+ no|off)
|
|
||||||
+ # disable the default enabling:
|
|
||||||
+ AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
|
|
||||||
+ [Disable Intel SSE optimizations])
|
|
||||||
+ # Prevent inclusion of the assembler files below:
|
|
||||||
+ enable_intel_sse=no;;
|
|
||||||
+ yes|on)
|
|
||||||
+ AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
|
|
||||||
+ [Enable Intel SSE optimizations]);;
|
|
||||||
+ *)
|
|
||||||
+ AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
|
|
||||||
+ esac])
|
|
||||||
+
|
|
||||||
+# Add Intel specific files to all builds where the host_cpu is Intel ('x86*')
|
|
||||||
+# or where Intel optimizations were explicitly requested (this allows a
|
|
||||||
+# fallback if a future host CPU does not match 'x86*')
|
|
||||||
+AM_CONDITIONAL([PNG_INTEL_SSE],
|
|
||||||
+ [test "$enable_intel_sse" != 'no' &&
|
|
||||||
+ case "$host_cpu" in
|
|
||||||
+ i?86|x86_64) :;;
|
|
||||||
+ *) test "$enable_intel_sse" != '';;
|
|
||||||
+ esac])
|
|
||||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
|
||||||
|
|
||||||
# Config files, substituting as above
|
|
||||||
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
|
|
||||||
AC_CONFIG_FILES([libpng-config:libpng-config.in],
|
|
||||||
[chmod +x libpng-config])
|
|
||||||
|
|
||||||
AC_OUTPUT
|
|
||||||
diff --git a/Makefile.am b/Makefile.am
|
|
||||||
--- a/Makefile.am 2016-05-17 18:15:12.000000000 -0400
|
|
||||||
+++ b/Makefile.am 2016-05-25 19:48:10.631751170 -0400
|
|
||||||
@@ -92,16 +92,20 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SO
|
|
||||||
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
|
|
||||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa
|
|
||||||
|
|
||||||
if PNG_ARM_NEON
|
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
|
||||||
arm/filter_neon.S arm/filter_neon_intrinsics.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
+if PNG_INTEL_SSE
|
|
||||||
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += contrib/intel/intel_init.c\
|
|
||||||
+ contrib/intel/filter_sse2_intrinsics.c
|
|
||||||
+endif
|
|
||||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
|
||||||
|
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
|
|
||||||
-version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0
|
|
||||||
|
|
||||||
if HAVE_LD_VERSION_SCRIPT
|
|
||||||
# Versioned symbols and restricted exports
|
|
||||||
if HAVE_SOLARIS_LD
|
|
||||||
diff --git a/pngpriv.h b/pngpriv.h
|
|
||||||
--- a/pngpriv.h 2016-08-01 18:13:38.770128810 -0500
|
|
||||||
+++ b/pngpriv.h 2016-08-01 18:50:19.130179017 -0500
|
|
||||||
@@ -177,16 +177,52 @@
|
|
||||||
# endif /* !PNG_ARM_NEON_IMPLEMENTATION */
|
|
||||||
|
|
||||||
# ifndef PNG_ARM_NEON_IMPLEMENTATION
|
|
||||||
/* Use the intrinsics code by default. */
|
|
||||||
# define PNG_ARM_NEON_IMPLEMENTATION 1
|
|
||||||
# endif
|
|
||||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
|
||||||
|
|
||||||
+#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
|
|
||||||
+# endif
|
|
||||||
+# 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
|
|
||||||
+#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.
|
|
||||||
*/
|
|
||||||
@@ -1185,16 +1221,31 @@ PNG_INTERNAL_FUNCTION(void,png_read_filt
|
|
||||||
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_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
|
|
||||||
|
|
||||||
/* 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);
|
|
||||||
@@ -1914,16 +1965,20 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_O
|
|
||||||
/* 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_INTEL_SSE_IMPLEMENTATION > 0
|
|
||||||
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
|
|
||||||
+ (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
|
||||||
+# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
|
|
||||||
png_const_charp key, png_bytep new_key), PNG_EMPTY);
|
|
||||||
|
|
||||||
/* Maintainer: Put new private prototypes here ^ */
|
|
||||||
|
|
||||||
#include "pngdebug.h"
|
|
||||||
+70
-45
@@ -1,19 +1,18 @@
|
|||||||
|
|
||||||
/* filter_sse2_intrinsics.c - SSE2 optimized filter functions
|
/* filter_sse2_intrinsics.c - SSE2 optimized filter functions
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016 Google, Inc.
|
* Copyright (c) 2016-2017 Glenn Randers-Pehrson
|
||||||
* Written by Mike Klein and Matt Sarett
|
* Written by Mike Klein and Matt Sarett
|
||||||
* Derived from arm/filter_neon_intrinsics.c, which was
|
* Derived from arm/filter_neon_intrinsics.c
|
||||||
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../pngpriv.h"
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ static __m128i load3(const void* p) {
|
|||||||
/* We'll load 2 bytes, then 1 byte,
|
/* We'll load 2 bytes, then 1 byte,
|
||||||
* then mask them together, and finally load into SSE.
|
* then mask them together, and finally load into SSE.
|
||||||
*/
|
*/
|
||||||
const png_uint_16* p01 = p;
|
const png_uint_16* p01 = (png_const_uint_16p)p;
|
||||||
const png_byte* p2 = (const png_byte*)(p01+1);
|
const png_byte* p2 = (const png_byte*)(p01+1);
|
||||||
|
|
||||||
png_uint_32 v012 = (png_uint_32)(*p01)
|
png_uint_32 v012 = (png_uint_32)(*p01)
|
||||||
@@ -54,12 +53,15 @@ static void store3(void* p, __m128i v) {
|
|||||||
* its bottom two bytes, then its third byte.
|
* its bottom two bytes, then its third byte.
|
||||||
*/
|
*/
|
||||||
png_uint_32 v012;
|
png_uint_32 v012;
|
||||||
|
png_uint_16* p01;
|
||||||
|
png_byte* p2;
|
||||||
|
|
||||||
store4(&v012, v);
|
store4(&v012, v);
|
||||||
|
|
||||||
png_uint_16* p01 = p;
|
p01 = (png_uint_16p)p;
|
||||||
png_byte* p2 = (png_byte*)(p01+1);
|
p2 = (png_byte*)(p01+1);
|
||||||
*p01 = v012;
|
*p01 = (png_uint_16)v012;
|
||||||
*p2 = v012 >> 16;
|
*p2 = (png_byte)(v012 >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
|
void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
|
||||||
@@ -69,11 +71,13 @@ void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
* There is no pixel to the left of the first pixel. It's encoded directly.
|
* 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.
|
* That works with our main loop if we just say that left pixel was zero.
|
||||||
*/
|
*/
|
||||||
(void) prev; //unused parameter
|
png_size_t rb;
|
||||||
png_debug(1, "in png_read_filter_row_sub3_sse2");
|
|
||||||
__m128i a, d = _mm_setzero_si128();
|
__m128i a, d = _mm_setzero_si128();
|
||||||
|
|
||||||
png_size_t rb = row_info->rowbytes;
|
png_debug(1, "in png_read_filter_row_sub3_sse2");
|
||||||
|
|
||||||
|
rb = row_info->rowbytes;
|
||||||
while (rb >= 4) {
|
while (rb >= 4) {
|
||||||
a = d; d = load4(row);
|
a = d; d = load4(row);
|
||||||
d = _mm_add_epi8(d, a);
|
d = _mm_add_epi8(d, a);
|
||||||
@@ -90,6 +94,7 @@ void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
row += 3;
|
row += 3;
|
||||||
rb -= 3;
|
rb -= 3;
|
||||||
}
|
}
|
||||||
|
PNG_UNUSED(prev)
|
||||||
}
|
}
|
||||||
|
|
||||||
void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row,
|
void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row,
|
||||||
@@ -99,12 +104,14 @@ void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
* There is no pixel to the left of the first pixel. It's encoded directly.
|
* 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.
|
* That works with our main loop if we just say that left pixel was zero.
|
||||||
*/
|
*/
|
||||||
(void) prev; //unused parameter
|
png_size_t rb;
|
||||||
png_debug(1, "in png_read_filter_row_sub4_sse2");
|
|
||||||
__m128i a, d = _mm_setzero_si128();
|
__m128i a, d = _mm_setzero_si128();
|
||||||
|
|
||||||
png_size_t rb = row_info->rowbytes;
|
png_debug(1, "in png_read_filter_row_sub4_sse2");
|
||||||
while (rb > 0) {
|
|
||||||
|
rb = row_info->rowbytes+4;
|
||||||
|
while (rb > 4) {
|
||||||
a = d; d = load4(row);
|
a = d; d = load4(row);
|
||||||
d = _mm_add_epi8(d, a);
|
d = _mm_add_epi8(d, a);
|
||||||
store4(row, d);
|
store4(row, d);
|
||||||
@@ -112,6 +119,7 @@ void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
row += 4;
|
row += 4;
|
||||||
rb -= 4;
|
rb -= 4;
|
||||||
}
|
}
|
||||||
|
PNG_UNUSED(prev)
|
||||||
}
|
}
|
||||||
|
|
||||||
void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row,
|
void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row,
|
||||||
@@ -122,18 +130,23 @@ void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
* predicted to be half of the pixel above it. So again, this works
|
* 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.
|
* perfectly with our loop if we make sure a starts at zero.
|
||||||
*/
|
*/
|
||||||
png_debug(1, "in png_read_filter_row_avg3_sse2");
|
|
||||||
|
png_size_t rb;
|
||||||
|
|
||||||
const __m128i zero = _mm_setzero_si128();
|
const __m128i zero = _mm_setzero_si128();
|
||||||
|
|
||||||
__m128i b;
|
__m128i b;
|
||||||
__m128i a, d = zero;
|
__m128i a, d = zero;
|
||||||
|
|
||||||
png_size_t rb = row_info->rowbytes;
|
png_debug(1, "in png_read_filter_row_avg3_sse2");
|
||||||
|
rb = row_info->rowbytes;
|
||||||
while (rb >= 4) {
|
while (rb >= 4) {
|
||||||
|
__m128i avg;
|
||||||
b = load4(prev);
|
b = load4(prev);
|
||||||
a = d; d = load4(row );
|
a = d; d = load4(row );
|
||||||
|
|
||||||
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
||||||
__m128i avg = _mm_avg_epu8(a,b);
|
avg = _mm_avg_epu8(a,b);
|
||||||
/* ...but we can fix it up by subtracting off 1 if it rounded up. */
|
/* ...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),
|
avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
|
||||||
_mm_set1_epi8(1)));
|
_mm_set1_epi8(1)));
|
||||||
@@ -145,11 +158,12 @@ void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
rb -= 3;
|
rb -= 3;
|
||||||
}
|
}
|
||||||
if (rb > 0) {
|
if (rb > 0) {
|
||||||
|
__m128i avg;
|
||||||
b = load3(prev);
|
b = load3(prev);
|
||||||
a = d; d = load3(row );
|
a = d; d = load3(row );
|
||||||
|
|
||||||
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
||||||
__m128i avg = _mm_avg_epu8(a,b);
|
avg = _mm_avg_epu8(a,b);
|
||||||
/* ...but we can fix it up by subtracting off 1 if it rounded up. */
|
/* ...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),
|
avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
|
||||||
_mm_set1_epi8(1)));
|
_mm_set1_epi8(1)));
|
||||||
@@ -171,18 +185,21 @@ void png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
* predicted to be half of the pixel above it. So again, this works
|
* 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.
|
* perfectly with our loop if we make sure a starts at zero.
|
||||||
*/
|
*/
|
||||||
png_debug(1, "in png_read_filter_row_avg4_sse2");
|
png_size_t rb;
|
||||||
const __m128i zero = _mm_setzero_si128();
|
const __m128i zero = _mm_setzero_si128();
|
||||||
__m128i b;
|
__m128i b;
|
||||||
__m128i a, d = zero;
|
__m128i a, d = zero;
|
||||||
|
|
||||||
png_size_t rb = row_info->rowbytes;
|
png_debug(1, "in png_read_filter_row_avg4_sse2");
|
||||||
while (rb > 0) {
|
|
||||||
|
rb = row_info->rowbytes+4;
|
||||||
|
while (rb > 4) {
|
||||||
|
__m128i avg;
|
||||||
b = load4(prev);
|
b = load4(prev);
|
||||||
a = d; d = load4(row );
|
a = d; d = load4(row );
|
||||||
|
|
||||||
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
/* PNG requires a truncating average, so we can't just use _mm_avg_epu8 */
|
||||||
__m128i avg = _mm_avg_epu8(a,b);
|
avg = _mm_avg_epu8(a,b);
|
||||||
/* ...but we can fix it up by subtracting off 1 if it rounded up. */
|
/* ...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),
|
avg = _mm_sub_epi8(avg, _mm_and_si128(_mm_xor_si128(a,b),
|
||||||
_mm_set1_epi8(1)));
|
_mm_set1_epi8(1)));
|
||||||
@@ -240,36 +257,40 @@ void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
* Here we zero b and d, which become c and a respectively at the start of
|
* Here we zero b and d, which become c and a respectively at the start of
|
||||||
* the loop.
|
* the loop.
|
||||||
*/
|
*/
|
||||||
png_debug(1, "in png_read_filter_row_paeth3_sse2");
|
png_size_t rb;
|
||||||
const __m128i zero = _mm_setzero_si128();
|
const __m128i zero = _mm_setzero_si128();
|
||||||
__m128i c, b = zero,
|
__m128i c, b = zero,
|
||||||
a, d = zero;
|
a, d = zero;
|
||||||
|
|
||||||
png_size_t rb = row_info->rowbytes;
|
png_debug(1, "in png_read_filter_row_paeth3_sse2");
|
||||||
|
|
||||||
|
rb = row_info->rowbytes;
|
||||||
while (rb >= 4) {
|
while (rb >= 4) {
|
||||||
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
||||||
* intermediates.
|
* intermediates.
|
||||||
*/
|
*/
|
||||||
|
__m128i pa,pb,pc,smallest,nearest;
|
||||||
c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
|
c = b; b = _mm_unpacklo_epi8(load4(prev), zero);
|
||||||
a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
|
a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
|
||||||
|
|
||||||
/* (p-a) == (a+b-c - a) == (b-c) */
|
/* (p-a) == (a+b-c - a) == (b-c) */
|
||||||
__m128i pa = _mm_sub_epi16(b,c);
|
|
||||||
|
pa = _mm_sub_epi16(b,c);
|
||||||
|
|
||||||
/* (p-b) == (a+b-c - b) == (a-c) */
|
/* (p-b) == (a+b-c - b) == (a-c) */
|
||||||
__m128i pb = _mm_sub_epi16(a,c);
|
pb = _mm_sub_epi16(a,c);
|
||||||
|
|
||||||
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
||||||
__m128i pc = _mm_add_epi16(pa,pb);
|
pc = _mm_add_epi16(pa,pb);
|
||||||
|
|
||||||
pa = abs_i16(pa); /* |p-a| */
|
pa = abs_i16(pa); /* |p-a| */
|
||||||
pb = abs_i16(pb); /* |p-b| */
|
pb = abs_i16(pb); /* |p-b| */
|
||||||
pc = abs_i16(pc); /* |p-c| */
|
pc = abs_i16(pc); /* |p-c| */
|
||||||
|
|
||||||
__m128i smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
||||||
|
|
||||||
/* Paeth breaks ties favoring a over b over c. */
|
/* Paeth breaks ties favoring a over b over c. */
|
||||||
__m128i nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
||||||
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
||||||
c));
|
c));
|
||||||
|
|
||||||
@@ -285,26 +306,27 @@ void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
||||||
* intermediates.
|
* intermediates.
|
||||||
*/
|
*/
|
||||||
|
__m128i pa,pb,pc,smallest,nearest;
|
||||||
c = b; b = _mm_unpacklo_epi8(load3(prev), zero);
|
c = b; b = _mm_unpacklo_epi8(load3(prev), zero);
|
||||||
a = d; d = _mm_unpacklo_epi8(load3(row ), zero);
|
a = d; d = _mm_unpacklo_epi8(load3(row ), zero);
|
||||||
|
|
||||||
/* (p-a) == (a+b-c - a) == (b-c) */
|
/* (p-a) == (a+b-c - a) == (b-c) */
|
||||||
__m128i pa = _mm_sub_epi16(b,c);
|
pa = _mm_sub_epi16(b,c);
|
||||||
|
|
||||||
/* (p-b) == (a+b-c - b) == (a-c) */
|
/* (p-b) == (a+b-c - b) == (a-c) */
|
||||||
__m128i pb = _mm_sub_epi16(a,c);
|
pb = _mm_sub_epi16(a,c);
|
||||||
|
|
||||||
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
||||||
__m128i pc = _mm_add_epi16(pa,pb);
|
pc = _mm_add_epi16(pa,pb);
|
||||||
|
|
||||||
pa = abs_i16(pa); /* |p-a| */
|
pa = abs_i16(pa); /* |p-a| */
|
||||||
pb = abs_i16(pb); /* |p-b| */
|
pb = abs_i16(pb); /* |p-b| */
|
||||||
pc = abs_i16(pc); /* |p-c| */
|
pc = abs_i16(pc); /* |p-c| */
|
||||||
|
|
||||||
__m128i smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
||||||
|
|
||||||
/* Paeth breaks ties favoring a over b over c. */
|
/* Paeth breaks ties favoring a over b over c. */
|
||||||
__m128i nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
||||||
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
||||||
c));
|
c));
|
||||||
|
|
||||||
@@ -334,13 +356,16 @@ void png_read_filter_row_paeth4_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
* Here we zero b and d, which become c and a respectively at the start of
|
* Here we zero b and d, which become c and a respectively at the start of
|
||||||
* the loop.
|
* the loop.
|
||||||
*/
|
*/
|
||||||
png_debug(1, "in png_read_filter_row_paeth4_sse2");
|
png_size_t rb;
|
||||||
const __m128i zero = _mm_setzero_si128();
|
const __m128i zero = _mm_setzero_si128();
|
||||||
|
__m128i pa,pb,pc,smallest,nearest;
|
||||||
__m128i c, b = zero,
|
__m128i c, b = zero,
|
||||||
a, d = zero;
|
a, d = zero;
|
||||||
|
|
||||||
png_size_t rb = row_info->rowbytes;
|
png_debug(1, "in png_read_filter_row_paeth4_sse2");
|
||||||
while (rb > 0) {
|
|
||||||
|
rb = row_info->rowbytes+4;
|
||||||
|
while (rb > 4) {
|
||||||
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
/* It's easiest to do this math (particularly, deal with pc) with 16-bit
|
||||||
* intermediates.
|
* intermediates.
|
||||||
*/
|
*/
|
||||||
@@ -348,22 +373,22 @@ void png_read_filter_row_paeth4_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
|
a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
|
||||||
|
|
||||||
/* (p-a) == (a+b-c - a) == (b-c) */
|
/* (p-a) == (a+b-c - a) == (b-c) */
|
||||||
__m128i pa = _mm_sub_epi16(b,c);
|
pa = _mm_sub_epi16(b,c);
|
||||||
|
|
||||||
/* (p-b) == (a+b-c - b) == (a-c) */
|
/* (p-b) == (a+b-c - b) == (a-c) */
|
||||||
__m128i pb = _mm_sub_epi16(a,c);
|
pb = _mm_sub_epi16(a,c);
|
||||||
|
|
||||||
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
/* (p-c) == (a+b-c - c) == (a+b-c-c) == (b-c)+(a-c) */
|
||||||
__m128i pc = _mm_add_epi16(pa,pb);
|
pc = _mm_add_epi16(pa,pb);
|
||||||
|
|
||||||
pa = abs_i16(pa); /* |p-a| */
|
pa = abs_i16(pa); /* |p-a| */
|
||||||
pb = abs_i16(pb); /* |p-b| */
|
pb = abs_i16(pb); /* |p-b| */
|
||||||
pc = abs_i16(pc); /* |p-c| */
|
pc = abs_i16(pc); /* |p-c| */
|
||||||
|
|
||||||
__m128i smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
smallest = _mm_min_epi16(pc, _mm_min_epi16(pa, pb));
|
||||||
|
|
||||||
/* Paeth breaks ties favoring a over b over c. */
|
/* Paeth breaks ties favoring a over b over c. */
|
||||||
__m128i nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
nearest = if_then_else(_mm_cmpeq_epi16(smallest, pa), a,
|
||||||
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
if_then_else(_mm_cmpeq_epi16(smallest, pb), b,
|
||||||
c));
|
c));
|
||||||
|
|
||||||
+5
-6
@@ -1,19 +1,18 @@
|
|||||||
|
|
||||||
/* intel_init.c - SSE2 optimized filter functions
|
/* intel_init.c - SSE2 optimized filter functions
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016 Google, Inc.
|
* Copyright (c) 2016-2017 Glenn Randers-Pehrson
|
||||||
* Written by Mike Klein and Matt Sarett
|
* Written by Mike Klein and Matt Sarett, Google, Inc.
|
||||||
* Derived from arm/arm_init.c, which was
|
* Derived from arm/arm_init.c
|
||||||
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
* and license in png.h
|
* and license in png.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../pngpriv.h"
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
Vendored
+19
-86
@@ -1,67 +1,15 @@
|
|||||||
diff --git a/3rdparty/libpng/CMakeLists.txt b/3rdparty/libpng/CMakeLists.txt
|
|
||||||
index fee9c99..eaf2095 100644
|
|
||||||
--- a/3rdparty/libpng/CMakeLists.txt
|
|
||||||
+++ b/3rdparty/libpng/CMakeLists.txt
|
|
||||||
@@ -33,6 +33,11 @@ if(ENABLE_NEON)
|
|
||||||
add_definitions(-DPNG_ARM_NEON_OPT=2)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
+if(ENABLE_SSE)
|
|
||||||
+ list(APPEND lib_srcs contrib/intel/intel_init.c contrib/intel/filter_sse2_intrinsics.c)
|
|
||||||
+ add_definitions(-DPNG_INTEL_SSE)
|
|
||||||
+endif()
|
|
||||||
+
|
|
||||||
# ----------------------------------------------------------------------------------
|
|
||||||
# Define the library target:
|
|
||||||
# ----------------------------------------------------------------------------------
|
|
||||||
diff --git a/3rdparty/libpng/pngpriv.h b/3rdparty/libpng/pngpriv.h
|
|
||||||
index fe3355d..c0aa785 100644
|
|
||||||
--- a/3rdparty/libpng/pngpriv.h
|
--- a/3rdparty/libpng/pngpriv.h
|
||||||
+++ b/3rdparty/libpng/pngpriv.h
|
+++ b/3rdparty/libpng/pngpriv.h
|
||||||
@@ -182,6 +182,42 @@
|
@@ -214,7 +214,7 @@
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
|
||||||
|
|
||||||
+#ifndef PNG_INTEL_SSE_OPT
|
-#if PNG_INTEL_SSE_OPT > 0
|
||||||
+# 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
|
|
||||||
+# endif
|
|
||||||
+# endif
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+#if defined(PNG_INTEL_SSE_OPT) && PNG_INTEL_SSE_OPT > 0
|
+#if defined(PNG_INTEL_SSE_OPT) && PNG_INTEL_SSE_OPT > 0
|
||||||
+# ifndef PNG_INTEL_SSE_IMPLEMENTATION
|
# ifndef PNG_INTEL_SSE_IMPLEMENTATION
|
||||||
+# if defined(__SSE4_1__) || defined(__AVX__)
|
# if defined(__SSE4_1__) || defined(__AVX__)
|
||||||
+ /* We are not actually using AVX, but checking for AVX is the best
|
/* We are not actually using AVX, but checking for AVX is the best
|
||||||
+ way we can detect SSE4.1 and SSSE3 on MSVC.
|
@@ -547,7 +547,7 @@
|
||||||
+ */
|
|
||||||
+# 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
|
|
||||||
+#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.
|
|
||||||
@@ -457,7 +493,7 @@
|
|
||||||
|
|
||||||
/* Memory model/platform independent fns */
|
/* Memory model/platform independent fns */
|
||||||
#ifndef PNG_ABORT
|
#ifndef PNG_ABORT
|
||||||
@@ -70,36 +18,21 @@ index fe3355d..c0aa785 100644
|
|||||||
# define PNG_ABORT() ExitProcess(0)
|
# define PNG_ABORT() ExitProcess(0)
|
||||||
# else
|
# else
|
||||||
# define PNG_ABORT() abort()
|
# define PNG_ABORT() abort()
|
||||||
@@ -1190,6 +1226,21 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop
|
@@ -1340,7 +1340,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_vsx,(png_row_infop
|
||||||
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);
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
#endif
|
#endif
|
||||||
+
|
|
||||||
+#if defined(PNG_INTEL_SSE_IMPLEMENTATION) && 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
|
|
||||||
|
|
||||||
/* Choose the best filter to use and filter the row data */
|
-#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
|
+#if defined(PNG_INTEL_SSE_IMPLEMENTATION) && PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
@@ -1919,6 +1970,10 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
|
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop
|
||||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
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
|
||||||
|
@@ -2099,7 +2099,7 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
|
||||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||||
#endif
|
#endif
|
||||||
+# if defined(PNG_INTEL_SSE_IMPLEMENTATION) && 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
|
|
||||||
|
|
||||||
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
|
-# if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
|
+# if defined(PNG_INTEL_SSE_IMPLEMENTATION) && PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
|
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
|
||||||
|
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||||
|
# endif
|
||||||
Vendored
+169
-54
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* png.c - location for general purpose libpng functions
|
/* png.c - location for general purpose libpng functions
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -14,7 +14,27 @@
|
|||||||
#include "pngpriv.h"
|
#include "pngpriv.h"
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef png_libpng_version_1_6_24 Your_png_h_is_not_version_1_6_24;
|
typedef png_libpng_version_1_6_34 Your_png_h_is_not_version_1_6_34;
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
/* The version tests may need to be added to, but the problem warning has
|
||||||
|
* consistently been fixed in GCC versions which obtain wide-spread release.
|
||||||
|
* The problem is that many versions of GCC rearrange comparison expressions in
|
||||||
|
* the optimizer in such a way that the results of the comparison will change
|
||||||
|
* if signed integer overflow occurs. Such comparisons are not permitted in
|
||||||
|
* ANSI C90, however GCC isn't clever enough to work out that that do not occur
|
||||||
|
* below in png_ascii_from_fp and png_muldiv, so it produces a warning with
|
||||||
|
* -Wextra. Unfortunately this is highly dependent on the optimizer and the
|
||||||
|
* machine architecture so the warning comes and goes unpredictably and is
|
||||||
|
* impossible to "fix", even were that a good idea.
|
||||||
|
*/
|
||||||
|
#if __GNUC__ == 7 && __GNUC_MINOR__ == 1
|
||||||
|
#define GCC_STRICT_OVERFLOW 1
|
||||||
|
#endif /* GNU 7.1.x */
|
||||||
|
#endif /* GNU */
|
||||||
|
#ifndef GCC_STRICT_OVERFLOW
|
||||||
|
#define GCC_STRICT_OVERFLOW 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
/* 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
|
* of the PNG file signature. If the PNG data is embedded into another
|
||||||
@@ -458,7 +478,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||||||
|
|
||||||
#ifdef PNG_TEXT_SUPPORTED
|
#ifdef PNG_TEXT_SUPPORTED
|
||||||
/* Free text item num or (if num == -1) all text items */
|
/* Free text item num or (if num == -1) all text items */
|
||||||
if (info_ptr->text != 0 &&
|
if (info_ptr->text != NULL &&
|
||||||
((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0)
|
((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0)
|
||||||
{
|
{
|
||||||
if (num != -1)
|
if (num != -1)
|
||||||
@@ -477,6 +497,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||||||
png_free(png_ptr, info_ptr->text);
|
png_free(png_ptr, info_ptr->text);
|
||||||
info_ptr->text = NULL;
|
info_ptr->text = NULL;
|
||||||
info_ptr->num_text = 0;
|
info_ptr->num_text = 0;
|
||||||
|
info_ptr->max_text = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -541,7 +562,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||||||
|
|
||||||
#ifdef PNG_sPLT_SUPPORTED
|
#ifdef PNG_sPLT_SUPPORTED
|
||||||
/* Free a given sPLT entry, or (if num == -1) all sPLT entries */
|
/* Free a given sPLT entry, or (if num == -1) all sPLT entries */
|
||||||
if (info_ptr->splt_palettes != 0 &&
|
if (info_ptr->splt_palettes != NULL &&
|
||||||
((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0)
|
((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0)
|
||||||
{
|
{
|
||||||
if (num != -1)
|
if (num != -1)
|
||||||
@@ -571,7 +592,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
if (info_ptr->unknown_chunks != 0 &&
|
if (info_ptr->unknown_chunks != NULL &&
|
||||||
((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0)
|
((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0)
|
||||||
{
|
{
|
||||||
if (num != -1)
|
if (num != -1)
|
||||||
@@ -594,6 +615,26 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
#ifdef PNG_hIST_SUPPORTED
|
||||||
/* Free any hIST entry */
|
/* Free any hIST entry */
|
||||||
if (((mask & PNG_FREE_HIST) & info_ptr->free_me) != 0)
|
if (((mask & PNG_FREE_HIST) & info_ptr->free_me) != 0)
|
||||||
@@ -617,7 +658,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||||||
/* Free any image bits attached to the info structure */
|
/* Free any image bits attached to the info structure */
|
||||||
if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0)
|
if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0)
|
||||||
{
|
{
|
||||||
if (info_ptr->row_pointers != 0)
|
if (info_ptr->row_pointers != NULL)
|
||||||
{
|
{
|
||||||
png_uint_32 row;
|
png_uint_32 row;
|
||||||
for (row = 0; row < info_ptr->height; row++)
|
for (row = 0; row < info_ptr->height; row++)
|
||||||
@@ -684,7 +725,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_save_int_32(png_bytep buf, png_int_32 i)
|
png_save_int_32(png_bytep buf, png_int_32 i)
|
||||||
{
|
{
|
||||||
png_save_uint_32(buf, i);
|
png_save_uint_32(buf, (png_uint_32)i);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -775,15 +816,15 @@ png_get_copyright(png_const_structrp png_ptr)
|
|||||||
#else
|
#else
|
||||||
# ifdef __STDC__
|
# ifdef __STDC__
|
||||||
return PNG_STRING_NEWLINE \
|
return PNG_STRING_NEWLINE \
|
||||||
"libpng version 1.6.24 - August 4, 2016" PNG_STRING_NEWLINE \
|
"libpng version 1.6.34 - September 29, 2017" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
|
"Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
|
||||||
PNG_STRING_NEWLINE \
|
PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||||
PNG_STRING_NEWLINE;
|
PNG_STRING_NEWLINE;
|
||||||
# else
|
# else
|
||||||
return "libpng version 1.6.24 - August 4, 2016\
|
return "libpng version 1.6.34 - September 29, 2017\
|
||||||
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
|
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
|
||||||
Copyright (c) 1996-1997 Andreas Dilger\
|
Copyright (c) 1996-1997 Andreas Dilger\
|
||||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||||
# endif
|
# endif
|
||||||
@@ -1872,12 +1913,12 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
*/
|
*/
|
||||||
if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
|
if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
|
||||||
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
||||||
(unsigned)intent, "invalid sRGB rendering intent");
|
(png_alloc_size_t)intent, "invalid sRGB rendering intent");
|
||||||
|
|
||||||
if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
|
if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
|
||||||
colorspace->rendering_intent != intent)
|
colorspace->rendering_intent != intent)
|
||||||
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
||||||
(unsigned)intent, "inconsistent rendering intents");
|
(png_alloc_size_t)intent, "inconsistent rendering intents");
|
||||||
|
|
||||||
if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0)
|
if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0)
|
||||||
{
|
{
|
||||||
@@ -1931,16 +1972,49 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
static const png_byte D50_nCIEXYZ[12] =
|
static const png_byte D50_nCIEXYZ[12] =
|
||||||
{ 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
|
{ 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
|
||||||
|
|
||||||
int /* PRIVATE */
|
static int /* bool */
|
||||||
png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||||
png_const_charp name, png_uint_32 profile_length)
|
png_const_charp name, png_uint_32 profile_length)
|
||||||
{
|
{
|
||||||
if (profile_length < 132)
|
if (profile_length < 132)
|
||||||
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||||
"too short");
|
"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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif /* READ_iCCP */
|
||||||
|
|
||||||
int /* PRIVATE */
|
int /* PRIVATE */
|
||||||
png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||||
@@ -2149,15 +2223,6 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
* being in range. All defined tag types have an 8 byte header - a 4 byte
|
* being in range. All defined tag types have an 8 byte header - a 4 byte
|
||||||
* type signature then 0.
|
* type signature then 0.
|
||||||
*/
|
*/
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is a hard error; potentially it can cause read outside the
|
/* This is a hard error; potentially it can cause read outside the
|
||||||
* profile.
|
* profile.
|
||||||
@@ -2165,6 +2230,16 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
if (tag_start > profile_length || tag_length > profile_length - tag_start)
|
if (tag_start > profile_length || tag_length > profile_length - tag_start)
|
||||||
return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
|
return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
|
||||||
"ICC profile tag outside profile");
|
"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 */
|
return 1; /* success, maybe with warnings */
|
||||||
@@ -2377,7 +2452,7 @@ png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
|
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
|
if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
|
||||||
png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
|
png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
|
||||||
color_type) != 0 &&
|
color_type) != 0 &&
|
||||||
png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
|
png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
|
||||||
@@ -2495,7 +2570,7 @@ png_check_IHDR(png_const_structrp png_ptr,
|
|||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_gt(((width + 7) & (~7)),
|
if (png_gt(((width + 7) & (~7U)),
|
||||||
((PNG_SIZE_MAX
|
((PNG_SIZE_MAX
|
||||||
- 48 /* big_row_buf hack */
|
- 48 /* big_row_buf hack */
|
||||||
- 1) /* filter byte */
|
- 1) /* filter byte */
|
||||||
@@ -2797,7 +2872,7 @@ png_pow10(int power)
|
|||||||
if (power < 0)
|
if (power < 0)
|
||||||
{
|
{
|
||||||
if (power < DBL_MIN_10_EXP) return 0;
|
if (power < DBL_MIN_10_EXP) return 0;
|
||||||
recip = 1, power = -power;
|
recip = 1; power = -power;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (power > 0)
|
if (power > 0)
|
||||||
@@ -2822,6 +2897,14 @@ png_pow10(int power)
|
|||||||
/* Function to format a floating point value in ASCII with a given
|
/* Function to format a floating point value in ASCII with a given
|
||||||
* precision.
|
* precision.
|
||||||
*/
|
*/
|
||||||
|
#if GCC_STRICT_OVERFLOW
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
/* The problem arises below with exp_b10, which can never overflow because it
|
||||||
|
* comes, originally, from frexp and is therefore limited to a range which is
|
||||||
|
* typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)).
|
||||||
|
*/
|
||||||
|
#pragma GCC diagnostic warning "-Wstrict-overflow=2"
|
||||||
|
#endif /* GCC_STRICT_OVERFLOW */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
||||||
double fp, unsigned int precision)
|
double fp, unsigned int precision)
|
||||||
@@ -2875,7 +2958,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
double test = png_pow10(exp_b10+1);
|
double test = png_pow10(exp_b10+1);
|
||||||
|
|
||||||
if (test <= DBL_MAX)
|
if (test <= DBL_MAX)
|
||||||
++exp_b10, base = test;
|
{
|
||||||
|
++exp_b10; base = test;
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
@@ -2889,7 +2974,10 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
* test on DBL_MAX above.
|
* test on DBL_MAX above.
|
||||||
*/
|
*/
|
||||||
fp /= base;
|
fp /= base;
|
||||||
while (fp >= 1) fp /= 10, ++exp_b10;
|
while (fp >= 1)
|
||||||
|
{
|
||||||
|
fp /= 10; ++exp_b10;
|
||||||
|
}
|
||||||
|
|
||||||
/* Because of the code above fp may, at this point, be
|
/* Because of the code above fp may, at this point, be
|
||||||
* less than .1, this is ok because the code below can
|
* less than .1, this is ok because the code below can
|
||||||
@@ -2906,7 +2994,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
*/
|
*/
|
||||||
if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */
|
if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */
|
||||||
{
|
{
|
||||||
czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */
|
czero = 0U-exp_b10; /* PLUS 2 digits: TOTAL 3 */
|
||||||
exp_b10 = 0; /* Dot added below before first output. */
|
exp_b10 = 0; /* Dot added below before first output. */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2940,7 +3028,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
/* Rounding up to 10, handle that here. */
|
/* Rounding up to 10, handle that here. */
|
||||||
if (czero > 0)
|
if (czero > 0)
|
||||||
{
|
{
|
||||||
--czero, d = 1;
|
--czero; d = 1;
|
||||||
if (cdigits == 0) --clead;
|
if (cdigits == 0) --clead;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2954,7 +3042,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
|
|
||||||
else if (ch == 46)
|
else if (ch == 46)
|
||||||
{
|
{
|
||||||
ch = *--ascii, ++size;
|
ch = *--ascii; ++size;
|
||||||
/* Advance exp_b10 to '1', so that the
|
/* Advance exp_b10 to '1', so that the
|
||||||
* decimal point happens after the
|
* decimal point happens after the
|
||||||
* previous digit.
|
* previous digit.
|
||||||
@@ -2981,7 +3069,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
int ch = *--ascii;
|
int ch = *--ascii;
|
||||||
|
|
||||||
if (ch == 46)
|
if (ch == 46)
|
||||||
++size, exp_b10 = 1;
|
{
|
||||||
|
++size; exp_b10 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Else lost a leading zero, so 'exp_b10' is
|
/* Else lost a leading zero, so 'exp_b10' is
|
||||||
* still ok at (-1)
|
* still ok at (-1)
|
||||||
@@ -3017,21 +3107,26 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
*/
|
*/
|
||||||
if (exp_b10 != (-1))
|
if (exp_b10 != (-1))
|
||||||
{
|
{
|
||||||
if (exp_b10 == 0) *ascii++ = 46, --size;
|
if (exp_b10 == 0)
|
||||||
|
{
|
||||||
|
*ascii++ = 46; --size;
|
||||||
|
}
|
||||||
/* PLUS 1: TOTAL 4 */
|
/* PLUS 1: TOTAL 4 */
|
||||||
--exp_b10;
|
--exp_b10;
|
||||||
}
|
}
|
||||||
*ascii++ = 48, --czero;
|
*ascii++ = 48; --czero;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exp_b10 != (-1))
|
if (exp_b10 != (-1))
|
||||||
{
|
{
|
||||||
if (exp_b10 == 0)
|
if (exp_b10 == 0)
|
||||||
*ascii++ = 46, --size; /* counted above */
|
{
|
||||||
|
*ascii++ = 46; --size; /* counted above */
|
||||||
|
}
|
||||||
|
|
||||||
--exp_b10;
|
--exp_b10;
|
||||||
}
|
}
|
||||||
*ascii++ = (char)(48 + (int)d), ++cdigits;
|
*ascii++ = (char)(48 + (int)d); ++cdigits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (cdigits+czero < precision+clead && fp > DBL_MIN);
|
while (cdigits+czero < precision+clead && fp > DBL_MIN);
|
||||||
@@ -3040,7 +3135,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
|
|
||||||
/* Check for an exponent, if we don't need one we are
|
/* Check for an exponent, if we don't need one we are
|
||||||
* done and just need to terminate the string. At
|
* done and just need to terminate the string. At
|
||||||
* this point exp_b10==(-1) is effectively if flag - it got
|
* this point exp_b10==(-1) is effectively a flag - it got
|
||||||
* to '-1' because of the decrement after outputting
|
* to '-1' because of the decrement after outputting
|
||||||
* the decimal point above (the exponent required is
|
* the decimal point above (the exponent required is
|
||||||
* *not* -1!)
|
* *not* -1!)
|
||||||
@@ -3054,7 +3149,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
* zeros were *not* output, so this doesn't increase
|
* zeros were *not* output, so this doesn't increase
|
||||||
* the output count.
|
* the output count.
|
||||||
*/
|
*/
|
||||||
while (--exp_b10 >= 0) *ascii++ = 48;
|
while (exp_b10-- > 0) *ascii++ = 48;
|
||||||
|
|
||||||
*ascii = 0;
|
*ascii = 0;
|
||||||
|
|
||||||
@@ -3072,7 +3167,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
*/
|
*/
|
||||||
size -= cdigits;
|
size -= cdigits;
|
||||||
|
|
||||||
*ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision */
|
*ascii++ = 69; --size; /* 'E': PLUS 1 TOTAL 2+precision */
|
||||||
|
|
||||||
/* The following use of an unsigned temporary avoids ambiguities in
|
/* The following use of an unsigned temporary avoids ambiguities in
|
||||||
* the signed arithmetic on exp_b10 and permits GCC at least to do
|
* the signed arithmetic on exp_b10 and permits GCC at least to do
|
||||||
@@ -3083,12 +3178,12 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
|
|
||||||
if (exp_b10 < 0)
|
if (exp_b10 < 0)
|
||||||
{
|
{
|
||||||
*ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
|
*ascii++ = 45; --size; /* '-': PLUS 1 TOTAL 3+precision */
|
||||||
uexp_b10 = -exp_b10;
|
uexp_b10 = 0U-exp_b10;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
uexp_b10 = exp_b10;
|
uexp_b10 = 0U+exp_b10;
|
||||||
|
|
||||||
cdigits = 0;
|
cdigits = 0;
|
||||||
|
|
||||||
@@ -3131,6 +3226,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
/* Here on buffer too small. */
|
/* Here on buffer too small. */
|
||||||
png_error(png_ptr, "ASCII conversion buffer too small");
|
png_error(png_ptr, "ASCII conversion buffer too small");
|
||||||
}
|
}
|
||||||
|
#if GCC_STRICT_OVERFLOW
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif /* GCC_STRICT_OVERFLOW */
|
||||||
|
|
||||||
# endif /* FLOATING_POINT */
|
# endif /* FLOATING_POINT */
|
||||||
|
|
||||||
@@ -3150,9 +3248,11 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
|
|||||||
|
|
||||||
/* Avoid overflow here on the minimum integer. */
|
/* Avoid overflow here on the minimum integer. */
|
||||||
if (fp < 0)
|
if (fp < 0)
|
||||||
*ascii++ = 45, num = -fp;
|
{
|
||||||
|
*ascii++ = 45; num = (png_uint_32)(-fp);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
num = fp;
|
num = (png_uint_32)fp;
|
||||||
|
|
||||||
if (num <= 0x80000000) /* else overflowed */
|
if (num <= 0x80000000) /* else overflowed */
|
||||||
{
|
{
|
||||||
@@ -3188,7 +3288,10 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
|
|||||||
* then ndigits digits to first:
|
* then ndigits digits to first:
|
||||||
*/
|
*/
|
||||||
i = 5;
|
i = 5;
|
||||||
while (ndigits < i) *ascii++ = 48, --i;
|
while (ndigits < i)
|
||||||
|
{
|
||||||
|
*ascii++ = 48; --i;
|
||||||
|
}
|
||||||
while (ndigits >= first) *ascii++ = digits[--ndigits];
|
while (ndigits >= first) *ascii++ = digits[--ndigits];
|
||||||
/* Don't output the trailing zeros! */
|
/* Don't output the trailing zeros! */
|
||||||
}
|
}
|
||||||
@@ -3239,6 +3342,15 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
|
|||||||
* the nearest .00001). Overflow and divide by zero are signalled in
|
* the nearest .00001). Overflow and divide by zero are signalled in
|
||||||
* the result, a boolean - true on success, false on overflow.
|
* the result, a boolean - true on success, false on overflow.
|
||||||
*/
|
*/
|
||||||
|
#if GCC_STRICT_OVERFLOW /* from above */
|
||||||
|
/* It is not obvious which comparison below gets optimized in such a way that
|
||||||
|
* signed overflow would change the result; looking through the code does not
|
||||||
|
* reveal any tests which have the form GCC complains about, so presumably the
|
||||||
|
* optimizer is moving an add or subtract into the 'if' somewhere.
|
||||||
|
*/
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic warning "-Wstrict-overflow=2"
|
||||||
|
#endif /* GCC_STRICT_OVERFLOW */
|
||||||
int
|
int
|
||||||
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
|
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
|
||||||
png_int_32 divisor)
|
png_int_32 divisor)
|
||||||
@@ -3353,6 +3465,9 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#if GCC_STRICT_OVERFLOW
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif /* GCC_STRICT_OVERFLOW */
|
||||||
#endif /* READ_GAMMA || INCH_CONVERSIONS */
|
#endif /* READ_GAMMA || INCH_CONVERSIONS */
|
||||||
|
|
||||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
|
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
|
||||||
@@ -3646,7 +3761,7 @@ png_log16bit(png_uint_32 x)
|
|||||||
* of getting this accuracy in practice.
|
* of getting this accuracy in practice.
|
||||||
*
|
*
|
||||||
* To deal with this the following exp() function works out the exponent of the
|
* To deal with this the following exp() function works out the exponent of the
|
||||||
* frational part of the logarithm by using an accurate 32-bit value from 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.
|
* top four fractional bits then multiplying in the remaining bits.
|
||||||
*/
|
*/
|
||||||
static const png_uint_32
|
static const png_uint_32
|
||||||
@@ -4225,13 +4340,13 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
|
|||||||
if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
|
if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
|
||||||
(option & 1) == 0)
|
(option & 1) == 0)
|
||||||
{
|
{
|
||||||
int mask = 3 << option;
|
png_uint_32 mask = 3U << option;
|
||||||
int setting = (2 + (onoff != 0)) << option;
|
png_uint_32 setting = (2U + (onoff != 0)) << option;
|
||||||
int current = png_ptr->options;
|
png_uint_32 current = png_ptr->options;
|
||||||
|
|
||||||
png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff);
|
png_ptr->options = (png_uint_32)(((current & ~mask) | setting) & 0xff);
|
||||||
|
|
||||||
return (current & mask) >> option;
|
return (int)(current & mask) >> option;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PNG_OPTION_INVALID;
|
return PNG_OPTION_INVALID;
|
||||||
@@ -4243,7 +4358,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
|
|||||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||||
/* sRGB conversion tables; these are machine generated with the code in
|
/* sRGB conversion tables; these are machine generated with the code in
|
||||||
* contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
|
* contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
|
||||||
* specification (see the article at http://en.wikipedia.org/wiki/SRGB)
|
* specification (see the article at https://en.wikipedia.org/wiki/SRGB)
|
||||||
* is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
|
* 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 sRGB to linear table is exact (to the nearest 16-bit linear fraction).
|
||||||
* The inverse (linear to sRGB) table has accuracies as follows:
|
* The inverse (linear to sRGB) table has accuracies as follows:
|
||||||
|
|||||||
Vendored
+48
-32
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.6.24, August 4, 2016
|
* libpng version 1.6.34, September 29, 2017
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
* 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.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.6.24, August 4, 2016:
|
* libpng versions 0.97, January 1998, through 1.6.34, September 29, 2017:
|
||||||
* Glenn Randers-Pehrson.
|
* Glenn Randers-Pehrson.
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*/
|
*/
|
||||||
@@ -25,12 +25,8 @@
|
|||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
*
|
*
|
||||||
* Some files in the "contrib" directory and some configure-generated
|
* libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are
|
||||||
* files that are distributed with libpng have other copyright owners and
|
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||||
* are released under other open source licenses.
|
|
||||||
*
|
|
||||||
* libpng versions 1.0.7, July 1, 2000 through 1.6.24, August 4, 2016 are
|
|
||||||
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
|
||||||
* derived from libpng-1.0.6, and are distributed according to the same
|
* 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
|
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
* added to the list of Contributing Authors:
|
* added to the list of Contributing Authors:
|
||||||
@@ -41,6 +37,9 @@
|
|||||||
* Cosmin Truta
|
* Cosmin Truta
|
||||||
* Gilles Vollant
|
* Gilles Vollant
|
||||||
* James Yu
|
* James Yu
|
||||||
|
* Mandar Sahastrabuddhe
|
||||||
|
* Google Inc.
|
||||||
|
* Vadim Barkov
|
||||||
*
|
*
|
||||||
* and with the following additions to the disclaimer:
|
* and with the following additions to the disclaimer:
|
||||||
*
|
*
|
||||||
@@ -51,10 +50,10 @@
|
|||||||
* risk of satisfactory quality, performance, accuracy, and effort is with
|
* risk of satisfactory quality, performance, accuracy, and effort is with
|
||||||
* the user.
|
* the user.
|
||||||
*
|
*
|
||||||
* Some files in the "contrib" directory have other copyright owners and
|
* 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.
|
* are released under other open source licenses.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||||
* libpng-0.96, and are distributed according to the same disclaimer and
|
* libpng-0.96, and are distributed according to the same disclaimer and
|
||||||
@@ -65,9 +64,6 @@
|
|||||||
* Glenn Randers-Pehrson
|
* Glenn Randers-Pehrson
|
||||||
* Willem van Schaik
|
* Willem van Schaik
|
||||||
*
|
*
|
||||||
* Some files in the "scripts" directory have different copyright owners
|
|
||||||
* but are also released under this license.
|
|
||||||
*
|
|
||||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||||
* and are distributed according to the same disclaimer and license as
|
* and are distributed according to the same disclaimer and license as
|
||||||
@@ -213,11 +209,11 @@
|
|||||||
* ...
|
* ...
|
||||||
* 1.0.19 10 10019 10.so.0.19[.0]
|
* 1.0.19 10 10019 10.so.0.19[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.2.56 13 10256 12.so.0.56[.0]
|
* 1.2.59 13 10257 12.so.0.59[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.5.27 15 10527 15.so.15.27[.0]
|
* 1.5.30 15 10527 15.so.15.30[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.6.24 16 10624 16.so.16.24[.0]
|
* 1.6.34 16 10633 16.so.16.34[.0]
|
||||||
*
|
*
|
||||||
* Henceforth the source version will match the shared-library major
|
* Henceforth the source version will match the shared-library major
|
||||||
* and minor numbers; the shared-library major version number will be
|
* and minor numbers; the shared-library major version number will be
|
||||||
@@ -238,20 +234,20 @@
|
|||||||
*
|
*
|
||||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||||
* is available as a W3C Recommendation and as an ISO Specification,
|
* is available as a W3C Recommendation and as an ISO Specification,
|
||||||
* <http://www.w3.org/TR/2003/REC-PNG-20031110/
|
* <https://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* August 4, 2016
|
* September 29, 2017
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
*
|
*
|
||||||
* This is your unofficial assurance that libpng from version 0.71 and
|
* This is your unofficial assurance that libpng from version 0.71 and
|
||||||
* upward through 1.6.24 are Y2K compliant. It is my belief that
|
* upward through 1.6.34 are Y2K compliant. It is my belief that
|
||||||
* earlier versions were also Y2K compliant.
|
* earlier versions were also Y2K compliant.
|
||||||
*
|
*
|
||||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||||
@@ -313,8 +309,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Version information for png.h - this should match the version in png.c */
|
/* Version information for png.h - this should match the version in png.c */
|
||||||
#define PNG_LIBPNG_VER_STRING "1.6.24"
|
#define PNG_LIBPNG_VER_STRING "1.6.34"
|
||||||
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.24 - August 4, 2016\n"
|
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.34 - September 29, 2017\n"
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 16
|
#define PNG_LIBPNG_VER_SONUM 16
|
||||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||||
@@ -322,7 +318,7 @@
|
|||||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||||
#define PNG_LIBPNG_VER_MAJOR 1
|
#define PNG_LIBPNG_VER_MAJOR 1
|
||||||
#define PNG_LIBPNG_VER_MINOR 6
|
#define PNG_LIBPNG_VER_MINOR 6
|
||||||
#define PNG_LIBPNG_VER_RELEASE 24
|
#define PNG_LIBPNG_VER_RELEASE 34
|
||||||
|
|
||||||
/* This should match the numeric part of the final component of
|
/* This should match the numeric part of the final component of
|
||||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||||
@@ -353,7 +349,7 @@
|
|||||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||||
*/
|
*/
|
||||||
#define PNG_LIBPNG_VER 10624 /* 1.6.24 */
|
#define PNG_LIBPNG_VER 10634 /* 1.6.34 */
|
||||||
|
|
||||||
/* Library configuration: these options cannot be changed after
|
/* Library configuration: these options cannot be changed after
|
||||||
* the library has been built.
|
* the library has been built.
|
||||||
@@ -463,7 +459,7 @@ extern "C" {
|
|||||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||||
* do not agree upon the version number.
|
* do not agree upon the version number.
|
||||||
*/
|
*/
|
||||||
typedef char* png_libpng_version_1_6_24;
|
typedef char* png_libpng_version_1_6_34;
|
||||||
|
|
||||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||||
*
|
*
|
||||||
@@ -780,6 +776,7 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
|
|||||||
#define PNG_INFO_sPLT 0x2000U /* 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_sCAL 0x4000U /* ESR, 1.0.6 */
|
||||||
#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
|
#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
|
||||||
|
#define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */
|
||||||
|
|
||||||
/* This is used for the transformation routines, as some of them
|
/* This is used for the transformation routines, as some of them
|
||||||
* change these values for the row. It also should enable using
|
* change these values for the row. It also should enable using
|
||||||
@@ -1792,7 +1789,8 @@ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
|
|||||||
#define PNG_FREE_PLTE 0x1000U
|
#define PNG_FREE_PLTE 0x1000U
|
||||||
#define PNG_FREE_TRNS 0x2000U
|
#define PNG_FREE_TRNS 0x2000U
|
||||||
#define PNG_FREE_TEXT 0x4000U
|
#define PNG_FREE_TEXT 0x4000U
|
||||||
#define PNG_FREE_ALL 0x7fffU
|
#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 */
|
#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
|
||||||
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
@@ -2011,6 +2009,18 @@ PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
|
|||||||
png_fixed_point int_blue_Z))
|
png_fixed_point int_blue_Z))
|
||||||
#endif
|
#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, const 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, const png_uint_32 num_exif, const png_bytep exif));
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_gAMA_SUPPORTED
|
#ifdef PNG_gAMA_SUPPORTED
|
||||||
PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,
|
PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,
|
||||||
png_const_inforp info_ptr, double *file_gamma))
|
png_const_inforp info_ptr, double *file_gamma))
|
||||||
@@ -2029,9 +2039,6 @@ PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
|
|||||||
#ifdef PNG_hIST_SUPPORTED
|
#ifdef PNG_hIST_SUPPORTED
|
||||||
PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
|
PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
|
||||||
png_inforp info_ptr, png_uint_16p *hist));
|
png_inforp info_ptr, png_uint_16p *hist));
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_hIST_SUPPORTED
|
|
||||||
PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,
|
PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,
|
||||||
png_inforp info_ptr, png_const_uint_16p hist));
|
png_inforp info_ptr, png_const_uint_16p hist));
|
||||||
#endif
|
#endif
|
||||||
@@ -2757,7 +2764,7 @@ typedef struct
|
|||||||
*
|
*
|
||||||
* When the simplified API needs to convert between sRGB and linear colorspaces,
|
* When the simplified API needs to convert between sRGB and linear colorspaces,
|
||||||
* the actual sRGB transfer curve defined in the sRGB specification (see the
|
* the actual sRGB transfer curve defined in the sRGB specification (see the
|
||||||
* article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
|
* article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
|
||||||
* approximation used elsewhere in libpng.
|
* approximation used elsewhere in libpng.
|
||||||
*
|
*
|
||||||
* When an alpha channel is present it is expected to denote pixel coverage
|
* When an alpha channel is present it is expected to denote pixel coverage
|
||||||
@@ -2812,6 +2819,8 @@ typedef struct
|
|||||||
# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */
|
# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PNG_FORMAT_FLAG_ASSOCIATED_ALPHA 0x40U /* alpha channel is associated */
|
||||||
|
|
||||||
/* Commonly used formats have predefined macros.
|
/* Commonly used formats have predefined macros.
|
||||||
*
|
*
|
||||||
* First the single byte (sRGB) formats:
|
* First the single byte (sRGB) formats:
|
||||||
@@ -3226,7 +3235,14 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
|
|||||||
#endif
|
#endif
|
||||||
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
|
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
|
||||||
#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
|
#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
|
||||||
#define PNG_OPTION_NEXT 6 /* Next option - numbers must be even */
|
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||||
|
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
|
||||||
|
#endif
|
||||||
|
#define PNG_IGNORE_ADLER32 8
|
||||||
|
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
|
||||||
|
# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */
|
||||||
|
#endif
|
||||||
|
#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */
|
||||||
|
|
||||||
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
||||||
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
||||||
@@ -3250,7 +3266,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
|
|||||||
* one to use is one more than this.)
|
* one to use is one more than this.)
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||||
PNG_EXPORT_LAST_ORDINAL(245);
|
PNG_EXPORT_LAST_ORDINAL(249);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.6.24, August 4, 2016
|
* libpng version 1.6.34, September 29, 2017
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -507,9 +507,9 @@
|
|||||||
# error "libpng requires a signed 32-bit (or more) type"
|
# error "libpng requires a signed 32-bit (or more) type"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if UINT_MAX > 4294967294
|
#if UINT_MAX > 4294967294U
|
||||||
typedef unsigned int png_uint_32;
|
typedef unsigned int png_uint_32;
|
||||||
#elif ULONG_MAX > 4294967294
|
#elif ULONG_MAX > 4294967294U
|
||||||
typedef unsigned long int png_uint_32;
|
typedef unsigned long int png_uint_32;
|
||||||
#else
|
#else
|
||||||
# error "libpng requires an unsigned 32-bit (or more) type"
|
# error "libpng requires an unsigned 32-bit (or more) type"
|
||||||
|
|||||||
Vendored
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -573,7 +573,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
|||||||
{
|
{
|
||||||
# define fixed_message "fixed point overflow in "
|
# define fixed_message "fixed point overflow in "
|
||||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||||
int iin;
|
unsigned int iin;
|
||||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||||
memcpy(msg, fixed_message, fixed_message_ln);
|
memcpy(msg, fixed_message, fixed_message_ln);
|
||||||
iin = 0;
|
iin = 0;
|
||||||
|
|||||||
Vendored
+32
-3
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngget.c - retrieval of values from info struct
|
/* pngget.c - retrieval of values from info struct
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -338,7 +338,7 @@ ppi_from_ppm(png_uint_32 ppm)
|
|||||||
png_fixed_point result;
|
png_fixed_point result;
|
||||||
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
|
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
|
||||||
5000) != 0)
|
5000) != 0)
|
||||||
return result;
|
return (png_uint_32)result;
|
||||||
|
|
||||||
/* Overflow. */
|
/* Overflow. */
|
||||||
return 0;
|
return 0;
|
||||||
@@ -773,6 +773,35 @@ png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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
|
#ifdef PNG_hIST_SUPPORTED
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
|
|||||||
Vendored
+8
@@ -185,6 +185,14 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
|||||||
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
|
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
|
||||||
#endif
|
#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
|
#ifdef PNG_hIST_SUPPORTED
|
||||||
/* The hIST chunk contains the relative frequency or importance of the
|
/* The hIST chunk contains the relative frequency or importance of the
|
||||||
* various palette entries, so that a viewer can intelligently select a
|
* various palette entries, so that a viewer can intelligently select a
|
||||||
|
|||||||
Vendored
+8
-3
@@ -1,10 +1,10 @@
|
|||||||
/* libpng 1.6.24 STANDARD API DEFINITION */
|
/* libpng 1.6.34 STANDARD API DEFINITION */
|
||||||
|
|
||||||
/* pnglibconf.h - library build configuration */
|
/* pnglibconf.h - library build configuration */
|
||||||
|
|
||||||
/* Libpng version 1.6.24 - August 4, 2016 */
|
/* Libpng version 1.6.34 - September 29, 2017 */
|
||||||
|
|
||||||
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
/* Copyright (c) 1998-2017 Glenn Randers-Pehrson */
|
||||||
|
|
||||||
/* This code is released under the libpng license. */
|
/* This code is released under the libpng license. */
|
||||||
/* For conditions of distribution and use, see the disclaimer */
|
/* For conditions of distribution and use, see the disclaimer */
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||||
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||||
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||||
|
/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
|
||||||
|
/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
|
||||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||||
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||||
@@ -82,6 +84,7 @@
|
|||||||
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||||
#define PNG_READ_bKGD_SUPPORTED
|
#define PNG_READ_bKGD_SUPPORTED
|
||||||
#define PNG_READ_cHRM_SUPPORTED
|
#define PNG_READ_cHRM_SUPPORTED
|
||||||
|
#define PNG_READ_eXIf_SUPPORTED
|
||||||
#define PNG_READ_gAMA_SUPPORTED
|
#define PNG_READ_gAMA_SUPPORTED
|
||||||
#define PNG_READ_hIST_SUPPORTED
|
#define PNG_READ_hIST_SUPPORTED
|
||||||
#define PNG_READ_iCCP_SUPPORTED
|
#define PNG_READ_iCCP_SUPPORTED
|
||||||
@@ -151,6 +154,7 @@
|
|||||||
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||||
#define PNG_WRITE_bKGD_SUPPORTED
|
#define PNG_WRITE_bKGD_SUPPORTED
|
||||||
#define PNG_WRITE_cHRM_SUPPORTED
|
#define PNG_WRITE_cHRM_SUPPORTED
|
||||||
|
#define PNG_WRITE_eXIf_SUPPORTED
|
||||||
#define PNG_WRITE_gAMA_SUPPORTED
|
#define PNG_WRITE_gAMA_SUPPORTED
|
||||||
#define PNG_WRITE_hIST_SUPPORTED
|
#define PNG_WRITE_hIST_SUPPORTED
|
||||||
#define PNG_WRITE_iCCP_SUPPORTED
|
#define PNG_WRITE_iCCP_SUPPORTED
|
||||||
@@ -168,6 +172,7 @@
|
|||||||
#define PNG_WRITE_zTXt_SUPPORTED
|
#define PNG_WRITE_zTXt_SUPPORTED
|
||||||
#define PNG_bKGD_SUPPORTED
|
#define PNG_bKGD_SUPPORTED
|
||||||
#define PNG_cHRM_SUPPORTED
|
#define PNG_cHRM_SUPPORTED
|
||||||
|
#define PNG_eXIf_SUPPORTED
|
||||||
#define PNG_gAMA_SUPPORTED
|
#define PNG_gAMA_SUPPORTED
|
||||||
#define PNG_hIST_SUPPORTED
|
#define PNG_hIST_SUPPORTED
|
||||||
#define PNG_iCCP_SUPPORTED
|
#define PNG_iCCP_SUPPORTED
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
/* pngmem.c - stub functions for memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@@ -109,7 +109,7 @@ static png_voidp
|
|||||||
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||||
size_t element_size)
|
size_t element_size)
|
||||||
{
|
{
|
||||||
png_alloc_size_t req = nelements; /* known to be > 0 */
|
png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */
|
||||||
|
|
||||||
if (req <= PNG_SIZE_MAX/element_size)
|
if (req <= PNG_SIZE_MAX/element_size)
|
||||||
return png_malloc_base(png_ptr, req * element_size);
|
return png_malloc_base(png_ptr, req * element_size);
|
||||||
|
|||||||
Vendored
+8
-2
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -189,6 +189,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
png_crc_read(png_ptr, chunk_tag, 4);
|
png_crc_read(png_ptr, chunk_tag, 4);
|
||||||
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
|
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
|
||||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
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;
|
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,8 +684,13 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
|||||||
png_ptr->pass > 6)
|
png_ptr->pass > 6)
|
||||||
png_warning(png_ptr, "Truncated compressed data in IDAT");
|
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
|
else
|
||||||
png_error(png_ptr, "Decompression error in IDAT");
|
png_error(png_ptr, "Decompression error in IDAT");
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip the check on unprocessed input */
|
/* Skip the check on unprocessed input */
|
||||||
return;
|
return;
|
||||||
|
|||||||
Vendored
+235
-106
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngpriv.h - private declarations for use inside libpng
|
/* pngpriv.h - private declarations for use inside libpng
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -35,7 +35,9 @@
|
|||||||
* Windows/Visual Studio) there is no effect; the OS specific tests below are
|
* Windows/Visual Studio) there is no effect; the OS specific tests below are
|
||||||
* still required (as of 2011-05-02.)
|
* still required (as of 2011-05-02.)
|
||||||
*/
|
*/
|
||||||
|
#ifndef _POSIX_SOURCE
|
||||||
# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
|
# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_VERSION_INFO_ONLY
|
#ifndef PNG_VERSION_INFO_ONLY
|
||||||
/* Standard library headers not required by png.h: */
|
/* Standard library headers not required by png.h: */
|
||||||
@@ -182,6 +184,22 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif /* PNG_ARM_NEON_OPT > 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_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_INTEL_SSE_OPT
|
#ifndef PNG_INTEL_SSE_OPT
|
||||||
# ifdef PNG_INTEL_SSE
|
# ifdef PNG_INTEL_SSE
|
||||||
/* Only check for SSE if the build configuration has been modified to
|
/* Only check for SSE if the build configuration has been modified to
|
||||||
@@ -218,6 +236,32 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PNG_MIPS_MSA_OPT > 0
|
||||||
|
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
|
||||||
|
# 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
|
||||||
|
# endif
|
||||||
|
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
||||||
|
|
||||||
|
#if PNG_POWERPC_VSX_OPT > 0
|
||||||
|
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
|
||||||
|
# define PNG_POWERPC_VSX_IMPLEMENTATION 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Is this a build of a DLL where compilation of the object modules requires
|
/* 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
|
* different preprocessor settings to those required for a simple library? If
|
||||||
* so PNG_BUILD_DLL must be set.
|
* so PNG_BUILD_DLL must be set.
|
||||||
@@ -410,25 +454,6 @@
|
|||||||
# define png_fixed_error(s1,s2) png_err(s1)
|
# define png_fixed_error(s1,s2) png_err(s1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* 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)(value))
|
|
||||||
# define png_aligncast(type, value) ((void*)(value))
|
|
||||||
# define png_aligncastconst(type, value) ((const void*)(value))
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
/* Some fixed point APIs are still required even if not exported because
|
/* Some fixed point APIs are still required even if not exported because
|
||||||
* they get used by the corresponding floating point APIs. This magic
|
* they get used by the corresponding floating point APIs. This magic
|
||||||
* deals with this:
|
* deals with this:
|
||||||
@@ -443,6 +468,35 @@
|
|||||||
/* Other defines specific to compilers can go here. Try to keep
|
/* Other defines specific to compilers can go here. Try to keep
|
||||||
* them inside an appropriate ifdef/endif pair for portability.
|
* 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)
|
||||||
|
# ifdef _WIN64
|
||||||
|
# ifdef __GNUC__
|
||||||
|
typedef unsigned long long png_ptruint;
|
||||||
|
# else
|
||||||
|
typedef unsigned __int64 png_ptruint;
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
typedef unsigned long png_ptruint;
|
||||||
|
# endif
|
||||||
|
# define png_constcast(type, value) ((type)(png_ptruint)(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) ||\
|
#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\
|
||||||
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
||||||
/* png.c requires the following ANSI-C constants if the conversion of
|
/* png.c requires the following ANSI-C constants if the conversion of
|
||||||
@@ -540,7 +594,8 @@
|
|||||||
/* This implicitly assumes alignment is always to a power of 2. */
|
/* This implicitly assumes alignment is always to a power of 2. */
|
||||||
#ifdef png_alignof
|
#ifdef png_alignof
|
||||||
# define png_isaligned(ptr, type)\
|
# define png_isaligned(ptr, type)\
|
||||||
((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)
|
(((type)((const char*)ptr-(const char*)0) & \
|
||||||
|
(type)(png_alignof(type)-1)) == 0)
|
||||||
#else
|
#else
|
||||||
# define png_isaligned(ptr, type) 0
|
# define png_isaligned(ptr, type) 0
|
||||||
#endif
|
#endif
|
||||||
@@ -557,92 +612,92 @@
|
|||||||
* are defined in png.h because they need to be visible to applications
|
* are defined in png.h because they need to be visible to applications
|
||||||
* that call png_set_unknown_chunk().
|
* that call png_set_unknown_chunk().
|
||||||
*/
|
*/
|
||||||
/* #define PNG_HAVE_IHDR 0x01 (defined in png.h) */
|
/* #define PNG_HAVE_IHDR 0x01U (defined in png.h) */
|
||||||
/* #define PNG_HAVE_PLTE 0x02 (defined in png.h) */
|
/* #define PNG_HAVE_PLTE 0x02U (defined in png.h) */
|
||||||
#define PNG_HAVE_IDAT 0x04
|
#define PNG_HAVE_IDAT 0x04U
|
||||||
/* #define PNG_AFTER_IDAT 0x08 (defined in png.h) */
|
/* #define PNG_AFTER_IDAT 0x08U (defined in png.h) */
|
||||||
#define PNG_HAVE_IEND 0x10
|
#define PNG_HAVE_IEND 0x10U
|
||||||
/* 0x20 (unused) */
|
/* 0x20U (unused) */
|
||||||
/* 0x40 (unused) */
|
/* 0x40U (unused) */
|
||||||
/* 0x80 (unused) */
|
/* 0x80U (unused) */
|
||||||
#define PNG_HAVE_CHUNK_HEADER 0x100
|
#define PNG_HAVE_CHUNK_HEADER 0x100U
|
||||||
#define PNG_WROTE_tIME 0x200
|
#define PNG_WROTE_tIME 0x200U
|
||||||
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
|
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U
|
||||||
#define PNG_BACKGROUND_IS_GRAY 0x800
|
#define PNG_BACKGROUND_IS_GRAY 0x800U
|
||||||
#define PNG_HAVE_PNG_SIGNATURE 0x1000
|
#define PNG_HAVE_PNG_SIGNATURE 0x1000U
|
||||||
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
|
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
|
||||||
/* 0x4000 (unused) */
|
/* 0x4000U (unused) */
|
||||||
#define PNG_IS_READ_STRUCT 0x8000 /* Else is a write struct */
|
#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */
|
||||||
|
|
||||||
/* Flags for the transformations the PNG library does on the image data */
|
/* Flags for the transformations the PNG library does on the image data */
|
||||||
#define PNG_BGR 0x0001
|
#define PNG_BGR 0x0001U
|
||||||
#define PNG_INTERLACE 0x0002
|
#define PNG_INTERLACE 0x0002U
|
||||||
#define PNG_PACK 0x0004
|
#define PNG_PACK 0x0004U
|
||||||
#define PNG_SHIFT 0x0008
|
#define PNG_SHIFT 0x0008U
|
||||||
#define PNG_SWAP_BYTES 0x0010
|
#define PNG_SWAP_BYTES 0x0010U
|
||||||
#define PNG_INVERT_MONO 0x0020
|
#define PNG_INVERT_MONO 0x0020U
|
||||||
#define PNG_QUANTIZE 0x0040
|
#define PNG_QUANTIZE 0x0040U
|
||||||
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
|
#define PNG_COMPOSE 0x0080U /* Was PNG_BACKGROUND */
|
||||||
#define PNG_BACKGROUND_EXPAND 0x0100
|
#define PNG_BACKGROUND_EXPAND 0x0100U
|
||||||
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
|
#define PNG_EXPAND_16 0x0200U /* Added to libpng 1.5.2 */
|
||||||
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
|
#define PNG_16_TO_8 0x0400U /* Becomes 'chop' in 1.5.4 */
|
||||||
#define PNG_RGBA 0x0800
|
#define PNG_RGBA 0x0800U
|
||||||
#define PNG_EXPAND 0x1000
|
#define PNG_EXPAND 0x1000U
|
||||||
#define PNG_GAMMA 0x2000
|
#define PNG_GAMMA 0x2000U
|
||||||
#define PNG_GRAY_TO_RGB 0x4000
|
#define PNG_GRAY_TO_RGB 0x4000U
|
||||||
#define PNG_FILLER 0x8000
|
#define PNG_FILLER 0x8000U
|
||||||
#define PNG_PACKSWAP 0x10000
|
#define PNG_PACKSWAP 0x10000U
|
||||||
#define PNG_SWAP_ALPHA 0x20000
|
#define PNG_SWAP_ALPHA 0x20000U
|
||||||
#define PNG_STRIP_ALPHA 0x40000
|
#define PNG_STRIP_ALPHA 0x40000U
|
||||||
#define PNG_INVERT_ALPHA 0x80000
|
#define PNG_INVERT_ALPHA 0x80000U
|
||||||
#define PNG_USER_TRANSFORM 0x100000
|
#define PNG_USER_TRANSFORM 0x100000U
|
||||||
#define PNG_RGB_TO_GRAY_ERR 0x200000
|
#define PNG_RGB_TO_GRAY_ERR 0x200000U
|
||||||
#define PNG_RGB_TO_GRAY_WARN 0x400000
|
#define PNG_RGB_TO_GRAY_WARN 0x400000U
|
||||||
#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
|
#define PNG_RGB_TO_GRAY 0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */
|
||||||
#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
|
#define PNG_ENCODE_ALPHA 0x800000U /* Added to libpng-1.5.4 */
|
||||||
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
|
#define PNG_ADD_ALPHA 0x1000000U /* Added to libpng-1.2.7 */
|
||||||
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
|
#define PNG_EXPAND_tRNS 0x2000000U /* Added to libpng-1.2.9 */
|
||||||
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
|
#define PNG_SCALE_16_TO_8 0x4000000U /* Added to libpng-1.5.4 */
|
||||||
/* 0x8000000 unused */
|
/* 0x8000000U unused */
|
||||||
/* 0x10000000 unused */
|
/* 0x10000000U unused */
|
||||||
/* 0x20000000 unused */
|
/* 0x20000000U unused */
|
||||||
/* 0x40000000 unused */
|
/* 0x40000000U unused */
|
||||||
/* Flags for png_create_struct */
|
/* Flags for png_create_struct */
|
||||||
#define PNG_STRUCT_PNG 0x0001
|
#define PNG_STRUCT_PNG 0x0001U
|
||||||
#define PNG_STRUCT_INFO 0x0002
|
#define PNG_STRUCT_INFO 0x0002U
|
||||||
|
|
||||||
/* Flags for the png_ptr->flags rather than declaring a byte for each one */
|
/* Flags for the png_ptr->flags rather than declaring a byte for each one */
|
||||||
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
|
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001U
|
||||||
#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002 /* Added to libpng-1.6.0 */
|
#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002U /* Added to libpng-1.6.0 */
|
||||||
/* 0x0004 unused */
|
/* 0x0004U unused */
|
||||||
#define PNG_FLAG_ZSTREAM_ENDED 0x0008 /* Added to libpng-1.6.0 */
|
#define PNG_FLAG_ZSTREAM_ENDED 0x0008U /* Added to libpng-1.6.0 */
|
||||||
/* 0x0010 unused */
|
/* 0x0010U unused */
|
||||||
/* 0x0020 unused */
|
/* 0x0020U unused */
|
||||||
#define PNG_FLAG_ROW_INIT 0x0040
|
#define PNG_FLAG_ROW_INIT 0x0040U
|
||||||
#define PNG_FLAG_FILLER_AFTER 0x0080
|
#define PNG_FLAG_FILLER_AFTER 0x0080U
|
||||||
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
|
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100U
|
||||||
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
|
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U
|
||||||
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
|
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U
|
||||||
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
|
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U
|
||||||
#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */
|
#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */
|
||||||
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */
|
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */
|
||||||
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */
|
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */
|
||||||
/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000 */
|
/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */
|
||||||
/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000 */
|
/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */
|
||||||
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000
|
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U
|
||||||
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000
|
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U
|
||||||
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000
|
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U
|
||||||
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */
|
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */
|
||||||
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */
|
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */
|
||||||
#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */
|
#define PNG_FLAG_APP_ERRORS_WARN 0x400000U /* Added to libpng-1.6.0 */
|
||||||
/* 0x800000 unused */
|
/* 0x800000U unused */
|
||||||
/* 0x1000000 unused */
|
/* 0x1000000U unused */
|
||||||
/* 0x2000000 unused */
|
/* 0x2000000U unused */
|
||||||
/* 0x4000000 unused */
|
/* 0x4000000U unused */
|
||||||
/* 0x8000000 unused */
|
/* 0x8000000U unused */
|
||||||
/* 0x10000000 unused */
|
/* 0x10000000U unused */
|
||||||
/* 0x20000000 unused */
|
/* 0x20000000U unused */
|
||||||
/* 0x40000000 unused */
|
/* 0x40000000U unused */
|
||||||
|
|
||||||
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
|
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
|
||||||
PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
||||||
@@ -676,6 +731,24 @@
|
|||||||
((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
|
((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
|
||||||
(( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
|
(( ((png_size_t)(width) * ((png_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
|
/* PNG_OUT_OF_RANGE returns true if value is outside the range
|
||||||
* ideal-delta..ideal+delta. Each argument is evaluated twice.
|
* ideal-delta..ideal+delta. Each argument is evaluated twice.
|
||||||
* "ideal" and "delta" should be constants, normally simple
|
* "ideal" and "delta" should be constants, normally simple
|
||||||
@@ -769,6 +842,7 @@
|
|||||||
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
||||||
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
||||||
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
||||||
|
#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_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
|
||||||
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
||||||
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
||||||
@@ -1069,6 +1143,11 @@ PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,
|
|||||||
int intent),PNG_EMPTY);
|
int intent),PNG_EMPTY);
|
||||||
#endif
|
#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
|
#ifdef PNG_WRITE_iCCP_SUPPORTED
|
||||||
PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,
|
||||||
png_const_charp name, png_const_bytep profile), PNG_EMPTY);
|
png_const_charp name, png_const_bytep profile), PNG_EMPTY);
|
||||||
@@ -1227,6 +1306,40 @@ 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);
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PNG_MIPS_MSA_OPT > 0
|
||||||
|
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_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 defined(PNG_INTEL_SSE_IMPLEMENTATION) && PNG_INTEL_SSE_IMPLEMENTATION > 0
|
#if defined(PNG_INTEL_SSE_IMPLEMENTATION) && PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop
|
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);
|
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||||
@@ -1268,7 +1381,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
|
|||||||
/* Initialize the row buffers, etc. */
|
/* Initialize the row buffers, etc. */
|
||||||
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
|
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
|
||||||
|
|
||||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
|
PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
|
||||||
PNG_EMPTY);
|
PNG_EMPTY);
|
||||||
# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
|
# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
|
||||||
@@ -1334,6 +1447,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,
|
|||||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||||
#endif
|
#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
|
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||||
PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,
|
||||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||||
@@ -1409,8 +1527,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
|
|||||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
|
||||||
png_uint_32 chunk_name),PNG_EMPTY);
|
const png_uint_32 chunk_name),PNG_EMPTY);
|
||||||
|
|
||||||
|
PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
|
||||||
|
const png_uint_32 chunk_length),PNG_EMPTY);
|
||||||
|
|
||||||
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
|
||||||
png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
|
png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
|
||||||
@@ -1545,9 +1666,11 @@ PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,
|
|||||||
/* The 'name' is used for information only */
|
/* The 'name' is used for information only */
|
||||||
|
|
||||||
/* Routines for checking parts of an ICC profile. */
|
/* 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_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,
|
||||||
png_colorspacerp colorspace, png_const_charp name,
|
png_colorspacerp colorspace, png_const_charp name,
|
||||||
png_uint_32 profile_length), PNG_EMPTY);
|
png_uint_32 profile_length), PNG_EMPTY);
|
||||||
|
#endif /* READ_iCCP */
|
||||||
PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
|
||||||
png_colorspacerp colorspace, png_const_charp name,
|
png_colorspacerp colorspace, png_const_charp name,
|
||||||
png_uint_32 profile_length,
|
png_uint_32 profile_length,
|
||||||
@@ -1970,6 +2093,12 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
|
|||||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
||||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PNG_MIPS_MSA_OPT > 0
|
||||||
|
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
|
||||||
|
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||||
|
#endif
|
||||||
|
|
||||||
# if defined(PNG_INTEL_SSE_IMPLEMENTATION) && PNG_INTEL_SSE_IMPLEMENTATION > 0
|
# if defined(PNG_INTEL_SSE_IMPLEMENTATION) && PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
|
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
|
||||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||||
|
|||||||
Vendored
+59
-34
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -175,6 +175,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
png_handle_cHRM(png_ptr, info_ptr, length);
|
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||||
#endif
|
#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
|
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||||
else if (chunk_name == png_gAMA)
|
else if (chunk_name == png_gAMA)
|
||||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||||
@@ -359,9 +364,9 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
|
|||||||
|
|
||||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||||
{
|
{
|
||||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1);
|
||||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3);
|
||||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5);
|
||||||
png_uint_32 red = (s0 + s1 + 65536) & 0xffff;
|
png_uint_32 red = (s0 + s1 + 65536) & 0xffff;
|
||||||
png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;
|
png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;
|
||||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||||
@@ -534,6 +539,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||||||
png_error(png_ptr, "Invalid attempt to read row data");
|
png_error(png_ptr, "Invalid attempt to read row data");
|
||||||
|
|
||||||
/* Fill the row with IDAT 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);
|
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_NONE)
|
||||||
@@ -842,6 +848,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
png_handle_cHRM(png_ptr, info_ptr, length);
|
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||||
#endif
|
#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
|
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||||
else if (chunk_name == png_gAMA)
|
else if (chunk_name == png_gAMA)
|
||||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||||
@@ -1393,7 +1404,9 @@ png_image_read_header(png_voidp argument)
|
|||||||
png_structrp png_ptr = image->opaque->png_ptr;
|
png_structrp png_ptr = image->opaque->png_ptr;
|
||||||
png_inforp info_ptr = image->opaque->info_ptr;
|
png_inforp info_ptr = image->opaque->info_ptr;
|
||||||
|
|
||||||
|
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
png_set_benign_errors(png_ptr, 1/*warn*/);
|
png_set_benign_errors(png_ptr, 1/*warn*/);
|
||||||
|
#endif
|
||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
/* Do this the fast way; just read directly out of png_struct. */
|
/* Do this the fast way; just read directly out of png_struct. */
|
||||||
@@ -1431,7 +1444,7 @@ png_image_read_header(png_voidp argument)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_PALETTE:
|
case PNG_COLOR_TYPE_PALETTE:
|
||||||
cmap_entries = png_ptr->num_palette;
|
cmap_entries = (png_uint_32)png_ptr->num_palette;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1932,6 +1945,7 @@ png_create_colormap_entry(png_image_read_control *display,
|
|||||||
{
|
{
|
||||||
case 4:
|
case 4:
|
||||||
entry[afirst ? 0 : 3] = (png_byte)alpha;
|
entry[afirst ? 0 : 3] = (png_byte)alpha;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 3:
|
case 3:
|
||||||
entry[afirst + (2 ^ bgr)] = (png_byte)blue;
|
entry[afirst + (2 ^ bgr)] = (png_byte)blue;
|
||||||
entry[afirst + 1] = (png_byte)green;
|
entry[afirst + 1] = (png_byte)green;
|
||||||
@@ -1940,6 +1954,7 @@ png_create_colormap_entry(png_image_read_control *display,
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
entry[1 ^ afirst] = (png_byte)alpha;
|
entry[1 ^ afirst] = (png_byte)alpha;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 1:
|
case 1:
|
||||||
entry[afirst] = (png_byte)green;
|
entry[afirst] = (png_byte)green;
|
||||||
break;
|
break;
|
||||||
@@ -1966,7 +1981,7 @@ make_gray_file_colormap(png_image_read_control *display)
|
|||||||
for (i=0; i<256; ++i)
|
for (i=0; i<256; ++i)
|
||||||
png_create_colormap_entry(display, i, i, i, i, 255, P_FILE);
|
png_create_colormap_entry(display, i, i, i, i, 255, P_FILE);
|
||||||
|
|
||||||
return i;
|
return (int)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -1977,7 +1992,7 @@ make_gray_colormap(png_image_read_control *display)
|
|||||||
for (i=0; i<256; ++i)
|
for (i=0; i<256; ++i)
|
||||||
png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB);
|
png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB);
|
||||||
|
|
||||||
return i;
|
return (int)i;
|
||||||
}
|
}
|
||||||
#define PNG_GRAY_COLORMAP_ENTRIES 256
|
#define PNG_GRAY_COLORMAP_ENTRIES 256
|
||||||
|
|
||||||
@@ -2031,7 +2046,7 @@ make_ga_colormap(png_image_read_control *display)
|
|||||||
P_sRGB);
|
P_sRGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return (int)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PNG_GA_COLORMAP_ENTRIES 256
|
#define PNG_GA_COLORMAP_ENTRIES 256
|
||||||
@@ -2056,7 +2071,7 @@ make_rgb_colormap(png_image_read_control *display)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return (int)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PNG_RGB_COLORMAP_ENTRIES 216
|
#define PNG_RGB_COLORMAP_ENTRIES 216
|
||||||
@@ -2249,7 +2264,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
|
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
|
||||||
png_error(png_ptr, "gray[16] color-map: too few entries");
|
png_error(png_ptr, "gray[16] color-map: too few entries");
|
||||||
|
|
||||||
cmap_entries = make_gray_colormap(display);
|
cmap_entries = (unsigned int)make_gray_colormap(display);
|
||||||
|
|
||||||
if (png_ptr->num_trans > 0)
|
if (png_ptr->num_trans > 0)
|
||||||
{
|
{
|
||||||
@@ -2347,7 +2362,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
|
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
|
||||||
png_error(png_ptr, "gray+alpha color-map: too few entries");
|
png_error(png_ptr, "gray+alpha color-map: too few entries");
|
||||||
|
|
||||||
cmap_entries = make_ga_colormap(display);
|
cmap_entries = (unsigned int)make_ga_colormap(display);
|
||||||
|
|
||||||
background_index = PNG_CMAP_GA_BACKGROUND;
|
background_index = PNG_CMAP_GA_BACKGROUND;
|
||||||
output_processing = PNG_CMAP_GA;
|
output_processing = PNG_CMAP_GA;
|
||||||
@@ -2381,7 +2396,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
|
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
|
||||||
png_error(png_ptr, "gray-alpha color-map: too few entries");
|
png_error(png_ptr, "gray-alpha color-map: too few entries");
|
||||||
|
|
||||||
cmap_entries = make_gray_colormap(display);
|
cmap_entries = (unsigned int)make_gray_colormap(display);
|
||||||
|
|
||||||
if (output_encoding == P_LINEAR)
|
if (output_encoding == P_LINEAR)
|
||||||
{
|
{
|
||||||
@@ -2520,7 +2535,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
|
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
|
||||||
png_error(png_ptr, "rgb[ga] color-map: too few entries");
|
png_error(png_ptr, "rgb[ga] color-map: too few entries");
|
||||||
|
|
||||||
cmap_entries = make_ga_colormap(display);
|
cmap_entries = (unsigned int)make_ga_colormap(display);
|
||||||
background_index = PNG_CMAP_GA_BACKGROUND;
|
background_index = PNG_CMAP_GA_BACKGROUND;
|
||||||
output_processing = PNG_CMAP_GA;
|
output_processing = PNG_CMAP_GA;
|
||||||
}
|
}
|
||||||
@@ -2546,12 +2561,12 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
png_ptr->num_trans > 0) &&
|
png_ptr->num_trans > 0) &&
|
||||||
png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
|
png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
|
||||||
{
|
{
|
||||||
cmap_entries = make_gray_file_colormap(display);
|
cmap_entries = (unsigned int)make_gray_file_colormap(display);
|
||||||
data_encoding = P_FILE;
|
data_encoding = P_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
cmap_entries = make_gray_colormap(display);
|
cmap_entries = (unsigned int)make_gray_colormap(display);
|
||||||
|
|
||||||
/* But if the input has alpha or transparency it must be removed
|
/* But if the input has alpha or transparency it must be removed
|
||||||
*/
|
*/
|
||||||
@@ -2639,7 +2654,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
|
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
|
||||||
png_error(png_ptr, "rgb+alpha color-map: too few entries");
|
png_error(png_ptr, "rgb+alpha color-map: too few entries");
|
||||||
|
|
||||||
cmap_entries = make_rgb_colormap(display);
|
cmap_entries = (unsigned int)make_rgb_colormap(display);
|
||||||
|
|
||||||
/* Add a transparent entry. */
|
/* Add a transparent entry. */
|
||||||
png_create_colormap_entry(display, cmap_entries, 255, 255,
|
png_create_colormap_entry(display, cmap_entries, 255, 255,
|
||||||
@@ -2688,7 +2703,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
|
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
|
||||||
png_error(png_ptr, "rgb-alpha color-map: too few entries");
|
png_error(png_ptr, "rgb-alpha color-map: too few entries");
|
||||||
|
|
||||||
cmap_entries = make_rgb_colormap(display);
|
cmap_entries = (unsigned int)make_rgb_colormap(display);
|
||||||
|
|
||||||
png_create_colormap_entry(display, cmap_entries, back_r,
|
png_create_colormap_entry(display, cmap_entries, back_r,
|
||||||
back_g, back_b, 0/*unused*/, output_encoding);
|
back_g, back_b, 0/*unused*/, output_encoding);
|
||||||
@@ -2773,7 +2788,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries)
|
if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries)
|
||||||
png_error(png_ptr, "rgb color-map: too few entries");
|
png_error(png_ptr, "rgb color-map: too few entries");
|
||||||
|
|
||||||
cmap_entries = make_rgb_colormap(display);
|
cmap_entries = (unsigned int)make_rgb_colormap(display);
|
||||||
output_processing = PNG_CMAP_RGB;
|
output_processing = PNG_CMAP_RGB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2797,11 +2812,11 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
|
|
||||||
output_processing = PNG_CMAP_NONE;
|
output_processing = PNG_CMAP_NONE;
|
||||||
data_encoding = P_FILE; /* Don't change from color-map indices */
|
data_encoding = P_FILE; /* Don't change from color-map indices */
|
||||||
cmap_entries = png_ptr->num_palette;
|
cmap_entries = (unsigned int)png_ptr->num_palette;
|
||||||
if (cmap_entries > 256)
|
if (cmap_entries > 256)
|
||||||
cmap_entries = 256;
|
cmap_entries = 256;
|
||||||
|
|
||||||
if (cmap_entries > image->colormap_entries)
|
if (cmap_entries > (unsigned int)image->colormap_entries)
|
||||||
png_error(png_ptr, "palette color-map: too few entries");
|
png_error(png_ptr, "palette color-map: too few entries");
|
||||||
|
|
||||||
for (i=0; i < cmap_entries; ++i)
|
for (i=0; i < cmap_entries; ++i)
|
||||||
@@ -2913,7 +2928,7 @@ png_image_read_colormap(png_voidp argument)
|
|||||||
png_error(png_ptr, "bad background index (internal error)");
|
png_error(png_ptr, "bad background index (internal error)");
|
||||||
}
|
}
|
||||||
|
|
||||||
display->colormap_processing = output_processing;
|
display->colormap_processing = (int)output_processing;
|
||||||
|
|
||||||
return 1/*ok*/;
|
return 1/*ok*/;
|
||||||
}
|
}
|
||||||
@@ -3177,8 +3192,7 @@ png_image_read_colormapped(png_voidp argument)
|
|||||||
image->colormap_entries == 244 /* 216 + 1 + 27 */)
|
image->colormap_entries == 244 /* 216 + 1 + 27 */)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* goto bad_output; */
|
goto bad_output;
|
||||||
/* FALL THROUGH */
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
bad_output:
|
bad_output:
|
||||||
@@ -3222,14 +3236,14 @@ png_image_read_colormapped(png_voidp argument)
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_alloc_size_t row_bytes = display->row_bytes;
|
png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
|
||||||
|
|
||||||
while (--passes >= 0)
|
while (--passes >= 0)
|
||||||
{
|
{
|
||||||
png_uint_32 y = image->height;
|
png_uint_32 y = image->height;
|
||||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||||
|
|
||||||
while (y-- > 0)
|
for (; y > 0; --y)
|
||||||
{
|
{
|
||||||
png_read_row(png_ptr, row, NULL);
|
png_read_row(png_ptr, row, NULL);
|
||||||
row += row_bytes;
|
row += row_bytes;
|
||||||
@@ -3557,8 +3571,9 @@ png_image_read_background(png_voidp argument)
|
|||||||
* stride which was multiplied by 2 (below) to get row_bytes.
|
* stride which was multiplied by 2 (below) to get row_bytes.
|
||||||
*/
|
*/
|
||||||
ptrdiff_t step_row = display->row_bytes / 2;
|
ptrdiff_t step_row = display->row_bytes / 2;
|
||||||
int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
unsigned int preserve_alpha = (image->format &
|
||||||
unsigned int outchannels = 1+preserve_alpha;
|
PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||||
|
unsigned int outchannels = 1U+preserve_alpha;
|
||||||
int swap_alpha = 0;
|
int swap_alpha = 0;
|
||||||
|
|
||||||
# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||||
@@ -3745,6 +3760,12 @@ png_image_read_direct(png_voidp argument)
|
|||||||
output_gamma = PNG_DEFAULT_sRGB;
|
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
|
/* If 'do_local_background' is set check for the presence of gamma
|
||||||
* correction; this is part of the work-round for the libpng bug
|
* correction; this is part of the work-round for the libpng bug
|
||||||
* described above.
|
* described above.
|
||||||
@@ -3970,6 +3991,10 @@ png_image_read_direct(png_voidp argument)
|
|||||||
else if (do_local_compose != 0) /* internal error */
|
else if (do_local_compose != 0) /* internal error */
|
||||||
png_error(png_ptr, "png_image_read: alpha channel lost");
|
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)
|
if (info_ptr->bit_depth == 16)
|
||||||
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
||||||
|
|
||||||
@@ -4055,14 +4080,14 @@ png_image_read_direct(png_voidp argument)
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
png_alloc_size_t row_bytes = display->row_bytes;
|
png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
|
||||||
|
|
||||||
while (--passes >= 0)
|
while (--passes >= 0)
|
||||||
{
|
{
|
||||||
png_uint_32 y = image->height;
|
png_uint_32 y = image->height;
|
||||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||||
|
|
||||||
while (y-- > 0)
|
for (; y > 0; --y)
|
||||||
{
|
{
|
||||||
png_read_row(png_ptr, row, NULL);
|
png_read_row(png_ptr, row, NULL);
|
||||||
row += row_bytes;
|
row += row_bytes;
|
||||||
@@ -4091,7 +4116,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||||||
* bits; this is just to verify that the 'row_stride' argument can be
|
* bits; this is just to verify that the 'row_stride' argument can be
|
||||||
* represented.
|
* represented.
|
||||||
*/
|
*/
|
||||||
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
|
if (image->width <= 0x7fffffffU/channels) /* no overflow */
|
||||||
{
|
{
|
||||||
png_uint_32 check;
|
png_uint_32 check;
|
||||||
const png_uint_32 png_row_stride = image->width * channels;
|
const png_uint_32 png_row_stride = image->width * channels;
|
||||||
@@ -4100,10 +4125,10 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||||||
row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||||
|
|
||||||
if (row_stride < 0)
|
if (row_stride < 0)
|
||||||
check = -row_stride;
|
check = (png_uint_32)(-row_stride);
|
||||||
|
|
||||||
else
|
else
|
||||||
check = row_stride;
|
check = (png_uint_32)row_stride;
|
||||||
|
|
||||||
/* This verifies 'check', the absolute value of the actual stride
|
/* This verifies 'check', the absolute value of the actual stride
|
||||||
* passed in and detects overflow in the application calculation (i.e.
|
* passed in and detects overflow in the application calculation (i.e.
|
||||||
@@ -4128,7 +4153,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||||||
* accomodated on 64-bit systems.
|
* accomodated on 64-bit systems.
|
||||||
*/
|
*/
|
||||||
if (image->height <=
|
if (image->height <=
|
||||||
0xFFFFFFFFU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check)
|
0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check)
|
||||||
{
|
{
|
||||||
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
|
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
|
||||||
(image->colormap_entries > 0 && colormap != NULL))
|
(image->colormap_entries > 0 && colormap != NULL))
|
||||||
|
|||||||
Vendored
+37
-27
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -49,6 +49,7 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
|
|||||||
case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */
|
case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */
|
||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
"Can't discard critical data on CRC error");
|
"Can't discard critical data on CRC error");
|
||||||
|
/* FALLTHROUGH */
|
||||||
case PNG_CRC_ERROR_QUIT: /* Error/quit */
|
case PNG_CRC_ERROR_QUIT: /* Error/quit */
|
||||||
|
|
||||||
case PNG_CRC_DEFAULT:
|
case PNG_CRC_DEFAULT:
|
||||||
@@ -429,7 +430,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
png_ptr->quantize_index[i] = (png_byte)i;
|
png_ptr->quantize_index[i] = (png_byte)i;
|
||||||
}
|
}
|
||||||
@@ -446,7 +447,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
|
|
||||||
/* Initialize an array to sort colors */
|
/* Initialize an array to sort colors */
|
||||||
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||||
|
|
||||||
/* Initialize the quantize_sort array */
|
/* Initialize the quantize_sort array */
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
@@ -580,9 +581,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
|
|
||||||
/* Initialize palette index arrays */
|
/* Initialize palette index arrays */
|
||||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
(png_alloc_size_t)((png_uint_32)num_palette *
|
||||||
|
(sizeof (png_byte))));
|
||||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
(png_alloc_size_t)((png_uint_32)num_palette *
|
||||||
|
(sizeof (png_byte))));
|
||||||
|
|
||||||
/* Initialize the sort array */
|
/* Initialize the sort array */
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
@@ -591,7 +594,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
png_ptr->palette_to_index[i] = (png_byte)i;
|
png_ptr->palette_to_index[i] = (png_byte)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
|
hash = (png_dsortpp)png_calloc(png_ptr, (png_alloc_size_t)(769 *
|
||||||
(sizeof (png_dsortp))));
|
(sizeof (png_dsortp))));
|
||||||
|
|
||||||
num_new_palette = num_palette;
|
num_new_palette = num_palette;
|
||||||
@@ -622,7 +625,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
{
|
{
|
||||||
|
|
||||||
t = (png_dsortp)png_malloc_warn(png_ptr,
|
t = (png_dsortp)png_malloc_warn(png_ptr,
|
||||||
(png_uint_32)(sizeof (png_dsort)));
|
(png_alloc_size_t)(sizeof (png_dsort)));
|
||||||
|
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
break;
|
break;
|
||||||
@@ -747,9 +750,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||||
|
|
||||||
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
||||||
(png_uint_32)(num_entries * (sizeof (png_byte))));
|
(png_alloc_size_t)(num_entries * (sizeof (png_byte))));
|
||||||
|
|
||||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries *
|
||||||
(sizeof (png_byte))));
|
(sizeof (png_byte))));
|
||||||
|
|
||||||
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
||||||
@@ -1253,7 +1256,7 @@ png_init_rgb_transformations(png_structrp png_ptr)
|
|||||||
default:
|
default:
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
/* FALL THROUGH (Already 8 bits) */
|
/* FALLTHROUGH */ /* (Already 8 bits) */
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
/* Already a full 16 bits */
|
/* Already a full 16 bits */
|
||||||
@@ -2150,7 +2153,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
|||||||
{
|
{
|
||||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
|
png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||||
png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
|
png_uint_32 shift = 7U - ((row_width + 7U) & 0x07);
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
*dp = (png_byte)((*sp >> shift) & 0x01);
|
*dp = (png_byte)((*sp >> shift) & 0x01);
|
||||||
@@ -2174,7 +2177,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
|||||||
|
|
||||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
|
png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||||
png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1);
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
*dp = (png_byte)((*sp >> shift) & 0x03);
|
*dp = (png_byte)((*sp >> shift) & 0x03);
|
||||||
@@ -2197,7 +2200,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
|||||||
{
|
{
|
||||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
|
png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||||
png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2);
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
*dp = (png_byte)((*sp >> shift) & 0x0f);
|
*dp = (png_byte)((*sp >> shift) & 0x0f);
|
||||||
@@ -2934,7 +2937,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
|||||||
* using the equation given in Poynton's ColorFAQ of 1998-01-04 at
|
* 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
|
* <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008 but
|
||||||
* versions dated 1998 through November 2002 have been archived at
|
* versions dated 1998 through November 2002 have been archived at
|
||||||
* http://web.archive.org/web/20000816232553/http://www.inforamp.net/
|
* https://web.archive.org/web/20000816232553/www.inforamp.net/
|
||||||
* ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
|
* ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
|
||||||
* Charles Poynton poynton at poynton.com
|
* Charles Poynton poynton at poynton.com
|
||||||
*
|
*
|
||||||
@@ -3223,7 +3226,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
|
unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
|
||||||
tmp |= png_ptr->background.gray << shift;
|
tmp |=
|
||||||
|
(unsigned int)(png_ptr->background.gray << shift);
|
||||||
*sp = (png_byte)(tmp & 0xff);
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3252,7 +3256,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||||
tmp |= png_ptr->background.gray << shift;
|
tmp |=
|
||||||
|
(unsigned int)png_ptr->background.gray << shift;
|
||||||
*sp = (png_byte)(tmp & 0xff);
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3262,7 +3267,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||||||
unsigned int g = (gamma_table [p | (p << 2) |
|
unsigned int g = (gamma_table [p | (p << 2) |
|
||||||
(p << 4) | (p << 6)] >> 6) & 0x03;
|
(p << 4) | (p << 6)] >> 6) & 0x03;
|
||||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||||
tmp |= g << shift;
|
tmp |= (unsigned int)(g << shift);
|
||||||
*sp = (png_byte)(tmp & 0xff);
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3288,7 +3293,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||||
tmp |= png_ptr->background.gray << shift;
|
tmp |=
|
||||||
|
(unsigned int)png_ptr->background.gray << shift;
|
||||||
*sp = (png_byte)(tmp & 0xff);
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3318,7 +3324,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||||
tmp |= png_ptr->background.gray << shift;
|
tmp |=
|
||||||
|
(unsigned int)(png_ptr->background.gray << shift);
|
||||||
*sp = (png_byte)(tmp & 0xff);
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3328,7 +3335,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||||||
unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
|
unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
|
||||||
0x0f;
|
0x0f;
|
||||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||||
tmp |= g << shift;
|
tmp |= (unsigned int)(g << shift);
|
||||||
*sp = (png_byte)(tmp & 0xff);
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3354,7 +3361,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||||
tmp |= png_ptr->background.gray << shift;
|
tmp |=
|
||||||
|
(unsigned int)(png_ptr->background.gray << shift);
|
||||||
*sp = (png_byte)(tmp & 0xff);
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4297,7 +4305,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
|||||||
if (num_trans > 0)
|
if (num_trans > 0)
|
||||||
{
|
{
|
||||||
sp = row + (png_size_t)row_width - 1;
|
sp = row + (png_size_t)row_width - 1;
|
||||||
dp = row + (png_size_t)(row_width << 2) - 1;
|
dp = row + ((png_size_t)row_width << 2) - 1;
|
||||||
|
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
@@ -4458,7 +4466,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
{
|
{
|
||||||
gray = gray & 0xff;
|
gray = gray & 0xff;
|
||||||
sp = row + (png_size_t)row_width - 1;
|
sp = row + (png_size_t)row_width - 1;
|
||||||
dp = row + (png_size_t)(row_width << 1) - 1;
|
dp = row + ((png_size_t)row_width << 1) - 1;
|
||||||
|
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
@@ -4514,7 +4522,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
png_byte green = (png_byte)(trans_color->green & 0xff);
|
png_byte green = (png_byte)(trans_color->green & 0xff);
|
||||||
png_byte blue = (png_byte)(trans_color->blue & 0xff);
|
png_byte blue = (png_byte)(trans_color->blue & 0xff);
|
||||||
sp = row + (png_size_t)row_info->rowbytes - 1;
|
sp = row + (png_size_t)row_info->rowbytes - 1;
|
||||||
dp = row + (png_size_t)(row_width << 2) - 1;
|
dp = row + ((png_size_t)row_width << 2) - 1;
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
|
if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
|
||||||
@@ -4537,7 +4545,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
png_byte green_low = (png_byte)(trans_color->green & 0xff);
|
png_byte green_low = (png_byte)(trans_color->green & 0xff);
|
||||||
png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
|
png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
|
||||||
sp = row + row_info->rowbytes - 1;
|
sp = row + row_info->rowbytes - 1;
|
||||||
dp = row + (png_size_t)(row_width << 3) - 1;
|
dp = row + ((png_size_t)row_width << 3) - 1;
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
if (*(sp - 5) == red_high &&
|
if (*(sp - 5) == red_high &&
|
||||||
@@ -4596,7 +4604,9 @@ png_do_expand_16(png_row_infop row_info, png_bytep row)
|
|||||||
png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */
|
png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */
|
||||||
png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
|
png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
|
||||||
while (dp > sp)
|
while (dp > sp)
|
||||||
dp[-2] = dp[-1] = *--sp, dp -= 2;
|
{
|
||||||
|
dp[-2] = dp[-1] = *--sp; dp -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
row_info->rowbytes *= 2;
|
row_info->rowbytes *= 2;
|
||||||
row_info->bit_depth = 16;
|
row_info->bit_depth = 16;
|
||||||
|
|||||||
Vendored
+222
-92
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngrutil.c - utilities to read a PNG file
|
/* pngrutil.c - utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -86,7 +86,7 @@ png_get_int_32)(png_const_bytep buf)
|
|||||||
{
|
{
|
||||||
png_uint_32 uval = png_get_uint_32(buf);
|
png_uint_32 uval = png_get_uint_32(buf);
|
||||||
if ((uval & 0x80000000) == 0) /* non-negative */
|
if ((uval & 0x80000000) == 0) /* non-negative */
|
||||||
return uval;
|
return (png_int_32)uval;
|
||||||
|
|
||||||
uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
|
uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
|
||||||
if ((uval & 0x80000000) == 0) /* no overflow */
|
if ((uval & 0x80000000) == 0) /* no overflow */
|
||||||
@@ -181,6 +181,9 @@ png_read_chunk_header(png_structrp png_ptr)
|
|||||||
/* Check to see if chunk name is valid. */
|
/* Check to see if chunk name is valid. */
|
||||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
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
|
#ifdef PNG_IO_STATE_SUPPORTED
|
||||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
|
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
|
||||||
#endif
|
#endif
|
||||||
@@ -311,6 +314,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
|||||||
|
|
||||||
if (buffer != NULL)
|
if (buffer != NULL)
|
||||||
{
|
{
|
||||||
|
memset(buffer, 0, new_size); /* just in case */
|
||||||
png_ptr->read_buffer = buffer;
|
png_ptr->read_buffer = buffer;
|
||||||
png_ptr->read_buffer_size = new_size;
|
png_ptr->read_buffer_size = new_size;
|
||||||
}
|
}
|
||||||
@@ -370,11 +374,10 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int ret; /* zlib return code */
|
int ret; /* zlib return code */
|
||||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
|
int window_bits = 0;
|
||||||
|
|
||||||
# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW)
|
# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW)
|
||||||
int window_bits;
|
|
||||||
|
|
||||||
if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
|
if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
|
||||||
PNG_OPTION_ON)
|
PNG_OPTION_ON)
|
||||||
{
|
{
|
||||||
@@ -384,14 +387,12 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window_bits = 0;
|
|
||||||
png_ptr->zstream_start = 1;
|
png_ptr->zstream_start = 1;
|
||||||
}
|
}
|
||||||
# else
|
|
||||||
# define window_bits 0
|
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
#endif /* ZLIB_VERNUM >= 0x1240 */
|
||||||
|
|
||||||
/* Set this for safety, just in case the previous owner left pointers to
|
/* Set this for safety, just in case the previous owner left pointers to
|
||||||
* memory allocations.
|
* memory allocations.
|
||||||
*/
|
*/
|
||||||
@@ -402,25 +403,32 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||||||
|
|
||||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
||||||
{
|
{
|
||||||
#if PNG_ZLIB_VERNUM < 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
ret = inflateReset(&png_ptr->zstream);
|
|
||||||
#else
|
|
||||||
ret = inflateReset2(&png_ptr->zstream, window_bits);
|
ret = inflateReset2(&png_ptr->zstream, window_bits);
|
||||||
|
#else
|
||||||
|
ret = inflateReset(&png_ptr->zstream);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if PNG_ZLIB_VERNUM < 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
ret = inflateInit(&png_ptr->zstream);
|
|
||||||
#else
|
|
||||||
ret = inflateInit2(&png_ptr->zstream, window_bits);
|
ret = inflateInit2(&png_ptr->zstream, window_bits);
|
||||||
|
#else
|
||||||
|
ret = inflateInit(&png_ptr->zstream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret == Z_OK)
|
if (ret == Z_OK)
|
||||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
|
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ZLIB_VERNUM >= 0x1290 && \
|
||||||
|
defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
|
||||||
|
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)
|
if (ret == Z_OK)
|
||||||
png_ptr->zowner = owner;
|
png_ptr->zowner = owner;
|
||||||
|
|
||||||
@@ -435,7 +443,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
/* Handle the start of the inflate stream if we called inflateInit2(strm,0);
|
/* 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
|
* 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
|
* certain circumstances, libpng may end up displaying an invalid image, in
|
||||||
@@ -461,6 +469,7 @@ png_zlib_inflate(png_structrp png_ptr, int flush)
|
|||||||
#endif /* Zlib >= 1.2.4 */
|
#endif /* Zlib >= 1.2.4 */
|
||||||
|
|
||||||
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
#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
|
/* 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
|
* 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
|
* set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must
|
||||||
@@ -590,7 +599,6 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED)
|
|
||||||
/*
|
/*
|
||||||
* Decompress trailing data in a chunk. The assumption is that read_buffer
|
* 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
|
* points at an allocated area holding the contents of a chunk with a
|
||||||
@@ -666,6 +674,8 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||||||
|
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
|
memset(text, 0, buffer_size);
|
||||||
|
|
||||||
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
|
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
|
||||||
png_ptr->read_buffer + prefix_size, &lzsize,
|
png_ptr->read_buffer + prefix_size, &lzsize,
|
||||||
text + prefix_size, newlength);
|
text + prefix_size, newlength);
|
||||||
@@ -729,8 +739,6 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||||||
{
|
{
|
||||||
/* inflateReset failed, store the error message */
|
/* inflateReset failed, store the error message */
|
||||||
png_zstream_error(png_ptr, ret);
|
png_zstream_error(png_ptr, ret);
|
||||||
|
|
||||||
if (ret == Z_STREAM_END)
|
|
||||||
ret = PNG_UNEXPECTED_ZLIB_RETURN;
|
ret = PNG_UNEXPECTED_ZLIB_RETURN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -823,7 +831,7 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
|
|||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* READ_iCCP */
|
||||||
|
|
||||||
/* Read and check the IDHR chunk */
|
/* Read and check the IDHR chunk */
|
||||||
|
|
||||||
@@ -1011,7 +1019,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
png_crc_finish(png_ptr, (int) length - num * 3);
|
png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
||||||
@@ -1373,11 +1381,13 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
* chunk is just ignored, so does not invalidate the color space. An
|
* 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
|
* 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.
|
* and only clear them in they were not set before and all the tests pass.
|
||||||
* The minimum 'deflate' stream is assumed to be just the 2 byte header and
|
|
||||||
* 4 byte checksum. The keyword must be at least one character and there is
|
|
||||||
* a terminator (0) byte and the compression method.
|
|
||||||
*/
|
*/
|
||||||
if (length < 9)
|
|
||||||
|
/* 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_crc_finish(png_ptr, length);
|
||||||
png_chunk_benign_error(png_ptr, "too short");
|
png_chunk_benign_error(png_ptr, "too short");
|
||||||
@@ -1409,6 +1419,16 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
png_crc_read(png_ptr, (png_bytep)keyword, read_length);
|
png_crc_read(png_ptr, (png_bytep)keyword, read_length);
|
||||||
length -= 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;
|
keyword_length = 0;
|
||||||
while (keyword_length < 80 && keyword_length < read_length &&
|
while (keyword_length < 80 && keyword_length < read_length &&
|
||||||
keyword[keyword_length] != 0)
|
keyword[keyword_length] != 0)
|
||||||
@@ -1427,7 +1447,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
|
|
||||||
if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK)
|
if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK)
|
||||||
{
|
{
|
||||||
Byte profile_header[132];
|
Byte profile_header[132]={0};
|
||||||
Byte local_buffer[PNG_INFLATE_BUF_SIZE];
|
Byte local_buffer[PNG_INFLATE_BUF_SIZE];
|
||||||
png_alloc_size_t size = (sizeof profile_header);
|
png_alloc_size_t size = (sizeof profile_header);
|
||||||
|
|
||||||
@@ -1457,7 +1477,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
/* Now read the tag table; a variable size buffer is
|
/* Now read the tag table; a variable size buffer is
|
||||||
* needed at this point, allocate one for the whole
|
* needed at this point, allocate one for the whole
|
||||||
* profile. The header check has already validated
|
* profile. The header check has already validated
|
||||||
* that none of these stuff will overflow.
|
* that none of this stuff will overflow.
|
||||||
*/
|
*/
|
||||||
const png_uint_32 tag_count = png_get_uint_32(
|
const png_uint_32 tag_count = png_get_uint_32(
|
||||||
profile_header+128);
|
profile_header+128);
|
||||||
@@ -1564,19 +1584,11 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (errmsg == NULL)
|
||||||
else if (size > 0)
|
|
||||||
errmsg = "truncated";
|
|
||||||
|
|
||||||
#ifndef __COVERITY__
|
|
||||||
else
|
|
||||||
errmsg = png_ptr->zstream.msg;
|
errmsg = png_ptr->zstream.msg;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else png_icc_check_tag_table output an error */
|
/* else png_icc_check_tag_table output an error */
|
||||||
}
|
}
|
||||||
|
|
||||||
else /* profile truncated */
|
else /* profile truncated */
|
||||||
errmsg = png_ptr->zstream.msg;
|
errmsg = png_ptr->zstream.msg;
|
||||||
}
|
}
|
||||||
@@ -1717,13 +1729,13 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
data_length = length - (png_uint_32)(entry_start - buffer);
|
data_length = length - (png_uint_32)(entry_start - buffer);
|
||||||
|
|
||||||
/* Integrity-check the data length */
|
/* Integrity-check the data length */
|
||||||
if ((data_length % entry_size) != 0)
|
if ((data_length % (unsigned int)entry_size) != 0)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "sPLT chunk has bad length");
|
png_warning(png_ptr, "sPLT chunk has bad length");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl = (png_int_32)(data_length / entry_size);
|
dl = (png_uint_32)(data_length / (unsigned int)entry_size);
|
||||||
max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry));
|
max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry));
|
||||||
|
|
||||||
if (dl > max_dl)
|
if (dl > max_dl)
|
||||||
@@ -1732,10 +1744,10 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_palette.nentries = (png_int_32)(data_length / entry_size);
|
new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size);
|
||||||
|
|
||||||
new_palette.entries = (png_sPLT_entryp)png_malloc_warn(
|
new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
|
||||||
png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry)));
|
(png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry)));
|
||||||
|
|
||||||
if (new_palette.entries == NULL)
|
if (new_palette.entries == NULL)
|
||||||
{
|
{
|
||||||
@@ -2005,6 +2017,69 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
}
|
}
|
||||||
#endif
|
#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 && buf[0] != 'M' && buf[0] != 'I'
|
||||||
|
&& info_ptr->eXIf_buf[0] != buf[0])
|
||||||
|
{
|
||||||
|
png_crc_finish(png_ptr, length);
|
||||||
|
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)
|
||||||
|
return;
|
||||||
|
|
||||||
|
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
|
#ifdef PNG_READ_hIST_SUPPORTED
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
@@ -2533,6 +2608,9 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
||||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
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*/);
|
buffer = png_read_buffer(png_ptr, length, 2/*silent*/);
|
||||||
|
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
@@ -2579,9 +2657,13 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
{
|
{
|
||||||
png_text text;
|
png_text text;
|
||||||
|
|
||||||
/* It worked; png_ptr->read_buffer now looks like a tEXt chunk except
|
if (png_ptr->read_buffer == NULL)
|
||||||
* for the extra compression type byte and the fact that it isn't
|
errmsg="Read failure in png_handle_zTXt";
|
||||||
* necessarily '\0' terminated.
|
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 = png_ptr->read_buffer;
|
||||||
buffer[uncompressed_length+(keyword_length+2)] = 0;
|
buffer[uncompressed_length+(keyword_length+2)] = 0;
|
||||||
@@ -2597,6 +2679,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
|
if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
|
||||||
errmsg = "insufficient memory";
|
errmsg = "insufficient memory";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
errmsg = png_ptr->zstream.msg;
|
errmsg = png_ptr->zstream.msg;
|
||||||
@@ -3031,20 +3114,58 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_check_chunk_name(png_structrp png_ptr, png_uint_32 chunk_name)
|
png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
png_uint_32 cn=chunk_name;
|
||||||
|
|
||||||
png_debug(1, "in png_check_chunk_name");
|
png_debug(1, "in png_check_chunk_name");
|
||||||
|
|
||||||
for (i=1; i<=4; ++i)
|
for (i=1; i<=4; ++i)
|
||||||
{
|
{
|
||||||
int c = chunk_name & 0xff;
|
int c = cn & 0xff;
|
||||||
|
|
||||||
if (c < 65 || c > 122 || (c > 90 && c < 97))
|
if (c < 65 || c > 122 || (c > 90 && c < 97))
|
||||||
png_chunk_error(png_ptr, "invalid chunk type");
|
png_chunk_error(png_ptr, "invalid chunk type");
|
||||||
|
|
||||||
chunk_name >>= 8;
|
cn >>= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void /* PRIVATE */
|
||||||
|
png_check_chunk_length(png_const_structrp png_ptr, const 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
|
||||||
|
if (png_ptr->chunk_name == png_IDAT)
|
||||||
|
{
|
||||||
|
png_alloc_size_t idat_limit = PNG_UINT_31_MAX;
|
||||||
|
size_t row_factor =
|
||||||
|
(png_ptr->width * 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_chunk_error(png_ptr, "chunk data is too large");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3099,7 +3220,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
|||||||
# ifdef PNG_READ_PACKSWAP_SUPPORTED
|
# ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||||
/* little-endian byte */
|
/* little-endian byte */
|
||||||
end_mask = 0xff << end_mask;
|
end_mask = (unsigned int)(0xff << end_mask);
|
||||||
|
|
||||||
else /* big-endian byte */
|
else /* big-endian byte */
|
||||||
# endif
|
# endif
|
||||||
@@ -3373,7 +3494,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
|||||||
*/
|
*/
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
dp[0] = sp[0], dp[1] = sp[1];
|
dp[0] = sp[0]; dp[1] = sp[1];
|
||||||
|
|
||||||
if (row_width <= bytes_to_jump)
|
if (row_width <= bytes_to_jump)
|
||||||
return;
|
return;
|
||||||
@@ -3394,7 +3515,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
|||||||
*/
|
*/
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];
|
dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2];
|
||||||
|
|
||||||
if (row_width <= bytes_to_jump)
|
if (row_width <= bytes_to_jump)
|
||||||
return;
|
return;
|
||||||
@@ -3545,7 +3666,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
{
|
{
|
||||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
/* Offset to next interlace block */
|
/* Offset to next interlace block */
|
||||||
static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
|
|
||||||
png_debug(1, "in png_do_read_interlace");
|
png_debug(1, "in png_do_read_interlace");
|
||||||
if (row != NULL && row_info != NULL)
|
if (row != NULL && row_info != NULL)
|
||||||
@@ -3560,9 +3681,10 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
{
|
{
|
||||||
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
|
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
|
||||||
png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
|
png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
|
||||||
int sshift, dshift;
|
unsigned int sshift, dshift;
|
||||||
int s_start, s_end, s_inc;
|
unsigned int s_start, s_end;
|
||||||
int jstop = png_pass_inc[pass];
|
int s_inc;
|
||||||
|
int jstop = (int)png_pass_inc[pass];
|
||||||
png_byte v;
|
png_byte v;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
int j;
|
int j;
|
||||||
@@ -3570,8 +3692,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||||
if ((transformations & PNG_PACKSWAP) != 0)
|
if ((transformations & PNG_PACKSWAP) != 0)
|
||||||
{
|
{
|
||||||
sshift = (int)((row_info->width + 7) & 0x07);
|
sshift = ((row_info->width + 7) & 0x07);
|
||||||
dshift = (int)((final_width + 7) & 0x07);
|
dshift = ((final_width + 7) & 0x07);
|
||||||
s_start = 7;
|
s_start = 7;
|
||||||
s_end = 0;
|
s_end = 0;
|
||||||
s_inc = -1;
|
s_inc = -1;
|
||||||
@@ -3580,8 +3702,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sshift = 7 - (int)((row_info->width + 7) & 0x07);
|
sshift = 7 - ((row_info->width + 7) & 0x07);
|
||||||
dshift = 7 - (int)((final_width + 7) & 0x07);
|
dshift = 7 - ((final_width + 7) & 0x07);
|
||||||
s_start = 0;
|
s_start = 0;
|
||||||
s_end = 7;
|
s_end = 7;
|
||||||
s_inc = 1;
|
s_inc = 1;
|
||||||
@@ -3593,7 +3715,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
for (j = 0; j < jstop; j++)
|
for (j = 0; j < jstop; j++)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
|
unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
|
||||||
tmp |= v << dshift;
|
tmp |= (unsigned int)(v << dshift);
|
||||||
*dp = (png_byte)(tmp & 0xff);
|
*dp = (png_byte)(tmp & 0xff);
|
||||||
|
|
||||||
if (dshift == s_end)
|
if (dshift == s_end)
|
||||||
@@ -3603,7 +3725,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
dshift += s_inc;
|
dshift = (unsigned int)((int)dshift + s_inc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sshift == s_end)
|
if (sshift == s_end)
|
||||||
@@ -3613,7 +3735,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
sshift += s_inc;
|
sshift = (unsigned int)((int)sshift + s_inc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3622,16 +3744,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
{
|
{
|
||||||
png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
|
png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
|
||||||
png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
|
png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
|
||||||
int sshift, dshift;
|
unsigned int sshift, dshift;
|
||||||
int s_start, s_end, s_inc;
|
unsigned int s_start, s_end;
|
||||||
int jstop = png_pass_inc[pass];
|
int s_inc;
|
||||||
|
int jstop = (int)png_pass_inc[pass];
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
|
||||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||||
if ((transformations & PNG_PACKSWAP) != 0)
|
if ((transformations & PNG_PACKSWAP) != 0)
|
||||||
{
|
{
|
||||||
sshift = (int)(((row_info->width + 3) & 0x03) << 1);
|
sshift = (((row_info->width + 3) & 0x03) << 1);
|
||||||
dshift = (int)(((final_width + 3) & 0x03) << 1);
|
dshift = (((final_width + 3) & 0x03) << 1);
|
||||||
s_start = 6;
|
s_start = 6;
|
||||||
s_end = 0;
|
s_end = 0;
|
||||||
s_inc = -2;
|
s_inc = -2;
|
||||||
@@ -3640,8 +3763,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1);
|
sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1);
|
||||||
dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1);
|
dshift = ((3 - ((final_width + 3) & 0x03)) << 1);
|
||||||
s_start = 0;
|
s_start = 0;
|
||||||
s_end = 6;
|
s_end = 6;
|
||||||
s_inc = 2;
|
s_inc = 2;
|
||||||
@@ -3656,7 +3779,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
for (j = 0; j < jstop; j++)
|
for (j = 0; j < jstop; j++)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
|
unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
|
||||||
tmp |= v << dshift;
|
tmp |= (unsigned int)(v << dshift);
|
||||||
*dp = (png_byte)(tmp & 0xff);
|
*dp = (png_byte)(tmp & 0xff);
|
||||||
|
|
||||||
if (dshift == s_end)
|
if (dshift == s_end)
|
||||||
@@ -3666,7 +3789,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
dshift += s_inc;
|
dshift = (unsigned int)((int)dshift + s_inc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sshift == s_end)
|
if (sshift == s_end)
|
||||||
@@ -3676,7 +3799,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
sshift += s_inc;
|
sshift = (unsigned int)((int)sshift + s_inc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3685,16 +3808,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
{
|
{
|
||||||
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
|
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
|
||||||
png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
|
png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
|
||||||
int sshift, dshift;
|
unsigned int sshift, dshift;
|
||||||
int s_start, s_end, s_inc;
|
unsigned int s_start, s_end;
|
||||||
|
int s_inc;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
int jstop = png_pass_inc[pass];
|
int jstop = (int)png_pass_inc[pass];
|
||||||
|
|
||||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||||
if ((transformations & PNG_PACKSWAP) != 0)
|
if ((transformations & PNG_PACKSWAP) != 0)
|
||||||
{
|
{
|
||||||
sshift = (int)(((row_info->width + 1) & 0x01) << 2);
|
sshift = (((row_info->width + 1) & 0x01) << 2);
|
||||||
dshift = (int)(((final_width + 1) & 0x01) << 2);
|
dshift = (((final_width + 1) & 0x01) << 2);
|
||||||
s_start = 4;
|
s_start = 4;
|
||||||
s_end = 0;
|
s_end = 0;
|
||||||
s_inc = -4;
|
s_inc = -4;
|
||||||
@@ -3703,8 +3827,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2);
|
sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2);
|
||||||
dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2);
|
dshift = ((1 - ((final_width + 1) & 0x01)) << 2);
|
||||||
s_start = 0;
|
s_start = 0;
|
||||||
s_end = 4;
|
s_end = 4;
|
||||||
s_inc = 4;
|
s_inc = 4;
|
||||||
@@ -3718,7 +3842,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
for (j = 0; j < jstop; j++)
|
for (j = 0; j < jstop; j++)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
|
unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
|
||||||
tmp |= v << dshift;
|
tmp |= (unsigned int)(v << dshift);
|
||||||
*dp = (png_byte)(tmp & 0xff);
|
*dp = (png_byte)(tmp & 0xff);
|
||||||
|
|
||||||
if (dshift == s_end)
|
if (dshift == s_end)
|
||||||
@@ -3728,7 +3852,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
dshift += s_inc;
|
dshift = (unsigned int)((int)dshift + s_inc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sshift == s_end)
|
if (sshift == s_end)
|
||||||
@@ -3738,7 +3862,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
sshift += s_inc;
|
sshift = (unsigned int)((int)sshift + s_inc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3752,7 +3876,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||||||
|
|
||||||
png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
|
png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
|
||||||
|
|
||||||
int jstop = png_pass_inc[pass];
|
int jstop = (int)png_pass_inc[pass];
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
|
|
||||||
for (i = 0; i < row_info->width; i++)
|
for (i = 0; i < row_info->width; i++)
|
||||||
@@ -3880,7 +4004,10 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
|
|||||||
/* Find the best predictor, the least of pa, pb, pc favoring the earlier
|
/* Find the best predictor, the least of pa, pb, pc favoring the earlier
|
||||||
* ones in the case of a tie.
|
* ones in the case of a tie.
|
||||||
*/
|
*/
|
||||||
if (pb < pa) pa = pb, a = b;
|
if (pb < pa)
|
||||||
|
{
|
||||||
|
pa = pb; a = b;
|
||||||
|
}
|
||||||
if (pc < pa) a = c;
|
if (pc < pa) a = c;
|
||||||
|
|
||||||
/* Calculate the current pixel in a, and move the previous row pixel to c
|
/* Calculate the current pixel in a, and move the previous row pixel to c
|
||||||
@@ -3896,7 +4023,7 @@ static void
|
|||||||
png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
||||||
png_const_bytep prev_row)
|
png_const_bytep prev_row)
|
||||||
{
|
{
|
||||||
int bpp = (row_info->pixel_depth + 7) >> 3;
|
unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
|
||||||
png_bytep rp_end = row + bpp;
|
png_bytep rp_end = row + bpp;
|
||||||
|
|
||||||
/* Process the first pixel in the row completely (this is the same as 'up'
|
/* Process the first pixel in the row completely (this is the same as 'up'
|
||||||
@@ -3909,7 +4036,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Remainder */
|
/* Remainder */
|
||||||
rp_end += row_info->rowbytes - bpp;
|
rp_end = rp_end + (row_info->rowbytes - bpp);
|
||||||
|
|
||||||
while (row < rp_end)
|
while (row < rp_end)
|
||||||
{
|
{
|
||||||
@@ -3932,7 +4059,10 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
|||||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pb < pa) pa = pb, a = b;
|
if (pb < pa)
|
||||||
|
{
|
||||||
|
pa = pb; a = b;
|
||||||
|
}
|
||||||
if (pc < pa) a = c;
|
if (pc < pa) a = c;
|
||||||
|
|
||||||
a += *row;
|
a += *row;
|
||||||
@@ -4254,7 +4384,7 @@ png_read_start_row(png_structrp png_ptr)
|
|||||||
/* Offset to next interlace block in the y direction */
|
/* Offset to next interlace block in the y direction */
|
||||||
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
|
||||||
int max_pixel_depth;
|
unsigned int max_pixel_depth;
|
||||||
png_size_t row_bytes;
|
png_size_t row_bytes;
|
||||||
|
|
||||||
png_debug(1, "in png_read_start_row");
|
png_debug(1, "in png_read_start_row");
|
||||||
@@ -4283,7 +4413,7 @@ png_read_start_row(png_structrp png_ptr)
|
|||||||
png_ptr->iwidth = png_ptr->width;
|
png_ptr->iwidth = png_ptr->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
max_pixel_depth = png_ptr->pixel_depth;
|
max_pixel_depth = (unsigned int)png_ptr->pixel_depth;
|
||||||
|
|
||||||
/* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of
|
/* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of
|
||||||
* calculations to calculate the final pixel depth, then
|
* calculations to calculate the final pixel depth, then
|
||||||
@@ -4418,7 +4548,7 @@ png_read_start_row(png_structrp png_ptr)
|
|||||||
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||||
{
|
{
|
||||||
int user_pixel_depth = png_ptr->user_transform_depth *
|
unsigned int user_pixel_depth = png_ptr->user_transform_depth *
|
||||||
png_ptr->user_transform_channels;
|
png_ptr->user_transform_channels;
|
||||||
|
|
||||||
if (user_pixel_depth > max_pixel_depth)
|
if (user_pixel_depth > max_pixel_depth)
|
||||||
@@ -4440,7 +4570,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
|||||||
* for safety's sake
|
* for safety's sake
|
||||||
*/
|
*/
|
||||||
row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
|
row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
|
||||||
1 + ((max_pixel_depth + 7) >> 3);
|
1 + ((max_pixel_depth + 7) >> 3U);
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
if (row_bytes > (png_uint_32)65536L)
|
if (row_bytes > (png_uint_32)65536L)
|
||||||
@@ -4509,7 +4639,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
|||||||
* does not, so free the read buffer now regardless; the sequential reader
|
* does not, so free the read buffer now regardless; the sequential reader
|
||||||
* reallocates it on demand.
|
* reallocates it on demand.
|
||||||
*/
|
*/
|
||||||
if (png_ptr->read_buffer != 0)
|
if (png_ptr->read_buffer != NULL)
|
||||||
{
|
{
|
||||||
png_bytep buffer = png_ptr->read_buffer;
|
png_bytep buffer = png_ptr->read_buffer;
|
||||||
|
|
||||||
|
|||||||
Vendored
+83
-18
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngset.c - storage of image information into info struct
|
/* pngset.c - storage of image information into info struct
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||||
* Copyright (c) 1998-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -134,6 +134,53 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
|||||||
|
|
||||||
#endif /* cHRM */
|
#endif /* cHRM */
|
||||||
|
|
||||||
|
#ifdef PNG_eXIf_SUPPORTED
|
||||||
|
void PNGAPI
|
||||||
|
png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
|
const png_bytep eXIf_buf)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
|
||||||
|
PNG_UNUSED(info_ptr)
|
||||||
|
PNG_UNUSED(eXIf_buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
void PNGAPI
|
||||||
|
png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
|
const png_uint_32 num_exif, const png_bytep eXIf_buf)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
png_debug1(1, "in %s storage function", "eXIf");
|
||||||
|
|
||||||
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (info_ptr->exif)
|
||||||
|
{
|
||||||
|
png_free(png_ptr, info_ptr->exif);
|
||||||
|
info_ptr->exif = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
info_ptr->num_exif = num_exif;
|
||||||
|
|
||||||
|
info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr,
|
||||||
|
info_ptr->num_exif));
|
||||||
|
|
||||||
|
if (info_ptr->exif == NULL)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "Insufficient memory for eXIf chunk data");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info_ptr->free_me |= PNG_FREE_EXIF;
|
||||||
|
|
||||||
|
for (i = 0; i < (int) info_ptr->num_exif; i++)
|
||||||
|
info_ptr->exif[i] = eXIf_buf[i];
|
||||||
|
|
||||||
|
info_ptr->valid |= PNG_INFO_eXIf;
|
||||||
|
}
|
||||||
|
#endif /* eXIf */
|
||||||
|
|
||||||
#ifdef PNG_gAMA_SUPPORTED
|
#ifdef PNG_gAMA_SUPPORTED
|
||||||
void PNGFAPI
|
void PNGFAPI
|
||||||
png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
@@ -283,17 +330,29 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||||||
|
|
||||||
/* Check that the type matches the specification. */
|
/* Check that the type matches the specification. */
|
||||||
if (type < 0 || type > 3)
|
if (type < 0 || type > 3)
|
||||||
png_error(png_ptr, "Invalid pCAL equation type");
|
{
|
||||||
|
png_chunk_report(png_ptr, "Invalid pCAL equation type",
|
||||||
|
PNG_CHUNK_WRITE_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (nparams < 0 || nparams > 255)
|
if (nparams < 0 || nparams > 255)
|
||||||
png_error(png_ptr, "Invalid pCAL parameter count");
|
{
|
||||||
|
png_chunk_report(png_ptr, "Invalid pCAL parameter count",
|
||||||
|
PNG_CHUNK_WRITE_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Validate params[nparams] */
|
/* Validate params[nparams] */
|
||||||
for (i=0; i<nparams; ++i)
|
for (i=0; i<nparams; ++i)
|
||||||
{
|
{
|
||||||
if (params[i] == NULL ||
|
if (params[i] == NULL ||
|
||||||
!png_check_fp_string(params[i], strlen(params[i])))
|
!png_check_fp_string(params[i], strlen(params[i])))
|
||||||
png_error(png_ptr, "Invalid format for pCAL parameter");
|
{
|
||||||
|
png_chunk_report(png_ptr, "Invalid format for pCAL parameter",
|
||||||
|
PNG_CHUNK_WRITE_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info_ptr->pcal_purpose = png_voidcast(png_charp,
|
info_ptr->pcal_purpose = png_voidcast(png_charp,
|
||||||
@@ -301,8 +360,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||||||
|
|
||||||
if (info_ptr->pcal_purpose == NULL)
|
if (info_ptr->pcal_purpose == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Insufficient memory for pCAL purpose");
|
png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose",
|
||||||
|
PNG_CHUNK_WRITE_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +390,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||||||
memcpy(info_ptr->pcal_units, units, length);
|
memcpy(info_ptr->pcal_units, units, length);
|
||||||
|
|
||||||
info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
|
info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
|
||||||
(png_size_t)((nparams + 1) * (sizeof (png_charp)))));
|
(png_size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp)))));
|
||||||
|
|
||||||
if (info_ptr->pcal_params == NULL)
|
if (info_ptr->pcal_params == NULL)
|
||||||
{
|
{
|
||||||
@@ -340,7 +399,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));
|
memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) *
|
||||||
|
(sizeof (png_charp)));
|
||||||
|
|
||||||
for (i = 0; i < nparams; i++)
|
for (i = 0; i < nparams; i++)
|
||||||
{
|
{
|
||||||
@@ -563,7 +623,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||||||
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
||||||
|
|
||||||
if (num_palette > 0)
|
if (num_palette > 0)
|
||||||
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
memcpy(png_ptr->palette, palette, (unsigned int)num_palette *
|
||||||
|
(sizeof (png_color)));
|
||||||
info_ptr->palette = png_ptr->palette;
|
info_ptr->palette = png_ptr->palette;
|
||||||
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
||||||
|
|
||||||
@@ -1080,7 +1141,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
|||||||
* checked it when doing the allocation.
|
* checked it when doing the allocation.
|
||||||
*/
|
*/
|
||||||
memcpy(np->entries, entries->entries,
|
memcpy(np->entries, entries->entries,
|
||||||
entries->nentries * sizeof (png_sPLT_entry));
|
(unsigned int)entries->nentries * sizeof (png_sPLT_entry));
|
||||||
|
|
||||||
/* Note that 'continue' skips the advance of the out pointer and out
|
/* Note that 'continue' skips the advance of the out pointer and out
|
||||||
* count, so an invalid entry is not added.
|
* count, so an invalid entry is not added.
|
||||||
@@ -1088,8 +1149,9 @@ png_set_sPLT(png_const_structrp png_ptr,
|
|||||||
info_ptr->valid |= PNG_INFO_sPLT;
|
info_ptr->valid |= PNG_INFO_sPLT;
|
||||||
++(info_ptr->splt_palettes_num);
|
++(info_ptr->splt_palettes_num);
|
||||||
++np;
|
++np;
|
||||||
|
++entries;
|
||||||
}
|
}
|
||||||
while (++entries, --nentries);
|
while (--nentries);
|
||||||
|
|
||||||
if (nentries > 0)
|
if (nentries > 0)
|
||||||
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
|
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
|
||||||
@@ -1249,7 +1311,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||||||
{
|
{
|
||||||
png_app_error(png_ptr, "invalid unknown chunk location");
|
png_app_error(png_ptr, "invalid unknown chunk location");
|
||||||
/* Fake out the pre 1.6.0 behavior: */
|
/* Fake out the pre 1.6.0 behavior: */
|
||||||
if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */
|
if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */
|
||||||
location = PNG_AFTER_IDAT;
|
location = PNG_AFTER_IDAT;
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -1340,6 +1402,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||||||
static PNG_CONST png_byte chunks_to_ignore[] = {
|
static PNG_CONST png_byte chunks_to_ignore[] = {
|
||||||
98, 75, 71, 68, '\0', /* bKGD */
|
98, 75, 71, 68, '\0', /* bKGD */
|
||||||
99, 72, 82, 77, '\0', /* cHRM */
|
99, 72, 82, 77, '\0', /* cHRM */
|
||||||
|
101, 88, 73, 102, '\0', /* eXIf */
|
||||||
103, 65, 77, 65, '\0', /* gAMA */
|
103, 65, 77, 65, '\0', /* gAMA */
|
||||||
104, 73, 83, 84, '\0', /* hIST */
|
104, 73, 83, 84, '\0', /* hIST */
|
||||||
105, 67, 67, 80, '\0', /* iCCP */
|
105, 67, 67, 80, '\0', /* iCCP */
|
||||||
@@ -1373,7 +1436,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_chunks = num_chunks_in;
|
num_chunks = (unsigned int)num_chunks_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_num_chunks = png_ptr->num_chunk_list;
|
old_num_chunks = png_ptr->num_chunk_list;
|
||||||
@@ -1563,7 +1626,7 @@ void PNGAPI
|
|||||||
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
|
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL)
|
if (png_ptr != NULL && info_ptr != NULL)
|
||||||
info_ptr->valid &= ~mask;
|
info_ptr->valid &= (unsigned int)(~mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1682,14 +1745,16 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
|||||||
png_byte ch = (png_byte)*key++;
|
png_byte ch = (png_byte)*key++;
|
||||||
|
|
||||||
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
|
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
|
||||||
*new_key++ = ch, ++key_len, space = 0;
|
{
|
||||||
|
*new_key++ = ch; ++key_len; space = 0;
|
||||||
|
}
|
||||||
|
|
||||||
else if (space == 0)
|
else if (space == 0)
|
||||||
{
|
{
|
||||||
/* A space or an invalid character when one wasn't seen immediately
|
/* A space or an invalid character when one wasn't seen immediately
|
||||||
* before; output just a space.
|
* before; output just a space.
|
||||||
*/
|
*/
|
||||||
*new_key++ = 32, ++key_len, space = 1;
|
*new_key++ = 32; ++key_len; space = 1;
|
||||||
|
|
||||||
/* If the character was not a space then it is invalid. */
|
/* If the character was not a space then it is invalid. */
|
||||||
if (ch != 32)
|
if (ch != 32)
|
||||||
@@ -1702,7 +1767,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
|||||||
|
|
||||||
if (key_len > 0 && space != 0) /* trailing space */
|
if (key_len > 0 && space != 0) /* trailing space */
|
||||||
{
|
{
|
||||||
--key_len, --new_key;
|
--key_len; --new_key;
|
||||||
if (bad_character == 0)
|
if (bad_character == 0)
|
||||||
bad_character = 32;
|
bad_character = 32;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngstruct.h - header file for PNG reference library
|
/* pngstruct.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -263,7 +263,7 @@ struct png_struct_def
|
|||||||
/* pixel depth used for the row buffers */
|
/* pixel depth used for the row buffers */
|
||||||
png_byte transformed_pixel_depth;
|
png_byte transformed_pixel_depth;
|
||||||
/* pixel depth after read/write transforms */
|
/* pixel depth after read/write transforms */
|
||||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
#if ZLIB_VERNUM >= 0x1240
|
||||||
png_byte zstream_start; /* at start of an input zlib stream */
|
png_byte zstream_start; /* at start of an input zlib stream */
|
||||||
#endif /* Zlib >= 1.2.4 */
|
#endif /* Zlib >= 1.2.4 */
|
||||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||||
@@ -353,7 +353,7 @@ struct png_struct_def
|
|||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||||
png_byte options; /* On/off state (up to 4 options) */
|
png_uint_32 options; /* On/off state (up to 16 options) */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PNG_LIBPNG_VER < 10700
|
#if PNG_LIBPNG_VER < 10700
|
||||||
|
|||||||
Vendored
+29
-15
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -514,11 +514,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
|||||||
if (at_start != 0) /* Skip initial filler */
|
if (at_start != 0) /* Skip initial filler */
|
||||||
++sp;
|
++sp;
|
||||||
else /* Skip initial channel and, for sp, the filler */
|
else /* Skip initial channel and, for sp, the filler */
|
||||||
sp += 2, ++dp;
|
{
|
||||||
|
sp += 2; ++dp;
|
||||||
|
}
|
||||||
|
|
||||||
/* For a 1 pixel wide image there is nothing to do */
|
/* For a 1 pixel wide image there is nothing to do */
|
||||||
while (sp < ep)
|
while (sp < ep)
|
||||||
*dp++ = *sp, sp += 2;
|
{
|
||||||
|
*dp++ = *sp; sp += 2;
|
||||||
|
}
|
||||||
|
|
||||||
row_info->pixel_depth = 8;
|
row_info->pixel_depth = 8;
|
||||||
}
|
}
|
||||||
@@ -528,10 +532,14 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
|||||||
if (at_start != 0) /* Skip initial filler */
|
if (at_start != 0) /* Skip initial filler */
|
||||||
sp += 2;
|
sp += 2;
|
||||||
else /* Skip initial channel and, for sp, the filler */
|
else /* Skip initial channel and, for sp, the filler */
|
||||||
sp += 4, dp += 2;
|
{
|
||||||
|
sp += 4; dp += 2;
|
||||||
|
}
|
||||||
|
|
||||||
while (sp < ep)
|
while (sp < ep)
|
||||||
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
{
|
||||||
|
*dp++ = *sp++; *dp++ = *sp; sp += 3;
|
||||||
|
}
|
||||||
|
|
||||||
row_info->pixel_depth = 16;
|
row_info->pixel_depth = 16;
|
||||||
}
|
}
|
||||||
@@ -554,11 +562,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
|||||||
if (at_start != 0) /* Skip initial filler */
|
if (at_start != 0) /* Skip initial filler */
|
||||||
++sp;
|
++sp;
|
||||||
else /* Skip initial channels and, for sp, the filler */
|
else /* Skip initial channels and, for sp, the filler */
|
||||||
sp += 4, dp += 3;
|
{
|
||||||
|
sp += 4; dp += 3;
|
||||||
|
}
|
||||||
|
|
||||||
/* Note that the loop adds 3 to dp and 4 to sp each time. */
|
/* Note that the loop adds 3 to dp and 4 to sp each time. */
|
||||||
while (sp < ep)
|
while (sp < ep)
|
||||||
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
|
{
|
||||||
|
*dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2;
|
||||||
|
}
|
||||||
|
|
||||||
row_info->pixel_depth = 24;
|
row_info->pixel_depth = 24;
|
||||||
}
|
}
|
||||||
@@ -568,14 +580,16 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
|||||||
if (at_start != 0) /* Skip initial filler */
|
if (at_start != 0) /* Skip initial filler */
|
||||||
sp += 2;
|
sp += 2;
|
||||||
else /* Skip initial channels and, for sp, the filler */
|
else /* Skip initial channels and, for sp, the filler */
|
||||||
sp += 8, dp += 6;
|
{
|
||||||
|
sp += 8; dp += 6;
|
||||||
|
}
|
||||||
|
|
||||||
while (sp < ep)
|
while (sp < ep)
|
||||||
{
|
{
|
||||||
/* Copy 6 bytes, skip 2 */
|
/* Copy 6 bytes, skip 2 */
|
||||||
*dp++ = *sp++, *dp++ = *sp++;
|
*dp++ = *sp++; *dp++ = *sp++;
|
||||||
*dp++ = *sp++, *dp++ = *sp++;
|
*dp++ = *sp++; *dp++ = *sp++;
|
||||||
*dp++ = *sp++, *dp++ = *sp, sp += 3;
|
*dp++ = *sp++; *dp++ = *sp; sp += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
row_info->pixel_depth = 48;
|
row_info->pixel_depth = 48;
|
||||||
@@ -595,7 +609,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
|||||||
return; /* The filler channel has gone already */
|
return; /* The filler channel has gone already */
|
||||||
|
|
||||||
/* Fix the rowbytes value. */
|
/* Fix the rowbytes value. */
|
||||||
row_info->rowbytes = dp-row;
|
row_info->rowbytes = (png_size_t)(dp-row);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -693,8 +707,8 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
* and this calculation is used because it avoids warnings that other
|
* and this calculation is used because it avoids warnings that other
|
||||||
* forms produced on either GCC or MSVC.
|
* forms produced on either GCC or MSVC.
|
||||||
*/
|
*/
|
||||||
int padding = (-row_info->pixel_depth * row_info->width) & 7;
|
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
|
||||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
|
png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1;
|
||||||
|
|
||||||
switch (row_info->bit_depth)
|
switch (row_info->bit_depth)
|
||||||
{
|
{
|
||||||
|
|||||||
Vendored
+43
-30
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngwrite.c - general routines to write a PNG file
|
/* pngwrite.c - general routines to write a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -237,6 +237,11 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
|||||||
png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
|
png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
|
||||||
#endif
|
#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);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_hIST_SUPPORTED
|
#ifdef PNG_WRITE_hIST_SUPPORTED
|
||||||
if ((info_ptr->valid & PNG_INFO_hIST) != 0)
|
if ((info_ptr->valid & PNG_INFO_hIST) != 0)
|
||||||
png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
|
png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
|
||||||
@@ -432,6 +437,12 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT);
|
write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT);
|
||||||
#endif
|
#endif
|
||||||
@@ -666,9 +677,9 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||||||
|
|
||||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||||
{
|
{
|
||||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1);
|
||||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3);
|
||||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
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 red = (png_uint_32)((s0 - s1) & 0xffffL);
|
||||||
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
||||||
*(rp ) = (png_byte)(red >> 8);
|
*(rp ) = (png_byte)(red >> 8);
|
||||||
@@ -901,7 +912,7 @@ png_set_flush(png_structrp png_ptr, int nrows)
|
|||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
|
png_ptr->flush_dist = (nrows < 0 ? 0 : (png_uint_32)nrows);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush the current output buffers now */
|
/* Flush the current output buffers now */
|
||||||
@@ -1007,8 +1018,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
|
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||||
/* FALL THROUGH */
|
|
||||||
#endif /* WRITE_FILTER */
|
#endif /* WRITE_FILTER */
|
||||||
|
/* FALLTHROUGH */
|
||||||
case PNG_FILTER_VALUE_NONE:
|
case PNG_FILTER_VALUE_NONE:
|
||||||
png_ptr->do_filter = PNG_FILTER_NONE; break;
|
png_ptr->do_filter = PNG_FILTER_NONE; break;
|
||||||
|
|
||||||
@@ -1525,7 +1536,8 @@ png_write_image_16bit(png_voidp argument)
|
|||||||
display->first_row);
|
display->first_row);
|
||||||
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
|
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
|
||||||
png_uint_16p row_end;
|
png_uint_16p row_end;
|
||||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||||
|
3 : 1;
|
||||||
int aindex = 0;
|
int aindex = 0;
|
||||||
png_uint_32 y = image->height;
|
png_uint_32 y = image->height;
|
||||||
|
|
||||||
@@ -1539,9 +1551,9 @@ png_write_image_16bit(png_voidp argument)
|
|||||||
++output_row;
|
++output_row;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
aindex = channels;
|
aindex = (int)channels;
|
||||||
# else
|
# else
|
||||||
aindex = channels;
|
aindex = (int)channels;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1554,7 +1566,7 @@ png_write_image_16bit(png_voidp argument)
|
|||||||
*/
|
*/
|
||||||
row_end = output_row + image->width * (channels+1);
|
row_end = output_row + image->width * (channels+1);
|
||||||
|
|
||||||
while (y-- > 0)
|
for (; y > 0; --y)
|
||||||
{
|
{
|
||||||
png_const_uint_16p in_ptr = input_row;
|
png_const_uint_16p in_ptr = input_row;
|
||||||
png_uint_16p out_ptr = output_row;
|
png_uint_16p out_ptr = output_row;
|
||||||
@@ -1575,7 +1587,7 @@ png_write_image_16bit(png_voidp argument)
|
|||||||
if (alpha > 0 && alpha < 65535)
|
if (alpha > 0 && alpha < 65535)
|
||||||
reciprocal = ((0xffff<<15)+(alpha>>1))/alpha;
|
reciprocal = ((0xffff<<15)+(alpha>>1))/alpha;
|
||||||
|
|
||||||
c = channels;
|
c = (int)channels;
|
||||||
do /* always at least one channel */
|
do /* always at least one channel */
|
||||||
{
|
{
|
||||||
png_uint_16 component = *in_ptr++;
|
png_uint_16 component = *in_ptr++;
|
||||||
@@ -1610,7 +1622,7 @@ png_write_image_16bit(png_voidp argument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row));
|
png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row));
|
||||||
input_row += display->row_bytes/(sizeof (png_uint_16));
|
input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1683,7 +1695,8 @@ png_write_image_8bit(png_voidp argument)
|
|||||||
display->first_row);
|
display->first_row);
|
||||||
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
|
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
|
||||||
png_uint_32 y = image->height;
|
png_uint_32 y = image->height;
|
||||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||||
|
3 : 1;
|
||||||
|
|
||||||
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||||
{
|
{
|
||||||
@@ -1700,12 +1713,12 @@ png_write_image_8bit(png_voidp argument)
|
|||||||
|
|
||||||
else
|
else
|
||||||
# endif
|
# endif
|
||||||
aindex = channels;
|
aindex = (int)channels;
|
||||||
|
|
||||||
/* Use row_end in place of a loop counter: */
|
/* Use row_end in place of a loop counter: */
|
||||||
row_end = output_row + image->width * (channels+1);
|
row_end = output_row + image->width * (channels+1);
|
||||||
|
|
||||||
while (y-- > 0)
|
for (; y > 0; --y)
|
||||||
{
|
{
|
||||||
png_const_uint_16p in_ptr = input_row;
|
png_const_uint_16p in_ptr = input_row;
|
||||||
png_bytep out_ptr = output_row;
|
png_bytep out_ptr = output_row;
|
||||||
@@ -1723,7 +1736,7 @@ png_write_image_8bit(png_voidp argument)
|
|||||||
if (alphabyte > 0 && alphabyte < 255)
|
if (alphabyte > 0 && alphabyte < 255)
|
||||||
reciprocal = UNP_RECIPROCAL(alpha);
|
reciprocal = UNP_RECIPROCAL(alpha);
|
||||||
|
|
||||||
c = channels;
|
c = (int)channels;
|
||||||
do /* always at least one channel */
|
do /* always at least one channel */
|
||||||
*out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal);
|
*out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal);
|
||||||
while (--c > 0);
|
while (--c > 0);
|
||||||
@@ -1735,7 +1748,7 @@ png_write_image_8bit(png_voidp argument)
|
|||||||
|
|
||||||
png_write_row(png_ptr, png_voidcast(png_const_bytep,
|
png_write_row(png_ptr, png_voidcast(png_const_bytep,
|
||||||
display->local_row));
|
display->local_row));
|
||||||
input_row += display->row_bytes/(sizeof (png_uint_16));
|
input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
|
||||||
} /* while y */
|
} /* while y */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1746,7 +1759,7 @@ png_write_image_8bit(png_voidp argument)
|
|||||||
*/
|
*/
|
||||||
png_bytep row_end = output_row + image->width * channels;
|
png_bytep row_end = output_row + image->width * channels;
|
||||||
|
|
||||||
while (y-- > 0)
|
for (; y > 0; --y)
|
||||||
{
|
{
|
||||||
png_const_uint_16p in_ptr = input_row;
|
png_const_uint_16p in_ptr = input_row;
|
||||||
png_bytep out_ptr = output_row;
|
png_bytep out_ptr = output_row;
|
||||||
@@ -1760,7 +1773,7 @@ png_write_image_8bit(png_voidp argument)
|
|||||||
}
|
}
|
||||||
|
|
||||||
png_write_row(png_ptr, output_row);
|
png_write_row(png_ptr, output_row);
|
||||||
input_row += display->row_bytes/(sizeof (png_uint_16));
|
input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1777,7 +1790,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||||||
|
|
||||||
/* NOTE: the caller must check for cmap != NULL and entries != 0 */
|
/* NOTE: the caller must check for cmap != NULL and entries != 0 */
|
||||||
const png_uint_32 format = image->format;
|
const png_uint_32 format = image->format;
|
||||||
const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
const unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
||||||
|
|
||||||
# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
|
# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
|
||||||
defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
|
defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
|
||||||
@@ -1809,7 +1822,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||||||
{
|
{
|
||||||
png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
|
png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
|
||||||
|
|
||||||
entry += i * channels;
|
entry += (unsigned int)i * channels;
|
||||||
|
|
||||||
if ((channels & 1) != 0) /* no alpha */
|
if ((channels & 1) != 0) /* no alpha */
|
||||||
{
|
{
|
||||||
@@ -1865,7 +1878,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||||||
{
|
{
|
||||||
png_const_bytep entry = png_voidcast(png_const_bytep, cmap);
|
png_const_bytep entry = png_voidcast(png_const_bytep, cmap);
|
||||||
|
|
||||||
entry += i * channels;
|
entry += (unsigned int)i * channels;
|
||||||
|
|
||||||
switch (channels)
|
switch (channels)
|
||||||
{
|
{
|
||||||
@@ -1910,7 +1923,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||||||
png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS,
|
png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS,
|
||||||
num_trans, NULL);
|
num_trans, NULL);
|
||||||
|
|
||||||
image->colormap_entries = entries;
|
image->colormap_entries = (png_uint_32)entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -1927,7 +1940,7 @@ png_image_write_main(png_voidp argument)
|
|||||||
int colormap = (format & PNG_FORMAT_FLAG_COLORMAP);
|
int colormap = (format & PNG_FORMAT_FLAG_COLORMAP);
|
||||||
int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */
|
int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */
|
||||||
int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
|
int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
|
||||||
int write_16bit = linear && !colormap && (display->convert_to_8bit == 0);
|
int write_16bit = linear && (display->convert_to_8bit == 0);
|
||||||
|
|
||||||
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
/* Make sure we error out on any bad situation */
|
/* Make sure we error out on any bad situation */
|
||||||
@@ -1940,7 +1953,7 @@ png_image_write_main(png_voidp argument)
|
|||||||
{
|
{
|
||||||
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||||
|
|
||||||
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
|
if (image->width <= 0x7fffffffU/channels) /* no overflow */
|
||||||
{
|
{
|
||||||
png_uint_32 check;
|
png_uint_32 check;
|
||||||
const png_uint_32 png_row_stride = image->width * channels;
|
const png_uint_32 png_row_stride = image->width * channels;
|
||||||
@@ -1949,10 +1962,10 @@ png_image_write_main(png_voidp argument)
|
|||||||
display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||||
|
|
||||||
if (display->row_stride < 0)
|
if (display->row_stride < 0)
|
||||||
check = -display->row_stride;
|
check = (png_uint_32)(-display->row_stride);
|
||||||
|
|
||||||
else
|
else
|
||||||
check = display->row_stride;
|
check = (png_uint_32)display->row_stride;
|
||||||
|
|
||||||
if (check >= png_row_stride)
|
if (check >= png_row_stride)
|
||||||
{
|
{
|
||||||
@@ -1960,7 +1973,7 @@ png_image_write_main(png_voidp argument)
|
|||||||
* limits the whole image size to 32 bits for API compatibility with
|
* limits the whole image size to 32 bits for API compatibility with
|
||||||
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
|
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
|
||||||
*/
|
*/
|
||||||
if (image->height > 0xFFFFFFFF/png_row_stride)
|
if (image->height > 0xffffffffU/png_row_stride)
|
||||||
png_error(image->opaque->png_ptr, "memory image too large");
|
png_error(image->opaque->png_ptr, "memory image too large");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2136,7 +2149,7 @@ png_image_write_main(png_voidp argument)
|
|||||||
ptrdiff_t row_bytes = display->row_bytes;
|
ptrdiff_t row_bytes = display->row_bytes;
|
||||||
png_uint_32 y = image->height;
|
png_uint_32 y = image->height;
|
||||||
|
|
||||||
while (y-- > 0)
|
for (; y > 0; --y)
|
||||||
{
|
{
|
||||||
png_write_row(png_ptr, row);
|
png_write_row(png_ptr, row);
|
||||||
row += row_bytes;
|
row += row_bytes;
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@@ -177,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
|||||||
if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
int shift_start[4], shift_dec[4];
|
int shift_start[4], shift_dec[4];
|
||||||
int channels = 0;
|
unsigned int channels = 0;
|
||||||
|
|
||||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Vendored
+54
-25
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngwutil.c - utilities to write a PNG file
|
/* pngwutil.c - utilities to write a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -408,7 +408,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||||||
png_ptr->zstream.avail_out = 0;
|
png_ptr->zstream.avail_out = 0;
|
||||||
|
|
||||||
/* Now initialize if required, setting the new parameters, otherwise just
|
/* Now initialize if required, setting the new parameters, otherwise just
|
||||||
* to a simple reset to the previous parameters.
|
* do a simple reset to the previous parameters.
|
||||||
*/
|
*/
|
||||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
||||||
ret = deflateReset(&png_ptr->zstream);
|
ret = deflateReset(&png_ptr->zstream);
|
||||||
@@ -675,6 +675,7 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
int interlace_type)
|
int interlace_type)
|
||||||
{
|
{
|
||||||
png_byte buf[13]; /* Buffer to store the IHDR info */
|
png_byte buf[13]; /* Buffer to store the IHDR info */
|
||||||
|
int is_invalid_depth;
|
||||||
|
|
||||||
png_debug(1, "in png_write_IHDR");
|
png_debug(1, "in png_write_IHDR");
|
||||||
|
|
||||||
@@ -700,11 +701,11 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_RGB:
|
case PNG_COLOR_TYPE_RGB:
|
||||||
|
is_invalid_depth = (bit_depth != 8);
|
||||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||||
if (bit_depth != 8 && bit_depth != 16)
|
is_invalid_depth = (is_invalid_depth && bit_depth != 16);
|
||||||
#else
|
|
||||||
if (bit_depth != 8)
|
|
||||||
#endif
|
#endif
|
||||||
|
if (is_invalid_depth)
|
||||||
png_error(png_ptr, "Invalid bit depth for RGB image");
|
png_error(png_ptr, "Invalid bit depth for RGB image");
|
||||||
|
|
||||||
png_ptr->channels = 3;
|
png_ptr->channels = 3;
|
||||||
@@ -726,18 +727,22 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||||
if (bit_depth != 8 && bit_depth != 16)
|
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_error(png_ptr, "Invalid bit depth for grayscale+alpha image");
|
||||||
|
|
||||||
png_ptr->channels = 2;
|
png_ptr->channels = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||||
|
is_invalid_depth = (bit_depth != 8);
|
||||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||||
if (bit_depth != 8 && bit_depth != 16)
|
is_invalid_depth = (is_invalid_depth && bit_depth != 16);
|
||||||
#else
|
|
||||||
if (bit_depth != 8)
|
|
||||||
#endif
|
#endif
|
||||||
|
if (is_invalid_depth)
|
||||||
png_error(png_ptr, "Invalid bit depth for RGBA image");
|
png_error(png_ptr, "Invalid bit depth for RGBA image");
|
||||||
|
|
||||||
png_ptr->channels = 4;
|
png_ptr->channels = 4;
|
||||||
@@ -998,6 +1003,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
|||||||
optimize_cmf(data, png_image_size(png_ptr));
|
optimize_cmf(data, png_image_size(png_ptr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
||||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||||
|
|
||||||
@@ -1044,6 +1050,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
|
|||||||
optimize_cmf(data, png_image_size(png_ptr));
|
optimize_cmf(data, png_image_size(png_ptr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
|
||||||
png_ptr->zstream.avail_out = 0;
|
png_ptr->zstream.avail_out = 0;
|
||||||
png_ptr->zstream.next_out = NULL;
|
png_ptr->zstream.next_out = NULL;
|
||||||
@@ -1176,7 +1183,7 @@ png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)
|
|||||||
png_byte new_name[80];
|
png_byte new_name[80];
|
||||||
png_byte entrybuf[10];
|
png_byte entrybuf[10];
|
||||||
png_size_t entry_size = (spalette->depth == 8 ? 6 : 10);
|
png_size_t entry_size = (spalette->depth == 8 ? 6 : 10);
|
||||||
png_size_t palette_size = entry_size * spalette->nentries;
|
png_size_t palette_size = entry_size * (png_size_t)spalette->nentries;
|
||||||
png_sPLT_entryp ep;
|
png_sPLT_entryp ep;
|
||||||
#ifndef PNG_POINTER_INDEXING_SUPPORTED
|
#ifndef PNG_POINTER_INDEXING_SUPPORTED
|
||||||
int i;
|
int i;
|
||||||
@@ -1466,6 +1473,28 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
|
|||||||
}
|
}
|
||||||
#endif
|
#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, (png_size_t)1);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_write_chunk_end(png_ptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_hIST_SUPPORTED
|
#ifdef PNG_WRITE_hIST_SUPPORTED
|
||||||
/* Write the histogram */
|
/* Write the histogram */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
@@ -1743,7 +1772,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
|
|||||||
total_len = purpose_len + units_len + 10;
|
total_len = purpose_len + units_len + 10;
|
||||||
|
|
||||||
params_len = (png_size_tp)png_malloc(png_ptr,
|
params_len = (png_size_tp)png_malloc(png_ptr,
|
||||||
(png_alloc_size_t)(nparams * (sizeof (png_size_t))));
|
(png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (png_size_t))));
|
||||||
|
|
||||||
/* Find the length of each parameter, making sure we don't count the
|
/* Find the length of each parameter, making sure we don't count the
|
||||||
* null terminator for the last parameter.
|
* null terminator for the last parameter.
|
||||||
@@ -2255,7 +2284,7 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
png_bytep rp, dp, lp;
|
png_bytep rp, dp, lp;
|
||||||
png_size_t i;
|
png_size_t i;
|
||||||
png_size_t sum = 0;
|
png_size_t sum = 0;
|
||||||
int v;
|
unsigned int v;
|
||||||
|
|
||||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
|
png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
|
||||||
|
|
||||||
@@ -2264,7 +2293,7 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
{
|
{
|
||||||
v = *dp = *rp;
|
v = *dp = *rp;
|
||||||
#ifdef PNG_USE_ABS
|
#ifdef PNG_USE_ABS
|
||||||
sum += 128 - abs(v - 128);
|
sum += 128 - abs((int)v - 128);
|
||||||
#else
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
#endif
|
#endif
|
||||||
@@ -2275,7 +2304,7 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
{
|
{
|
||||||
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
||||||
#ifdef PNG_USE_ABS
|
#ifdef PNG_USE_ABS
|
||||||
sum += 128 - abs(v - 128);
|
sum += 128 - abs((int)v - 128);
|
||||||
#else
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
#endif
|
#endif
|
||||||
@@ -2316,7 +2345,7 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||||||
png_bytep rp, dp, pp;
|
png_bytep rp, dp, pp;
|
||||||
png_size_t i;
|
png_size_t i;
|
||||||
png_size_t sum = 0;
|
png_size_t sum = 0;
|
||||||
int v;
|
unsigned int v;
|
||||||
|
|
||||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
|
png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
|
||||||
|
|
||||||
@@ -2326,7 +2355,7 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||||||
{
|
{
|
||||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||||
#ifdef PNG_USE_ABS
|
#ifdef PNG_USE_ABS
|
||||||
sum += 128 - abs(v - 128);
|
sum += 128 - abs((int)v - 128);
|
||||||
#else
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
#endif
|
#endif
|
||||||
@@ -2360,7 +2389,7 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
png_bytep rp, dp, pp, lp;
|
png_bytep rp, dp, pp, lp;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
png_size_t sum = 0;
|
png_size_t sum = 0;
|
||||||
int v;
|
unsigned int v;
|
||||||
|
|
||||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
|
png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
|
||||||
|
|
||||||
@@ -2370,7 +2399,7 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
||||||
|
|
||||||
#ifdef PNG_USE_ABS
|
#ifdef PNG_USE_ABS
|
||||||
sum += 128 - abs(v - 128);
|
sum += 128 - abs((int)v - 128);
|
||||||
#else
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
#endif
|
#endif
|
||||||
@@ -2382,7 +2411,7 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
& 0xff);
|
& 0xff);
|
||||||
|
|
||||||
#ifdef PNG_USE_ABS
|
#ifdef PNG_USE_ABS
|
||||||
sum += 128 - abs(v - 128);
|
sum += 128 - abs((int)v - 128);
|
||||||
#else
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
#endif
|
#endif
|
||||||
@@ -2422,7 +2451,7 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
png_bytep rp, dp, pp, cp, lp;
|
png_bytep rp, dp, pp, cp, lp;
|
||||||
png_size_t i;
|
png_size_t i;
|
||||||
png_size_t sum = 0;
|
png_size_t sum = 0;
|
||||||
int v;
|
unsigned int v;
|
||||||
|
|
||||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
|
png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||||
|
|
||||||
@@ -2432,7 +2461,7 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||||
|
|
||||||
#ifdef PNG_USE_ABS
|
#ifdef PNG_USE_ABS
|
||||||
sum += 128 - abs(v - 128);
|
sum += 128 - abs((int)v - 128);
|
||||||
#else
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
#endif
|
#endif
|
||||||
@@ -2465,7 +2494,7 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||||||
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||||
|
|
||||||
#ifdef PNG_USE_ABS
|
#ifdef PNG_USE_ABS
|
||||||
sum += 128 - abs(v - 128);
|
sum += 128 - abs((int)v - 128);
|
||||||
#else
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
#endif
|
#endif
|
||||||
@@ -2588,14 +2617,14 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
png_bytep rp;
|
png_bytep rp;
|
||||||
png_size_t sum = 0;
|
png_size_t sum = 0;
|
||||||
png_size_t i;
|
png_size_t i;
|
||||||
int v;
|
unsigned int v;
|
||||||
|
|
||||||
{
|
{
|
||||||
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
||||||
{
|
{
|
||||||
v = *rp;
|
v = *rp;
|
||||||
#ifdef PNG_USE_ABS
|
#ifdef PNG_USE_ABS
|
||||||
sum += 128 - abs(v - 128);
|
sum += 128 - abs((int)v - 128);
|
||||||
#else
|
#else
|
||||||
sum += (v < 128) ? v : 256 - v;
|
sum += (v < 128) ? v : 256 - v;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+767
@@ -0,0 +1,767 @@
|
|||||||
|
/* filter_vsx_intrinsics.c - PowerPC optimised filter functions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 Glenn Randers-Pehrson
|
||||||
|
* Written by Vadim Barkov, 2017.
|
||||||
|
* Last changed in libpng 1.6.29 [March 16, 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;\
|
||||||
|
png_size_t unaligned_top = 16 - (((png_size_t)rp % 16));\
|
||||||
|
png_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)
|
||||||
|
{
|
||||||
|
const 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)
|
||||||
|
{
|
||||||
|
const 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)
|
||||||
|
{
|
||||||
|
const 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)
|
||||||
|
{
|
||||||
|
const 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)
|
||||||
|
{
|
||||||
|
const 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)
|
||||||
|
{
|
||||||
|
const 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 */
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
|
||||||
|
/* powerpc_init.c - POWERPC optimised filter functions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 Glenn Randers-Pehrson
|
||||||
|
* Written by Vadim Barkov, 2017.
|
||||||
|
* Last changed in libpng 1.6.29 [March 16, 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);
|
||||||
|
#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 */
|
||||||
Vendored
+355
-9
@@ -4,27 +4,373 @@
|
|||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
project(${TIFF_LIBRARY})
|
project(${TIFF_LIBRARY})
|
||||||
|
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
|
include(CheckTypeSize)
|
||||||
|
|
||||||
|
|
||||||
|
# Find libm, if available
|
||||||
|
find_library(M_LIBRARY m)
|
||||||
|
|
||||||
check_include_file(assert.h HAVE_ASSERT_H)
|
check_include_file(assert.h HAVE_ASSERT_H)
|
||||||
|
if(NOT MSVC)
|
||||||
|
check_include_file(dlfcn.h HAVE_DLFCN_H)
|
||||||
|
endif()
|
||||||
check_include_file(fcntl.h HAVE_FCNTL_H)
|
check_include_file(fcntl.h HAVE_FCNTL_H)
|
||||||
|
check_include_file(inttypes.h HAVE_INTTYPES_H)
|
||||||
check_include_file(io.h HAVE_IO_H)
|
check_include_file(io.h HAVE_IO_H)
|
||||||
check_function_exists(jbg_newlen HAVE_JBG_NEWLEN)
|
check_include_file(limits.h HAVE_LIMITS_H)
|
||||||
|
check_include_file(malloc.h HAVE_MALLOC_H)
|
||||||
|
check_include_file(memory.h HAVE_MEMORY_H)
|
||||||
check_include_file(search.h HAVE_SEARCH_H)
|
check_include_file(search.h HAVE_SEARCH_H)
|
||||||
|
check_include_file(stdint.h HAVE_STDINT_H)
|
||||||
check_include_file(string.h HAVE_STRING_H)
|
check_include_file(string.h HAVE_STRING_H)
|
||||||
|
if(NOT MSVC)
|
||||||
|
check_include_file(strings.h HAVE_STRINGS_H)
|
||||||
|
check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
||||||
|
endif()
|
||||||
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Inspired from /usr/share/autoconf/autoconf/c.m4
|
||||||
|
foreach(inline_keyword "inline" "__inline__" "__inline")
|
||||||
|
if(NOT DEFINED C_INLINE)
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS_SAVE ${CMAKE_REQUIRED_DEFINITIONS})
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||||
|
"-Dinline=${inline_keyword}")
|
||||||
|
check_c_source_compiles("
|
||||||
|
typedef int foo_t;
|
||||||
|
static inline foo_t static_foo() {return 0;}
|
||||||
|
foo_t foo(){return 0;}
|
||||||
|
int main(int argc, char *argv[]) {return 0;}"
|
||||||
|
C_HAS_${inline_keyword})
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_SAVE})
|
||||||
|
if(C_HAS_${inline_keyword})
|
||||||
|
set(C_INLINE TRUE)
|
||||||
|
set(INLINE_KEYWORD "${inline_keyword}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if(NOT DEFINED C_INLINE)
|
||||||
|
set(INLINE_KEYWORD)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# Check type sizes
|
||||||
|
# NOTE: Could be replaced with C99 <stdint.h>
|
||||||
|
check_type_size("signed short" SIZEOF_SIGNED_SHORT)
|
||||||
|
check_type_size("unsigned short" SIZEOF_UNSIGNED_SHORT)
|
||||||
|
check_type_size("signed int" SIZEOF_SIGNED_INT)
|
||||||
|
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
|
||||||
|
check_type_size("signed long" SIZEOF_SIGNED_LONG)
|
||||||
|
check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG)
|
||||||
|
check_type_size("signed long long" SIZEOF_SIGNED_LONG_LONG)
|
||||||
|
check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG)
|
||||||
|
check_type_size("unsigned char *" SIZEOF_UNSIGNED_CHAR_P)
|
||||||
|
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES})
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h")
|
||||||
|
check_type_size("size_t" SIZEOF_SIZE_T)
|
||||||
|
check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T)
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE})
|
||||||
|
|
||||||
|
set(TIFF_INT8_T "signed char")
|
||||||
|
set(TIFF_UINT8_T "unsigned char")
|
||||||
|
|
||||||
|
set(TIFF_INT16_T "signed short")
|
||||||
|
set(TIFF_UINT16_T "unsigned short")
|
||||||
|
|
||||||
|
if(SIZEOF_SIGNED_INT EQUAL 4)
|
||||||
|
set(TIFF_INT32_T "signed int")
|
||||||
|
set(TIFF_INT32_FORMAT "%d")
|
||||||
|
elseif(SIZEOF_SIGNED_LONG EQUAL 4)
|
||||||
|
set(TIFF_INT32_T "signed long")
|
||||||
|
set(TIFF_INT32_FORMAT "%ld")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIZEOF_UNSIGNED_INT EQUAL 4)
|
||||||
|
set(TIFF_UINT32_T "unsigned int")
|
||||||
|
set(TIFF_UINT32_FORMAT "%u")
|
||||||
|
elseif(SIZEOF_UNSIGNED_LONG EQUAL 4)
|
||||||
|
set(TIFF_UINT32_T "unsigned long")
|
||||||
|
set(TIFF_UINT32_FORMAT "%lu")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIZEOF_SIGNED_LONG EQUAL 8)
|
||||||
|
set(TIFF_INT64_T "signed long")
|
||||||
|
set(TIFF_INT64_FORMAT "%ld")
|
||||||
|
elseif(SIZEOF_SIGNED_LONG_LONG EQUAL 8)
|
||||||
|
set(TIFF_INT64_T "signed long long")
|
||||||
|
if(MINGW)
|
||||||
|
set(TIFF_INT64_FORMAT "%I64d")
|
||||||
|
else()
|
||||||
|
set(TIFF_INT64_FORMAT "%lld")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIZEOF_UNSIGNED_LONG EQUAL 8)
|
||||||
|
set(TIFF_UINT64_T "unsigned long")
|
||||||
|
set(TIFF_UINT64_FORMAT "%lu")
|
||||||
|
elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL 8)
|
||||||
|
set(TIFF_UINT64_T "unsigned long long")
|
||||||
|
if(MINGW)
|
||||||
|
set(TIFF_UINT64_FORMAT "%I64u")
|
||||||
|
else()
|
||||||
|
set(TIFF_UINT64_FORMAT "%llu")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIZEOF_UNSIGNED_INT EQUAL SIZEOF_SIZE_T)
|
||||||
|
set(TIFF_SIZE_T "unsigned int")
|
||||||
|
set(TIFF_SIZE_FORMAT "%u")
|
||||||
|
elseif(SIZEOF_UNSIGNED_LONG EQUAL SIZEOF_SIZE_T)
|
||||||
|
set(TIFF_SIZE_T "unsigned long")
|
||||||
|
set(TIFF_SIZE_FORMAT "%lu")
|
||||||
|
elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL SIZEOF_SIZE_T)
|
||||||
|
set(TIFF_SIZE_T "unsigned long")
|
||||||
|
if(MINGW)
|
||||||
|
set(TIFF_SIZE_FORMAT "%I64u")
|
||||||
|
else()
|
||||||
|
set(TIFF_SIZE_FORMAT "%llu")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIZEOF_SIGNED_INT EQUAL SIZEOF_UNSIGNED_CHAR_P)
|
||||||
|
set(TIFF_SSIZE_T "signed int")
|
||||||
|
set(TIFF_SSIZE_FORMAT "%d")
|
||||||
|
elseif(SIZEOF_SIGNED_LONG EQUAL SIZEOF_UNSIGNED_CHAR_P)
|
||||||
|
set(TIFF_SSIZE_T "signed long")
|
||||||
|
set(TIFF_SSIZE_FORMAT "%ld")
|
||||||
|
elseif(SIZEOF_SIGNED_LONG_LONG EQUAL SIZEOF_UNSIGNED_CHAR_P)
|
||||||
|
set(TIFF_SSIZE_T "signed long long")
|
||||||
|
if(MINGW)
|
||||||
|
set(TIFF_SSIZE_FORMAT "%I64d")
|
||||||
|
else()
|
||||||
|
set(TIFF_SSIZE_FORMAT "%lld")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT SIZEOF_PTRDIFF_T)
|
||||||
|
set(TIFF_PTRDIFF_T "${TIFF_SSIZE_T}")
|
||||||
|
set(TIFF_PTRDIFF_FORMAT "${SSIZE_FORMAT}")
|
||||||
|
else()
|
||||||
|
set(TIFF_PTRDIFF_T "ptrdiff_t")
|
||||||
|
set(TIFF_PTRDIFF_FORMAT "%ld")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Nonstandard int types
|
||||||
|
if(NOT MSVC)
|
||||||
|
check_type_size(INT8 int8)
|
||||||
|
set(HAVE_INT8 ${INT8})
|
||||||
|
check_type_size(INT16 int16)
|
||||||
|
set(HAVE_INT16 ${INT16})
|
||||||
|
check_type_size(INT32 int32)
|
||||||
|
set(HAVE_INT32 ${INT32})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check functions
|
||||||
|
if(NOT MSVC)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY})
|
||||||
|
check_function_exists(floor HAVE_FLOOR)
|
||||||
|
check_function_exists(pow HAVE_POW)
|
||||||
|
check_function_exists(sqrt HAVE_SQRT)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
check_function_exists(isascii HAVE_ISASCII)
|
||||||
|
check_function_exists(memset HAVE_MEMSET)
|
||||||
check_function_exists(mmap HAVE_MMAP)
|
check_function_exists(mmap HAVE_MMAP)
|
||||||
|
check_function_exists(getopt HAVE_GETOPT)
|
||||||
|
endif()
|
||||||
|
check_function_exists(memmove HAVE_MEMMOVE)
|
||||||
|
check_function_exists(setmode HAVE_SETMODE)
|
||||||
|
check_function_exists(strcasecmp HAVE_STRCASECMP)
|
||||||
|
check_function_exists(strchr HAVE_STRCHR)
|
||||||
|
check_function_exists(strrchr HAVE_STRRCHR)
|
||||||
|
check_function_exists(strstr HAVE_STRSTR)
|
||||||
|
check_function_exists(strtol HAVE_STRTOL)
|
||||||
|
check_function_exists(strtol HAVE_STRTOUL)
|
||||||
|
check_function_exists(strtoull HAVE_STRTOULL)
|
||||||
|
check_function_exists(lfind HAVE_LFIND)
|
||||||
|
|
||||||
|
# May be inlined, so check it compiles:
|
||||||
|
check_c_source_compiles("
|
||||||
|
#include <stdio.h>
|
||||||
|
int main(void) {
|
||||||
|
char buf[10];
|
||||||
|
snprintf(buf, 10, \"Test %d\", 1);
|
||||||
|
return 0;
|
||||||
|
}"
|
||||||
|
HAVE_SNPRINTF)
|
||||||
|
|
||||||
|
if(NOT HAVE_SNPRINTF)
|
||||||
|
add_definitions(-DNEED_LIBPORT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# CPU bit order
|
||||||
|
set(fillorder FILLORDER_MSB2LSB)
|
||||||
|
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
|
||||||
|
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR
|
||||||
|
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*")
|
||||||
|
set(fillorder FILLORDER_LSB2MSB)
|
||||||
|
endif()
|
||||||
|
set(HOST_FILLORDER ${fillorder} CACHE STRING "Native CPU bit order")
|
||||||
|
mark_as_advanced(HOST_FILLORDER)
|
||||||
|
|
||||||
|
# CPU endianness
|
||||||
|
include(TestBigEndian)
|
||||||
|
test_big_endian(bigendian)
|
||||||
|
if(bigendian)
|
||||||
|
set(bigendian ON)
|
||||||
|
else()
|
||||||
|
set(bigendian OFF)
|
||||||
|
endif()
|
||||||
|
set(HOST_BIG_ENDIAN ${bigendian} CACHE STRING "Native CPU bit order")
|
||||||
|
mark_as_advanced(HOST_BIG_ENDIAN)
|
||||||
|
if(HOST_BIG_ENDIAN)
|
||||||
|
set(HOST_BIG_ENDIAN 1)
|
||||||
|
else()
|
||||||
|
set(HOST_BIG_ENDIAN 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# IEEE floating point
|
||||||
|
set(HAVE_IEEEFP 1 CACHE STRING "IEEE floating point is available")
|
||||||
|
mark_as_advanced(HAVE_IEEEFP)
|
||||||
|
|
||||||
|
# Large file support
|
||||||
|
if(UNIX OR MINGW)
|
||||||
|
if(ANDROID AND (ANDROID_NATIVE_API_LEVEL LESS 21) AND (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang))
|
||||||
|
# Android NDK build problem: 'mmap' issue with GCC and API<21
|
||||||
|
else()
|
||||||
|
# This might not catch every possibility catered for by
|
||||||
|
# AC_SYS_LARGEFILE.
|
||||||
|
add_definitions(-D_FILE_OFFSET_BITS=64)
|
||||||
|
set(FILE_OFFSET_BITS 64)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Documentation install directory (default to cmake project docdir)
|
||||||
|
set(LIBTIFF_DOCDIR "${CMAKE_INSTALL_FULL_DOCDIR}")
|
||||||
|
|
||||||
|
# Options to enable and disable internal codecs
|
||||||
|
|
||||||
|
option(ccitt "support for CCITT Group 3 & 4 algorithms" ON)
|
||||||
|
set(CCITT_SUPPORT ${ccitt})
|
||||||
|
|
||||||
|
option(packbits "support for Macintosh PackBits algorithm" ON)
|
||||||
|
set(PACKBITS_SUPPORT ${packbits})
|
||||||
|
|
||||||
|
option(lzw "support for LZW algorithm" ON)
|
||||||
|
set(LZW_SUPPORT ${lzw})
|
||||||
|
|
||||||
|
option(thunder "support for ThunderScan 4-bit RLE algorithm" ON)
|
||||||
|
set(THUNDER_SUPPORT ${thunder})
|
||||||
|
|
||||||
|
option(next "support for NeXT 2-bit RLE algorithm" ON)
|
||||||
|
set(NEXT_SUPPORT ${next})
|
||||||
|
|
||||||
|
option(logluv "support for LogLuv high dynamic range algorithm" ON)
|
||||||
|
set(LOGLUV_SUPPORT ${logluv})
|
||||||
|
|
||||||
|
# Option for Microsoft Document Imaging
|
||||||
|
option(mdi "support for Microsoft Document Imaging" ON)
|
||||||
|
set(MDI_SUPPORT ${mdi})
|
||||||
|
|
||||||
|
# ZLIB
|
||||||
|
set(ZLIB_SUPPORT 0)
|
||||||
|
if(ZLIB_LIBRARY)
|
||||||
|
set(ZLIB_SUPPORT 1)
|
||||||
|
endif()
|
||||||
|
set(ZIP_SUPPORT ${ZLIB_SUPPORT})
|
||||||
|
|
||||||
|
set(PIXARLOG_SUPPORT FALSE)
|
||||||
|
|
||||||
|
# JPEG
|
||||||
|
set(JPEG_SUPPORT FALSE)
|
||||||
|
if(HAVE_JPEG)
|
||||||
|
set(JPEG_SUPPORT TRUE)
|
||||||
|
include_directories(${JPEG_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(old-jpeg "support for Old JPEG compression (read-only)" OFF) # OpenCV: changed to OFF
|
||||||
|
set(OJPEG_SUPPORT FALSE)
|
||||||
|
if(JPEG_SUPPORT AND old-jpeg)
|
||||||
|
set(OJPEG_SUPPORT TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# OpenCV: turned off
|
||||||
|
set(JBIG_SUPPORT 0)
|
||||||
|
set(LZMA_SUPPORT 0) # OpenCV: turned off
|
||||||
|
set(JPEG12_FOUND FALSE) # OpenCV: turned off
|
||||||
|
set(STRIPCHOP_DEFAULT)
|
||||||
|
set(STRIP_SIZE_DEFAULT 8192)
|
||||||
|
|
||||||
|
# Win32 IO
|
||||||
|
set(win32_io FALSE)
|
||||||
if(WIN32 AND NOT WINRT)
|
if(WIN32 AND NOT WINRT)
|
||||||
set(USE_WIN32_FILEIO 1)
|
set(win32_io TRUE)
|
||||||
|
endif()
|
||||||
|
set(USE_WIN32_FILEIO ${win32_io} CACHE BOOL "Use win32 IO system (Microsoft Windows only)")
|
||||||
|
if(USE_WIN32_FILEIO)
|
||||||
|
set(USE_WIN32_FILEIO TRUE)
|
||||||
|
else()
|
||||||
|
set(USE_WIN32_FILEIO FALSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmakein"
|
# Orthogonal features
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h" @ONLY)
|
|
||||||
|
# OpenCV: turned ON
|
||||||
|
set(SUBIFD_SUPPORT 1)
|
||||||
|
set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1)
|
||||||
|
set(CHECK_JPEG_YCBCR_SUBSAMPLING 1)
|
||||||
|
|
||||||
|
if(JPEG_INCLUDE_DIR)
|
||||||
|
list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
if(JPEG12_INCLUDE_DIR)
|
||||||
|
list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
if(JBIG_INCLUDE_DIR)
|
||||||
|
list(APPEND TIFF_INCLUDES ${JBIG_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
if(LIBLZMA_INCLUDE_DIRS)
|
||||||
|
list(APPEND TIFF_INCLUDES ${LIBLZMA_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Libraries required by libtiff
|
||||||
|
set(TIFF_LIBRARY_DEPS)
|
||||||
|
if(M_LIBRARY)
|
||||||
|
list(APPEND TIFF_LIBRARY_DEPS ${M_LIBRARY})
|
||||||
|
endif()
|
||||||
|
if(ZLIB_LIBRARIES)
|
||||||
|
list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
if(JPEG_LIBRARIES)
|
||||||
|
list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
if(JPEG12_LIBRARIES)
|
||||||
|
list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
if(JBIG_LIBRARIES)
|
||||||
|
list(APPEND TIFF_LIBRARY_DEPS ${JBIG_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
if(LIBLZMA_LIBRARIES)
|
||||||
|
list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h"
|
||||||
|
@ONLY)
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h"
|
||||||
|
@ONLY)
|
||||||
|
|
||||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" ${ZLIB_INCLUDE_DIRS})
|
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" ${ZLIB_INCLUDE_DIRS})
|
||||||
|
|
||||||
@@ -68,6 +414,7 @@ set(lib_srcs
|
|||||||
tif_write.c
|
tif_write.c
|
||||||
tif_zip.c
|
tif_zip.c
|
||||||
tif_stream.cxx
|
tif_stream.cxx
|
||||||
|
snprintf.c
|
||||||
t4.h
|
t4.h
|
||||||
tif_dir.h
|
tif_dir.h
|
||||||
tif_fax3.h
|
tif_fax3.h
|
||||||
@@ -79,6 +426,7 @@ set(lib_srcs
|
|||||||
uvcode.h
|
uvcode.h
|
||||||
tiffio.hxx
|
tiffio.hxx
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32 AND NOT WINRT)
|
if(WIN32 AND NOT WINRT)
|
||||||
@@ -92,7 +440,9 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-protot
|
|||||||
-Wmisleading-indentation
|
-Wmisleading-indentation
|
||||||
)
|
)
|
||||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
|
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter)
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter
|
||||||
|
-Wundef # tiffiop.h: #if __clang_major__ >= 4
|
||||||
|
)
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4100 /wd4127 /wd4311 /wd4701 /wd4706) # vs2005
|
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4100 /wd4127 /wd4311 /wd4701 /wd4706) # vs2005
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
|
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267 /wd4305 /wd4306) # vs2008 Win64
|
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267 /wd4305 /wd4306) # vs2008 Win64
|
||||||
@@ -101,10 +451,6 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4456 /wd4457 /wd4312) # vs2015
|
|||||||
|
|
||||||
ocv_warnings_disable(CMAKE_C_FLAGS /wd4267 /wd4244 /wd4018 /wd4311 /wd4312)
|
ocv_warnings_disable(CMAKE_C_FLAGS /wd4267 /wd4244 /wd4018 /wd4311 /wd4312)
|
||||||
|
|
||||||
if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC))
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(${TIFF_LIBRARY} STATIC ${lib_srcs})
|
add_library(${TIFF_LIBRARY} STATIC ${lib_srcs})
|
||||||
target_link_libraries(${TIFF_LIBRARY} ${ZLIB_LIBRARIES})
|
target_link_libraries(${TIFF_LIBRARY} ${ZLIB_LIBRARIES})
|
||||||
|
|
||||||
|
|||||||
Vendored
+38
@@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* Workaround for lack of snprintf(3) in Visual Studio. See
|
||||||
|
* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010/8712996#8712996
|
||||||
|
* It's a trivial wrapper around the builtin _vsnprintf_s and
|
||||||
|
* _vscprintf functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
int _TIFF_vsnprintf_f(char* str, size_t size, const char* format, va_list ap)
|
||||||
|
{
|
||||||
|
int count = -1;
|
||||||
|
|
||||||
|
if (size != 0)
|
||||||
|
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
|
||||||
|
if (count == -1)
|
||||||
|
count = _vscprintf(format, ap);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _TIFF_snprintf_f(char* str, size_t size, const char* format, ...)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, format);
|
||||||
|
count = vsnprintf(str, size, format, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
Vendored
+24
-6
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_aux.c,v 1.26 2010-07-01 15:33:28 dron Exp $ */
|
/* $Id: tif_aux.c,v 1.31 2017-11-17 20:21:00 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1991-1997 Sam Leffler
|
* Copyright (c) 1991-1997 Sam Leffler
|
||||||
@@ -100,7 +100,8 @@ TIFFDefaultTransferFunction(TIFFDirectory* td)
|
|||||||
|
|
||||||
n = ((tmsize_t)1)<<td->td_bitspersample;
|
n = ((tmsize_t)1)<<td->td_bitspersample;
|
||||||
nbytes = n * sizeof (uint16);
|
nbytes = n * sizeof (uint16);
|
||||||
if (!(tf[0] = (uint16 *)_TIFFmalloc(nbytes)))
|
tf[0] = (uint16 *)_TIFFmalloc(nbytes);
|
||||||
|
if (tf[0] == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
tf[0][0] = 0;
|
tf[0][0] = 0;
|
||||||
for (i = 1; i < n; i++) {
|
for (i = 1; i < n; i++) {
|
||||||
@@ -109,10 +110,12 @@ TIFFDefaultTransferFunction(TIFFDirectory* td)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||||
if (!(tf[1] = (uint16 *)_TIFFmalloc(nbytes)))
|
tf[1] = (uint16 *)_TIFFmalloc(nbytes);
|
||||||
|
if(tf[1] == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
_TIFFmemcpy(tf[1], tf[0], nbytes);
|
_TIFFmemcpy(tf[1], tf[0], nbytes);
|
||||||
if (!(tf[2] = (uint16 *)_TIFFmalloc(nbytes)))
|
tf[2] = (uint16 *)_TIFFmalloc(nbytes);
|
||||||
|
if (tf[2] == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
_TIFFmemcpy(tf[2], tf[0], nbytes);
|
_TIFFmemcpy(tf[2], tf[0], nbytes);
|
||||||
}
|
}
|
||||||
@@ -134,7 +137,8 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float))))
|
td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float));
|
||||||
|
if (td->td_refblackwhite == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (td->td_photometric == PHOTOMETRIC_YCBCR) {
|
if (td->td_photometric == PHOTOMETRIC_YCBCR) {
|
||||||
/*
|
/*
|
||||||
@@ -163,7 +167,7 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td)
|
|||||||
* value if the tag is not present in the directory.
|
* value if the tag is not present in the directory.
|
||||||
*
|
*
|
||||||
* NB: We use the value in the directory, rather than
|
* NB: We use the value in the directory, rather than
|
||||||
* explcit values so that defaults exist only one
|
* explicit values so that defaults exist only one
|
||||||
* place in the library -- in TIFFDefaultDirectory.
|
* place in the library -- in TIFFDefaultDirectory.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@@ -210,6 +214,13 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
case TIFFTAG_PREDICTOR:
|
case TIFFTAG_PREDICTOR:
|
||||||
{
|
{
|
||||||
TIFFPredictorState* sp = (TIFFPredictorState*) tif->tif_data;
|
TIFFPredictorState* sp = (TIFFPredictorState*) tif->tif_data;
|
||||||
|
if( sp == NULL )
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||||
|
"Cannot get \"Predictor\" tag as plugin is not configured");
|
||||||
|
*va_arg(ap, uint16*) = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
*va_arg(ap, uint16*) = (uint16) sp->predictor;
|
*va_arg(ap, uint16*) = (uint16) sp->predictor;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -348,6 +359,13 @@ _TIFFUInt64ToDouble(uint64 ui64)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off;
|
||||||
|
}
|
||||||
|
|
||||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||||
/*
|
/*
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
|
|||||||
Vendored
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_close.c,v 1.19 2010-03-10 18:56:48 bfriesen Exp $ */
|
/* $Id: tif_close.c,v 1.21 2016-01-23 21:20:34 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Auxiliary function to free the TIFF structure. Given structure will be
|
* Auxiliary function to free the TIFF structure. Given structure will be
|
||||||
* completetly freed, so you should save opened file handle and pointer
|
* completely freed, so you should save opened file handle and pointer
|
||||||
* to the close procedure in external variables before calling
|
* to the close procedure in external variables before calling
|
||||||
* _TIFFCleanup(), if you will need these ones to close the file.
|
* _TIFFCleanup(), if you will need these ones to close the file.
|
||||||
*
|
*
|
||||||
@@ -62,11 +62,11 @@ TIFFCleanup(TIFF* tif)
|
|||||||
*/
|
*/
|
||||||
while( tif->tif_clientinfo )
|
while( tif->tif_clientinfo )
|
||||||
{
|
{
|
||||||
TIFFClientInfoLink *link = tif->tif_clientinfo;
|
TIFFClientInfoLink *psLink = tif->tif_clientinfo;
|
||||||
|
|
||||||
tif->tif_clientinfo = link->next;
|
tif->tif_clientinfo = psLink->next;
|
||||||
_TIFFfree( link->name );
|
_TIFFfree( psLink->name );
|
||||||
_TIFFfree( link );
|
_TIFFfree( psLink );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
|
if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_codec.c,v 1.15 2010-12-14 12:53:00 dron Exp $ */
|
/* $Id: tif_codec.c,v 1.17 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
|
|||||||
Vendored
+41
-19
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_color.c,v 1.19 2010-12-14 02:22:42 faxguy Exp $ */
|
/* $Id: tif_color.c,v 1.24 2017-05-29 10:12:54 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -126,37 +126,37 @@ TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab,
|
|||||||
const TIFFDisplay *display, float *refWhite)
|
const TIFFDisplay *display, float *refWhite)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double gamma;
|
double dfGamma;
|
||||||
|
|
||||||
cielab->range = CIELABTORGB_TABLE_RANGE;
|
cielab->range = CIELABTORGB_TABLE_RANGE;
|
||||||
|
|
||||||
_TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
|
_TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
|
||||||
|
|
||||||
/* Red */
|
/* Red */
|
||||||
gamma = 1.0 / cielab->display.d_gammaR ;
|
dfGamma = 1.0 / cielab->display.d_gammaR ;
|
||||||
cielab->rstep =
|
cielab->rstep =
|
||||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||||
for(i = 0; i <= cielab->range; i++) {
|
for(i = 0; i <= cielab->range; i++) {
|
||||||
cielab->Yr2r[i] = cielab->display.d_Vrwr
|
cielab->Yr2r[i] = cielab->display.d_Vrwr
|
||||||
* ((float)pow((double)i / cielab->range, gamma));
|
* ((float)pow((double)i / cielab->range, dfGamma));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Green */
|
/* Green */
|
||||||
gamma = 1.0 / cielab->display.d_gammaG ;
|
dfGamma = 1.0 / cielab->display.d_gammaG ;
|
||||||
cielab->gstep =
|
cielab->gstep =
|
||||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||||
for(i = 0; i <= cielab->range; i++) {
|
for(i = 0; i <= cielab->range; i++) {
|
||||||
cielab->Yg2g[i] = cielab->display.d_Vrwg
|
cielab->Yg2g[i] = cielab->display.d_Vrwg
|
||||||
* ((float)pow((double)i / cielab->range, gamma));
|
* ((float)pow((double)i / cielab->range, dfGamma));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Blue */
|
/* Blue */
|
||||||
gamma = 1.0 / cielab->display.d_gammaB ;
|
dfGamma = 1.0 / cielab->display.d_gammaB ;
|
||||||
cielab->bstep =
|
cielab->bstep =
|
||||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||||
for(i = 0; i <= cielab->range; i++) {
|
for(i = 0; i <= cielab->range; i++) {
|
||||||
cielab->Yb2b[i] = cielab->display.d_Vrwb
|
cielab->Yb2b[i] = cielab->display.d_Vrwb
|
||||||
* ((float)pow((double)i / cielab->range, gamma));
|
* ((float)pow((double)i / cielab->range, dfGamma));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init reference white point */
|
/* Init reference white point */
|
||||||
@@ -175,7 +175,7 @@ TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab,
|
|||||||
#define SHIFT 16
|
#define SHIFT 16
|
||||||
#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5))
|
#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5))
|
||||||
#define ONE_HALF ((int32)(1<<(SHIFT-1)))
|
#define ONE_HALF ((int32)(1<<(SHIFT-1)))
|
||||||
#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)(((RW)-(RB)) ? ((RW)-(RB)) : 1))
|
#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)(((RW)-(RB)!=0) ? ((RW)-(RB)) : 1))
|
||||||
#define CLAMP(f,min,max) ((f)<(min)?(min):(f)>(max)?(max):(f))
|
#define CLAMP(f,min,max) ((f)<(min)?(min):(f)>(max)?(max):(f))
|
||||||
#define HICLAMP(f,max) ((f)>(max)?(max):(f))
|
#define HICLAMP(f,max) ((f)>(max)?(max):(f))
|
||||||
|
|
||||||
@@ -186,7 +186,9 @@ TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr,
|
|||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
/* XXX: Only 8-bit YCbCr input supported for now */
|
/* XXX: Only 8-bit YCbCr input supported for now */
|
||||||
Y = HICLAMP(Y, 255), Cb = CLAMP(Cb, 0, 255), Cr = CLAMP(Cr, 0, 255);
|
Y = HICLAMP(Y, 255);
|
||||||
|
Cb = CLAMP(Cb, 0, 255);
|
||||||
|
Cr = CLAMP(Cr, 0, 255);
|
||||||
|
|
||||||
i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
|
i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
|
||||||
*r = CLAMP(i, 0, 255);
|
*r = CLAMP(i, 0, 255);
|
||||||
@@ -197,6 +199,23 @@ TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr,
|
|||||||
*b = CLAMP(i, 0, 255);
|
*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
|
* Initialize the YCbCr->RGB conversion tables. The conversion
|
||||||
* is done according to the 6.0 spec:
|
* is done according to the 6.0 spec:
|
||||||
@@ -236,10 +255,10 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
|
|||||||
ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
|
ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
|
||||||
ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
|
ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
|
||||||
|
|
||||||
{ float f1 = 2-2*LumaRed; int32 D1 = FIX(f1);
|
{ float f1 = 2-2*LumaRed; int32 D1 = FIX(CLAMP(f1,0.0F,2.0F));
|
||||||
float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2);
|
float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(CLAMP(f2,0.0F,2.0F));
|
||||||
float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3);
|
float f3 = 2-2*LumaBlue; int32 D3 = FIX(CLAMP(f3,0.0F,2.0F));
|
||||||
float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4);
|
float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(CLAMP(f4,0.0F,2.0F));
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
#undef LumaBlue
|
#undef LumaBlue
|
||||||
@@ -254,17 +273,20 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
|
|||||||
* constructing tables indexed by the raw pixel data.
|
* constructing tables indexed by the raw pixel data.
|
||||||
*/
|
*/
|
||||||
for (i = 0, x = -128; i < 256; i++, x++) {
|
for (i = 0, x = -128; i < 256; i++, x++) {
|
||||||
int32 Cr = (int32)Code2V(x, refBlackWhite[4] - 128.0F,
|
int32 Cr = (int32)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F,
|
||||||
refBlackWhite[5] - 128.0F, 127);
|
refBlackWhite[5] - 128.0F, 127),
|
||||||
int32 Cb = (int32)Code2V(x, refBlackWhite[2] - 128.0F,
|
-128.0F * 32, 128.0F * 32);
|
||||||
refBlackWhite[3] - 128.0F, 127);
|
int32 Cb = (int32)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F,
|
||||||
|
refBlackWhite[3] - 128.0F, 127),
|
||||||
|
-128.0F * 32, 128.0F * 32);
|
||||||
|
|
||||||
ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
|
ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
|
||||||
ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
|
ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
|
||||||
ycbcr->Cr_g_tab[i] = D2*Cr;
|
ycbcr->Cr_g_tab[i] = D2*Cr;
|
||||||
ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF;
|
ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF;
|
||||||
ycbcr->Y_tab[i] =
|
ycbcr->Y_tab[i] =
|
||||||
(int32)Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255);
|
(int32)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255),
|
||||||
|
-128.0F * 32, 128.0F * 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_compress.c,v 1.22 2010-03-10 18:56:48 bfriesen Exp $ */
|
/* $Id: tif_compress.c,v 1.25 2016-10-25 20:04:22 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -82,10 +82,10 @@ TIFFNoDecode(TIFF* tif, const char* method)
|
|||||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||||
"Compression scheme %u %s decoding is not implemented",
|
"Compression scheme %u %s decoding is not implemented",
|
||||||
tif->tif_dir.td_compression, method);
|
tif->tif_dir.td_compression, method);
|
||||||
return (-1);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
_TIFFNoFixupTags(TIFF* tif)
|
_TIFFNoFixupTags(TIFF* tif)
|
||||||
{
|
{
|
||||||
(void) tif;
|
(void) tif;
|
||||||
@@ -227,7 +227,7 @@ TIFFUnRegisterCODEC(TIFFCodec* c)
|
|||||||
codec_t* cd;
|
codec_t* cd;
|
||||||
codec_t** pcd;
|
codec_t** pcd;
|
||||||
|
|
||||||
for (pcd = ®isteredCODECS; (cd = *pcd); pcd = &cd->next)
|
for (pcd = ®isteredCODECS; (cd = *pcd) != NULL; pcd = &cd->next)
|
||||||
if (cd->info == c) {
|
if (cd->info == c) {
|
||||||
*pcd = cd->next;
|
*pcd = cd->next;
|
||||||
_TIFFfree(cd);
|
_TIFFfree(cd);
|
||||||
|
|||||||
+258
@@ -0,0 +1,258 @@
|
|||||||
|
/* 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. */
|
||||||
|
|
||||||
|
/* Support CCITT Group 3 & 4 algorithms */
|
||||||
|
#cmakedefine CCITT_SUPPORT 1
|
||||||
|
|
||||||
|
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
|
||||||
|
lacking the tag (default enabled). */
|
||||||
|
#cmakedefine CHECK_JPEG_YCBCR_SUBSAMPLING 1
|
||||||
|
|
||||||
|
/* enable partial strip reading for large strips (experimental) */
|
||||||
|
#cmakedefine CHUNKY_STRIP_READ_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support C++ stream API (requires C++ compiler) */
|
||||||
|
#cmakedefine CXX_SUPPORT 1
|
||||||
|
|
||||||
|
/* enable deferred strip/tile offset/size loading (experimental) */
|
||||||
|
#cmakedefine DEFER_STRILE_LOAD 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <assert.h> header file. */
|
||||||
|
#cmakedefine HAVE_ASSERT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
#cmakedefine HAVE_DLFCN_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||||
|
#cmakedefine HAVE_FCNTL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `floor' function. */
|
||||||
|
#cmakedefine HAVE_FLOOR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getopt' function. */
|
||||||
|
#cmakedefine HAVE_GETOPT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <GLUT/glut.h> header file. */
|
||||||
|
#cmakedefine HAVE_GLUT_GLUT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <GL/glut.h> header file. */
|
||||||
|
#cmakedefine HAVE_GL_GLUT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <GL/glu.h> header file. */
|
||||||
|
#cmakedefine HAVE_GL_GLU_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <GL/gl.h> header file. */
|
||||||
|
#cmakedefine HAVE_GL_GL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#cmakedefine HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <io.h> header file. */
|
||||||
|
#cmakedefine HAVE_IO_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `isascii' function. */
|
||||||
|
#cmakedefine HAVE_ISASCII 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `jbg_newlen' function. */
|
||||||
|
#cmakedefine HAVE_JBG_NEWLEN 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `lfind' function. */
|
||||||
|
#cmakedefine HAVE_LFIND 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <limits.h> header file. */
|
||||||
|
#cmakedefine HAVE_LIMITS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <malloc.h> header file. */
|
||||||
|
#cmakedefine HAVE_MALLOC_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memmove' function. */
|
||||||
|
#cmakedefine HAVE_MEMMOVE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#cmakedefine HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `memset' function. */
|
||||||
|
#cmakedefine HAVE_MEMSET 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mmap' function. */
|
||||||
|
#cmakedefine HAVE_MMAP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <OpenGL/glu.h> header file. */
|
||||||
|
#cmakedefine HAVE_OPENGL_GLU_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <OpenGL/gl.h> header file. */
|
||||||
|
#cmakedefine HAVE_OPENGL_GL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `pow' function. */
|
||||||
|
#cmakedefine HAVE_POW 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <search.h> header file. */
|
||||||
|
#cmakedefine HAVE_SEARCH_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `setmode' function. */
|
||||||
|
#cmakedefine HAVE_SETMODE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `snprintf' function. */
|
||||||
|
#cmakedefine HAVE_SNPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sqrt' function. */
|
||||||
|
#cmakedefine HAVE_SQRT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#cmakedefine HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strcasecmp' function. */
|
||||||
|
#cmakedefine HAVE_STRCASECMP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strchr' function. */
|
||||||
|
#cmakedefine HAVE_STRCHR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#cmakedefine HAVE_STRINGS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#cmakedefine HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strrchr' function. */
|
||||||
|
#cmakedefine HAVE_STRRCHR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strstr' function. */
|
||||||
|
#cmakedefine HAVE_STRSTR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strtol' function. */
|
||||||
|
#cmakedefine HAVE_STRTOL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strtoul' function. */
|
||||||
|
#cmakedefine HAVE_STRTOUL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strtoull' function. */
|
||||||
|
#cmakedefine HAVE_STRTOULL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_TIME_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#cmakedefine HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* 8/12 bit libjpeg dual mode enabled */
|
||||||
|
#cmakedefine JPEG_DUAL_MODE_8_12 1
|
||||||
|
|
||||||
|
/* 12bit libjpeg primary include file with path */
|
||||||
|
#define LIBJPEG_12_PATH @LIBJPEG_12_PATH@
|
||||||
|
|
||||||
|
/* Support LZMA2 compression */
|
||||||
|
#cmakedefine LZMA_SUPPORT 1
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "@PACKAGE_NAME@"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING "@PACKAGE_STRING@"
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#define PACKAGE_URL "@PACKAGE_URL@"
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||||
|
|
||||||
|
/* The size of `signed int', as computed by sizeof. */
|
||||||
|
#define SIZEOF_SIGNED_INT @SIZEOF_SIGNED_INT@
|
||||||
|
|
||||||
|
/* The size of `signed long', as computed by sizeof. */
|
||||||
|
#define SIZEOF_SIGNED_LONG @SIZEOF_SIGNED_LONG@
|
||||||
|
|
||||||
|
/* The size of `signed long long', as computed by sizeof. */
|
||||||
|
#define SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@
|
||||||
|
|
||||||
|
/* The size of `signed short', as computed by sizeof. */
|
||||||
|
#define SIZEOF_SIGNED_SHORT @SIZEOF_SIGNED_SHORT@
|
||||||
|
|
||||||
|
/* The size of `unsigned char *', as computed by sizeof. */
|
||||||
|
#define SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@
|
||||||
|
|
||||||
|
/* The size of `unsigned int', as computed by sizeof. */
|
||||||
|
#define SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@
|
||||||
|
|
||||||
|
/* The size of `unsigned long', as computed by sizeof. */
|
||||||
|
#define SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@
|
||||||
|
|
||||||
|
/* The size of `unsigned long long', as computed by sizeof. */
|
||||||
|
#define SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@
|
||||||
|
|
||||||
|
/* The size of `unsigned short', as computed by sizeof. */
|
||||||
|
#define SIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@
|
||||||
|
|
||||||
|
/* Default size of the strip in bytes (when strip chopping enabled) */
|
||||||
|
#define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@
|
||||||
|
|
||||||
|
/* Signed 32-bit type formatter */
|
||||||
|
#define TIFF_INT32_FORMAT "@TIFF_INT32_FORMAT@"
|
||||||
|
|
||||||
|
/* Signed 64-bit type formatter */
|
||||||
|
#define TIFF_INT64_FORMAT "@TIFF_INT64_FORMAT@"
|
||||||
|
|
||||||
|
/* Pointer difference type formatter */
|
||||||
|
#define TIFF_PTRDIFF_FORMAT "@TIFF_PTRDIFF_FORMAT@"
|
||||||
|
|
||||||
|
/* Unsigned size type formatter */
|
||||||
|
#define TIFF_SIZE_FORMAT "@TIFF_SIZE_FORMAT@"
|
||||||
|
|
||||||
|
/* Signed size type formatter */
|
||||||
|
#define TIFF_SSIZE_FORMAT "@TIFF_SSIZE_FORMAT@"
|
||||||
|
|
||||||
|
/* Unsigned 32-bit type formatter */
|
||||||
|
#define TIFF_UINT32_FORMAT "@TIFF_UINT32_FORMAT@"
|
||||||
|
|
||||||
|
/* Unsigned 64-bit type formatter */
|
||||||
|
#define TIFF_UINT64_FORMAT "@TIFF_UINT64_FORMAT@"
|
||||||
|
|
||||||
|
/* Unsigned 8-bit type */
|
||||||
|
#define TIFF_UINT8_T @TIFF_UINT8_T@
|
||||||
|
|
||||||
|
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||||
|
#undef TIME_WITH_SYS_TIME
|
||||||
|
|
||||||
|
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||||
|
#cmakedefine TM_IN_SYS_TIME 1
|
||||||
|
|
||||||
|
/* define to use win32 IO system */
|
||||||
|
#cmakedefine USE_WIN32_FILEIO 1
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#define VERSION "@PACKAGE_VERSION@"
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
|
||||||
|
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||||
|
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#define inline @INLINE_KEYWORD@
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to `long int' if <sys/types.h> does not define. */
|
||||||
|
#undef off_t
|
||||||
|
|
||||||
|
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||||
|
#undef size_t
|
||||||
-162
@@ -1,162 +0,0 @@
|
|||||||
/* libtiff/tif_config.h. Generated from tif_config.h.in by configure. */
|
|
||||||
/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
/* 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
|
|
||||||
|
|
||||||
/* enable deferred strip/tile offset/size loading (experimental) */
|
|
||||||
#undef DEFER_STRILE_LOAD
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <assert.h> header file. */
|
|
||||||
#cmakedefine HAVE_ASSERT_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
|
||||||
#cmakedefine HAVE_FCNTL_H
|
|
||||||
|
|
||||||
/* Define as 0 or 1 according to the floating point format suported by the
|
|
||||||
machine */
|
|
||||||
#define HAVE_IEEEFP 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <io.h> header file. */
|
|
||||||
#cmakedefine HAVE_IO_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `jbg_newlen' function. */
|
|
||||||
#cmakedefine HAVE_JBG_NEWLEN
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `mmap' function. */
|
|
||||||
#cmakedefine HAVE_MMAP
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <search.h> header file. */
|
|
||||||
#cmakedefine HAVE_SEARCH_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <string.h> header file. */
|
|
||||||
#cmakedefine HAVE_STRING_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
|
||||||
#cmakedefine HAVE_SYS_TYPES_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
|
||||||
#ifndef HAVE_UNISTD_H
|
|
||||||
#cmakedefine HAVE_UNISTD_H
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
|
|
||||||
(Intel) */
|
|
||||||
#define HOST_BIGENDIAN @WORDS_BIGENDIAN@
|
|
||||||
|
|
||||||
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
|
|
||||||
#define HOST_FILLORDER FILLORDER_LSB2MSB
|
|
||||||
|
|
||||||
/* Support ISO JBIG compression (requires JBIG-KIT library) */
|
|
||||||
#undef JBIG_SUPPORT
|
|
||||||
|
|
||||||
/* 8/12 bit libjpeg dual mode enabled */
|
|
||||||
/* #undef JPEG_DUAL_MODE_8_12 */
|
|
||||||
|
|
||||||
/* Support JPEG compression (requires IJG JPEG library) */
|
|
||||||
#undef JPEG_SUPPORT
|
|
||||||
|
|
||||||
/* 12bit libjpeg primary include file with path */
|
|
||||||
/* #undef LIBJPEG_12_PATH */
|
|
||||||
|
|
||||||
/* Support LogLuv high dynamic range encoding */
|
|
||||||
#define LOGLUV_SUPPORT 1
|
|
||||||
|
|
||||||
/* Support LZMA2 compression */
|
|
||||||
/* #undef LZMA_SUPPORT */
|
|
||||||
|
|
||||||
/* Support LZW algorithm */
|
|
||||||
#define LZW_SUPPORT 1
|
|
||||||
|
|
||||||
/* Support Microsoft Document Imaging format */
|
|
||||||
#define MDI_SUPPORT 1
|
|
||||||
|
|
||||||
/* Support NeXT 2-bit RLE algorithm */
|
|
||||||
#define NEXT_SUPPORT 1
|
|
||||||
|
|
||||||
/* Support Old JPEG compresson (read-only) */
|
|
||||||
#undef OJPEG_SUPPORT
|
|
||||||
|
|
||||||
/* Support Macintosh PackBits algorithm */
|
|
||||||
#define PACKBITS_SUPPORT 1
|
|
||||||
|
|
||||||
/* Support Pixar log-format algorithm (requires Zlib) */
|
|
||||||
#define PIXARLOG_SUPPORT 1
|
|
||||||
|
|
||||||
/* The size of `unsigned long', as computed by sizeof. */
|
|
||||||
#define SIZEOF_UNSIGNED_LONG 8
|
|
||||||
|
|
||||||
/* Support strip chopping (whether or not to convert single-strip uncompressed
|
|
||||||
images to mutiple strips of specified size to reduce memory usage) */
|
|
||||||
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
|
|
||||||
|
|
||||||
/* Default size of the strip in bytes (when strip chopping enabled) */
|
|
||||||
//#define STRIP_SIZE_DEFAULT 8192
|
|
||||||
|
|
||||||
/* Support ThunderScan 4-bit RLE algorithm */
|
|
||||||
#define THUNDER_SUPPORT 1
|
|
||||||
|
|
||||||
/* Signed 8-bit type */
|
|
||||||
#define TIFF_INT8_T signed char
|
|
||||||
|
|
||||||
/* Signed 16-bit type */
|
|
||||||
#define TIFF_INT16_T signed short
|
|
||||||
|
|
||||||
/* Signed 32-bit type */
|
|
||||||
#define TIFF_INT32_T signed int
|
|
||||||
|
|
||||||
/* Signed size type */
|
|
||||||
#define TIFF_SSIZE_T size_t
|
|
||||||
|
|
||||||
/* Unsigned 8-bit type */
|
|
||||||
#define TIFF_UINT8_T unsigned char
|
|
||||||
|
|
||||||
/* Unsigned 16-bit type */
|
|
||||||
#define TIFF_UINT16_T unsigned short
|
|
||||||
|
|
||||||
/* Unsigned 32-bit type */
|
|
||||||
#define TIFF_UINT32_T unsigned int
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
/* Signed 64-bit type */
|
|
||||||
# define TIFF_INT64_T signed __int64
|
|
||||||
/* Unsigned 64-bit type */
|
|
||||||
# define TIFF_UINT64_T unsigned __int64
|
|
||||||
#else
|
|
||||||
/* Signed 64-bit type */
|
|
||||||
# define TIFF_INT64_T long long
|
|
||||||
/* Signed 64-bit type */
|
|
||||||
# define TIFF_UINT64_T unsigned long long
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Signed 64-bit type formatter */
|
|
||||||
/* Unsigned 64-bit type formatter */
|
|
||||||
#if defined _MSC_VER || defined __MINGW__ || defined __MINGW32__
|
|
||||||
# define TIFF_UINT64_FORMAT "%I64u"
|
|
||||||
# define TIFF_SSIZE_FORMAT "%Iu"
|
|
||||||
#else
|
|
||||||
# define TIFF_UINT64_FORMAT "%llu"
|
|
||||||
# define TIFF_SSIZE_FORMAT "%zd"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* define to use win32 IO system */
|
|
||||||
#cmakedefine USE_WIN32_FILEIO
|
|
||||||
|
|
||||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
|
||||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
|
||||||
#cmakedefine WORDS_BIGENDIAN 1
|
|
||||||
|
|
||||||
/* Support Deflate compression */
|
|
||||||
#define ZIP_SUPPORT 1
|
|
||||||
Vendored
+162
-54
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_dir.c,v 1.113 2012-06-14 20:32:53 fwarmerdam Exp $ */
|
/* $Id: tif_dir.c,v 1.131 2017-07-11 21:38:04 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
* (and also some miscellaneous stuff)
|
* (and also some miscellaneous stuff)
|
||||||
*/
|
*/
|
||||||
#include "tiffiop.h"
|
#include "tiffiop.h"
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are used in the backwards compatibility code...
|
* These are used in the backwards compatibility code...
|
||||||
@@ -43,8 +44,10 @@
|
|||||||
static void
|
static void
|
||||||
setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size)
|
setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size)
|
||||||
{
|
{
|
||||||
if (*vpp)
|
if (*vpp) {
|
||||||
_TIFFfree(*vpp), *vpp = 0;
|
_TIFFfree(*vpp);
|
||||||
|
*vpp = 0;
|
||||||
|
}
|
||||||
if (vp) {
|
if (vp) {
|
||||||
tmsize_t bytes = (tmsize_t)(nmemb * elem_size);
|
tmsize_t bytes = (tmsize_t)(nmemb * elem_size);
|
||||||
if (elem_size && bytes / elem_size == nmemb)
|
if (elem_size && bytes / elem_size == nmemb)
|
||||||
@@ -57,13 +60,13 @@ void _TIFFsetByteArray(void** vpp, void* vp, uint32 n)
|
|||||||
{ setByteArray(vpp, vp, n, 1); }
|
{ setByteArray(vpp, vp, n, 1); }
|
||||||
void _TIFFsetString(char** cpp, char* cp)
|
void _TIFFsetString(char** cpp, char* cp)
|
||||||
{ setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); }
|
{ setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); }
|
||||||
void _TIFFsetNString(char** cpp, char* cp, uint32 n)
|
static void _TIFFsetNString(char** cpp, char* cp, uint32 n)
|
||||||
{ setByteArray((void**) cpp, (void*) cp, n, 1); }
|
{ setByteArray((void**) cpp, (void*) cp, n, 1); }
|
||||||
void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n)
|
void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n)
|
||||||
{ setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); }
|
{ setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); }
|
||||||
void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n)
|
void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n)
|
||||||
{ setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); }
|
{ setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); }
|
||||||
void _TIFFsetLong8Array(uint64** lpp, uint64* lp, uint32 n)
|
static void _TIFFsetLong8Array(uint64** lpp, uint64* lp, uint32 n)
|
||||||
{ setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64)); }
|
{ setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64)); }
|
||||||
void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n)
|
void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n)
|
||||||
{ setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); }
|
{ setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); }
|
||||||
@@ -152,6 +155,15 @@ bad:
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static float TIFFClampDoubleToFloat( double val )
|
||||||
|
{
|
||||||
|
if( val > FLT_MAX )
|
||||||
|
return FLT_MAX;
|
||||||
|
if( val < -FLT_MAX )
|
||||||
|
return -FLT_MAX;
|
||||||
|
return (float)val;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
_TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||||
{
|
{
|
||||||
@@ -160,15 +172,17 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
TIFFDirectory* td = &tif->tif_dir;
|
TIFFDirectory* td = &tif->tif_dir;
|
||||||
int status = 1;
|
int status = 1;
|
||||||
uint32 v32, i, v;
|
uint32 v32, i, v;
|
||||||
|
double dblval;
|
||||||
char* s;
|
char* s;
|
||||||
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
|
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
|
||||||
uint32 standard_tag = tag;
|
uint32 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
|
* We want to force the custom code to be used for custom
|
||||||
* fields even if the tag happens to match a well known
|
* fields even if the tag happens to match a well known
|
||||||
* one - important for reinterpreted handling of standard
|
* one - important for reinterpreted handling of standard
|
||||||
* tag values in custom directories (ie. EXIF)
|
* tag values in custom directories (i.e. EXIF)
|
||||||
*/
|
*/
|
||||||
if (fip->field_bit == FIELD_CUSTOM) {
|
if (fip->field_bit == FIELD_CUSTOM) {
|
||||||
standard_tag = 0;
|
standard_tag = 0;
|
||||||
@@ -252,6 +266,28 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
v = (uint16) va_arg(ap, uint16_vap);
|
v = (uint16) va_arg(ap, uint16_vap);
|
||||||
if (v == 0)
|
if (v == 0)
|
||||||
goto badvalue;
|
goto badvalue;
|
||||||
|
if( v != td->td_samplesperpixel )
|
||||||
|
{
|
||||||
|
/* See http://bugzilla.maptools.org/show_bug.cgi?id=2500 */
|
||||||
|
if( td->td_sminsamplevalue != NULL )
|
||||||
|
{
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,module,
|
||||||
|
"SamplesPerPixel tag value is changing, "
|
||||||
|
"but SMinSampleValue tag was read with a different value. Cancelling it");
|
||||||
|
TIFFClrFieldBit(tif,FIELD_SMINSAMPLEVALUE);
|
||||||
|
_TIFFfree(td->td_sminsamplevalue);
|
||||||
|
td->td_sminsamplevalue = NULL;
|
||||||
|
}
|
||||||
|
if( td->td_smaxsamplevalue != NULL )
|
||||||
|
{
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,module,
|
||||||
|
"SamplesPerPixel tag value is changing, "
|
||||||
|
"but SMaxSampleValue tag was read with a different value. Cancelling it");
|
||||||
|
TIFFClrFieldBit(tif,FIELD_SMAXSAMPLEVALUE);
|
||||||
|
_TIFFfree(td->td_smaxsamplevalue);
|
||||||
|
td->td_smaxsamplevalue = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
td->td_samplesperpixel = (uint16) v;
|
td->td_samplesperpixel = (uint16) v;
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_ROWSPERSTRIP:
|
case TIFFTAG_ROWSPERSTRIP:
|
||||||
@@ -283,10 +319,16 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
setDoubleArrayOneValue(&td->td_smaxsamplevalue, va_arg(ap, double), td->td_samplesperpixel);
|
setDoubleArrayOneValue(&td->td_smaxsamplevalue, va_arg(ap, double), td->td_samplesperpixel);
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_XRESOLUTION:
|
case TIFFTAG_XRESOLUTION:
|
||||||
td->td_xresolution = (float) va_arg(ap, double);
|
dblval = va_arg(ap, double);
|
||||||
|
if( dblval < 0 )
|
||||||
|
goto badvaluedouble;
|
||||||
|
td->td_xresolution = TIFFClampDoubleToFloat( dblval );
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_YRESOLUTION:
|
case TIFFTAG_YRESOLUTION:
|
||||||
td->td_yresolution = (float) va_arg(ap, double);
|
dblval = va_arg(ap, double);
|
||||||
|
if( dblval < 0 )
|
||||||
|
goto badvaluedouble;
|
||||||
|
td->td_yresolution = TIFFClampDoubleToFloat( dblval );
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_PLANARCONFIG:
|
case TIFFTAG_PLANARCONFIG:
|
||||||
v = (uint16) va_arg(ap, uint16_vap);
|
v = (uint16) va_arg(ap, uint16_vap);
|
||||||
@@ -295,10 +337,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
td->td_planarconfig = (uint16) v;
|
td->td_planarconfig = (uint16) v;
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_XPOSITION:
|
case TIFFTAG_XPOSITION:
|
||||||
td->td_xposition = (float) va_arg(ap, double);
|
td->td_xposition = TIFFClampDoubleToFloat( va_arg(ap, double) );
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_YPOSITION:
|
case TIFFTAG_YPOSITION:
|
||||||
td->td_yposition = (float) va_arg(ap, double);
|
td->td_yposition = TIFFClampDoubleToFloat( va_arg(ap, double) );
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_RESOLUTIONUNIT:
|
case TIFFTAG_RESOLUTIONUNIT:
|
||||||
v = (uint16) va_arg(ap, uint16_vap);
|
v = (uint16) va_arg(ap, uint16_vap);
|
||||||
@@ -394,7 +436,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
if ((tif->tif_flags & TIFF_INSUBIFD) == 0) {
|
if ((tif->tif_flags & TIFF_INSUBIFD) == 0) {
|
||||||
td->td_nsubifd = (uint16) va_arg(ap, uint16_vap);
|
td->td_nsubifd = (uint16) va_arg(ap, uint16_vap);
|
||||||
_TIFFsetLong8Array(&td->td_subifd, (uint64*) va_arg(ap, uint64*),
|
_TIFFsetLong8Array(&td->td_subifd, (uint64*) va_arg(ap, uint64*),
|
||||||
(long) td->td_nsubifd);
|
(uint32) td->td_nsubifd);
|
||||||
} else {
|
} else {
|
||||||
TIFFErrorExt(tif->tif_clientdata, module,
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
"%s: Sorry, cannot nest SubIFDs",
|
"%s: Sorry, cannot nest SubIFDs",
|
||||||
@@ -413,7 +455,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
|
v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
|
||||||
for (i = 0; i < v; i++)
|
for (i = 0; i < v; i++)
|
||||||
_TIFFsetShortArray(&td->td_transferfunction[i],
|
_TIFFsetShortArray(&td->td_transferfunction[i],
|
||||||
va_arg(ap, uint16*), 1L<<td->td_bitspersample);
|
va_arg(ap, uint16*), 1U<<td->td_bitspersample);
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_REFERENCEBLACKWHITE:
|
case TIFFTAG_REFERENCEBLACKWHITE:
|
||||||
/* XXX should check for null range */
|
/* XXX should check for null range */
|
||||||
@@ -449,11 +491,11 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
* happens, for example, when tiffcp is used to convert between
|
* happens, for example, when tiffcp is used to convert between
|
||||||
* compression schemes and codec-specific tags are blindly copied.
|
* compression schemes and codec-specific tags are blindly copied.
|
||||||
*/
|
*/
|
||||||
if(fip == NULL || fip->field_bit != FIELD_CUSTOM) {
|
if(fip->field_bit != FIELD_CUSTOM) {
|
||||||
TIFFErrorExt(tif->tif_clientdata, module,
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
"%s: Invalid %stag \"%s\" (not supported by codec)",
|
"%s: Invalid %stag \"%s\" (not supported by codec)",
|
||||||
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
|
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
|
||||||
fip ? fip->field_name : "Unknown");
|
fip->field_name);
|
||||||
status = 0;
|
status = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -571,10 +613,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
handled this way ... likely best if we move it into
|
handled this way ... likely best if we move it into
|
||||||
the directory structure with an explicit field in
|
the directory structure with an explicit field in
|
||||||
libtiff 4.1 and assign it a FIELD_ value */
|
libtiff 4.1 and assign it a FIELD_ value */
|
||||||
uint16 v[2];
|
uint16 v2[2];
|
||||||
v[0] = (uint16)va_arg(ap, int);
|
v2[0] = (uint16)va_arg(ap, int);
|
||||||
v[1] = (uint16)va_arg(ap, int);
|
v2[1] = (uint16)va_arg(ap, int);
|
||||||
_TIFFmemcpy(tv->value, &v, 4);
|
_TIFFmemcpy(tv->value, &v2, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (fip->field_passcount
|
else if (fip->field_passcount
|
||||||
@@ -592,66 +634,66 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
case TIFF_BYTE:
|
case TIFF_BYTE:
|
||||||
case TIFF_UNDEFINED:
|
case TIFF_UNDEFINED:
|
||||||
{
|
{
|
||||||
uint8 v = (uint8)va_arg(ap, int);
|
uint8 v2 = (uint8)va_arg(ap, int);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_SBYTE:
|
case TIFF_SBYTE:
|
||||||
{
|
{
|
||||||
int8 v = (int8)va_arg(ap, int);
|
int8 v2 = (int8)va_arg(ap, int);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_SHORT:
|
case TIFF_SHORT:
|
||||||
{
|
{
|
||||||
uint16 v = (uint16)va_arg(ap, int);
|
uint16 v2 = (uint16)va_arg(ap, int);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_SSHORT:
|
case TIFF_SSHORT:
|
||||||
{
|
{
|
||||||
int16 v = (int16)va_arg(ap, int);
|
int16 v2 = (int16)va_arg(ap, int);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_LONG:
|
case TIFF_LONG:
|
||||||
case TIFF_IFD:
|
case TIFF_IFD:
|
||||||
{
|
{
|
||||||
uint32 v = va_arg(ap, uint32);
|
uint32 v2 = va_arg(ap, uint32);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_SLONG:
|
case TIFF_SLONG:
|
||||||
{
|
{
|
||||||
int32 v = va_arg(ap, int32);
|
int32 v2 = va_arg(ap, int32);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_LONG8:
|
case TIFF_LONG8:
|
||||||
case TIFF_IFD8:
|
case TIFF_IFD8:
|
||||||
{
|
{
|
||||||
uint64 v = va_arg(ap, uint64);
|
uint64 v2 = va_arg(ap, uint64);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_SLONG8:
|
case TIFF_SLONG8:
|
||||||
{
|
{
|
||||||
int64 v = va_arg(ap, int64);
|
int64 v2 = va_arg(ap, int64);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_RATIONAL:
|
case TIFF_RATIONAL:
|
||||||
case TIFF_SRATIONAL:
|
case TIFF_SRATIONAL:
|
||||||
case TIFF_FLOAT:
|
case TIFF_FLOAT:
|
||||||
{
|
{
|
||||||
float v = (float)va_arg(ap, double);
|
float v2 = TIFFClampDoubleToFloat(va_arg(ap, double));
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFF_DOUBLE:
|
case TIFF_DOUBLE:
|
||||||
{
|
{
|
||||||
double v = va_arg(ap, double);
|
double v2 = va_arg(ap, double);
|
||||||
_TIFFmemcpy(val, &v, tv_size);
|
_TIFFmemcpy(val, &v2, tv_size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -664,9 +706,9 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
const TIFFField* fip=TIFFFieldWithTag(tif,tag);
|
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
|
||||||
if (fip)
|
if (fip2)
|
||||||
TIFFSetFieldBit(tif, fip->field_bit);
|
TIFFSetFieldBit(tif, fip2->field_bit);
|
||||||
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,21 +717,31 @@ end:
|
|||||||
return (status);
|
return (status);
|
||||||
badvalue:
|
badvalue:
|
||||||
{
|
{
|
||||||
const TIFFField* fip=TIFFFieldWithTag(tif,tag);
|
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
|
||||||
TIFFErrorExt(tif->tif_clientdata, module,
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
"%s: Bad value %u for \"%s\" tag",
|
"%s: Bad value %u for \"%s\" tag",
|
||||||
tif->tif_name, v,
|
tif->tif_name, v,
|
||||||
fip ? fip->field_name : "Unknown");
|
fip2 ? fip2->field_name : "Unknown");
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
badvalue32:
|
badvalue32:
|
||||||
{
|
{
|
||||||
const TIFFField* fip=TIFFFieldWithTag(tif,tag);
|
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
|
||||||
TIFFErrorExt(tif->tif_clientdata, module,
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
"%s: Bad value %u for \"%s\" tag",
|
"%s: Bad value %u for \"%s\" tag",
|
||||||
tif->tif_name, v32,
|
tif->tif_name, v32,
|
||||||
fip ? fip->field_name : "Unknown");
|
fip2 ? fip2->field_name : "Unknown");
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
badvaluedouble:
|
||||||
|
{
|
||||||
|
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
|
||||||
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
|
"%s: Bad value %f for \"%s\" tag",
|
||||||
|
tif->tif_name, dblval,
|
||||||
|
fip2 ? fip2->field_name : "Unknown");
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
@@ -809,12 +861,42 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
int ret_val = 1;
|
int ret_val = 1;
|
||||||
uint32 standard_tag = tag;
|
uint32 standard_tag = tag;
|
||||||
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
|
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
|
||||||
|
if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if( tag == TIFFTAG_NUMBEROFINKS )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < td->td_customValueCount; i++) {
|
||||||
|
uint16 val;
|
||||||
|
TIFFTagValue *tv = td->td_customValues + i;
|
||||||
|
if (tv->info->field_tag != tag)
|
||||||
|
continue;
|
||||||
|
if( tv->value == NULL )
|
||||||
|
return 0;
|
||||||
|
val = *(uint16 *)tv->value;
|
||||||
|
/* Truncate to SamplesPerPixel, since the */
|
||||||
|
/* setting code for INKNAMES assume that there are SamplesPerPixel */
|
||||||
|
/* inknames. */
|
||||||
|
/* Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2599 */
|
||||||
|
if( val > td->td_samplesperpixel )
|
||||||
|
{
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField",
|
||||||
|
"Truncating NumberOfInks from %u to %u",
|
||||||
|
val, td->td_samplesperpixel);
|
||||||
|
val = td->td_samplesperpixel;
|
||||||
|
}
|
||||||
|
*va_arg(ap, uint16*) = val;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We want to force the custom code to be used for custom
|
* We want to force the custom code to be used for custom
|
||||||
* fields even if the tag happens to match a well known
|
* fields even if the tag happens to match a well known
|
||||||
* one - important for reinterpreted handling of standard
|
* one - important for reinterpreted handling of standard
|
||||||
* tag values in custom directories (ie. EXIF)
|
* tag values in custom directories (i.e. EXIF)
|
||||||
*/
|
*/
|
||||||
if (fip->field_bit == FIELD_CUSTOM) {
|
if (fip->field_bit == FIELD_CUSTOM) {
|
||||||
standard_tag = 0;
|
standard_tag = 0;
|
||||||
@@ -865,7 +947,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
*va_arg(ap, double**) = td->td_sminsamplevalue;
|
*va_arg(ap, double**) = td->td_sminsamplevalue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* libtiff historially treats this as a single value. */
|
/* libtiff historically treats this as a single value. */
|
||||||
uint16 i;
|
uint16 i;
|
||||||
double v = td->td_sminsamplevalue[0];
|
double v = td->td_sminsamplevalue[0];
|
||||||
for (i=1; i < td->td_samplesperpixel; ++i)
|
for (i=1; i < td->td_samplesperpixel; ++i)
|
||||||
@@ -879,7 +961,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
*va_arg(ap, double**) = td->td_smaxsamplevalue;
|
*va_arg(ap, double**) = td->td_smaxsamplevalue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* libtiff historially treats this as a single value. */
|
/* libtiff historically treats this as a single value. */
|
||||||
uint16 i;
|
uint16 i;
|
||||||
double v = td->td_smaxsamplevalue[0];
|
double v = td->td_smaxsamplevalue[0];
|
||||||
for (i=1; i < td->td_samplesperpixel; ++i)
|
for (i=1; i < td->td_samplesperpixel; ++i)
|
||||||
@@ -1006,14 +1088,14 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
* get a tag that is not valid for the image's
|
* get a tag that is not valid for the image's
|
||||||
* codec then we'll arrive here.
|
* codec then we'll arrive here.
|
||||||
*/
|
*/
|
||||||
if( fip == NULL || fip->field_bit != FIELD_CUSTOM )
|
if( fip->field_bit != FIELD_CUSTOM )
|
||||||
{
|
{
|
||||||
TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
|
TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
|
||||||
"%s: Invalid %stag \"%s\" "
|
"%s: Invalid %stag \"%s\" "
|
||||||
"(not supported by codec)",
|
"(not supported by codec)",
|
||||||
tif->tif_name,
|
tif->tif_name,
|
||||||
isPseudoTag(tag) ? "pseudo-" : "",
|
isPseudoTag(tag) ? "pseudo-" : "",
|
||||||
fip ? fip->field_name : "Unknown");
|
fip->field_name);
|
||||||
ret_val = 0;
|
ret_val = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1302,8 +1384,20 @@ TIFFDefaultDirectory(TIFF* tif)
|
|||||||
tif->tif_tagmethods.printdir = NULL;
|
tif->tif_tagmethods.printdir = NULL;
|
||||||
/*
|
/*
|
||||||
* Give client code a chance to install their own
|
* Give client code a chance to install their own
|
||||||
* tag extensions & methods, prior to compression overloads.
|
* 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 i;
|
||||||
|
|
||||||
|
for (i = 0; i < tif->tif_nfieldscompat; i++) {
|
||||||
|
if (tif->tif_fieldscompat[i].allocated_size)
|
||||||
|
_TIFFfree(tif->tif_fieldscompat[i].fields);
|
||||||
|
}
|
||||||
|
_TIFFfree(tif->tif_fieldscompat);
|
||||||
|
tif->tif_nfieldscompat = 0;
|
||||||
|
tif->tif_fieldscompat = NULL;
|
||||||
|
}
|
||||||
if (_TIFFextender)
|
if (_TIFFextender)
|
||||||
(*_TIFFextender)(tif);
|
(*_TIFFextender)(tif);
|
||||||
(void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
(void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
||||||
@@ -1344,6 +1438,7 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
|
|||||||
if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint16))||(poffb>tif->tif_size))
|
if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint16))||(poffb>tif->tif_size))
|
||||||
{
|
{
|
||||||
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
|
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
|
||||||
|
*nextdir=0;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
_TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16));
|
_TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16));
|
||||||
@@ -1453,7 +1548,8 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
|
|||||||
(void) TIFFSeekFile(tif,
|
(void) TIFFSeekFile(tif,
|
||||||
dircount16*20, SEEK_CUR);
|
dircount16*20, SEEK_CUR);
|
||||||
if (!ReadOK(tif, nextdir, sizeof (uint64))) {
|
if (!ReadOK(tif, nextdir, sizeof (uint64))) {
|
||||||
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
|
"%s: Error fetching directory link",
|
||||||
tif->tif_name);
|
tif->tif_name);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -1470,6 +1566,7 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
|
|||||||
uint16
|
uint16
|
||||||
TIFFNumberOfDirectories(TIFF* tif)
|
TIFFNumberOfDirectories(TIFF* tif)
|
||||||
{
|
{
|
||||||
|
static const char module[] = "TIFFNumberOfDirectories";
|
||||||
uint64 nextdir;
|
uint64 nextdir;
|
||||||
uint16 n;
|
uint16 n;
|
||||||
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
||||||
@@ -1478,7 +1575,18 @@ TIFFNumberOfDirectories(TIFF* tif)
|
|||||||
nextdir = tif->tif_header.big.tiff_diroff;
|
nextdir = tif->tif_header.big.tiff_diroff;
|
||||||
n = 0;
|
n = 0;
|
||||||
while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL))
|
while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL))
|
||||||
n++;
|
{
|
||||||
|
if (n != 65535) {
|
||||||
|
++n;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
|
"Directory count exceeded 65535 limit,"
|
||||||
|
" giving up on counting.");
|
||||||
|
return (65535);
|
||||||
|
}
|
||||||
|
}
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_dir.h,v 1.54 2011-02-18 20:53:05 fwarmerdam Exp $ */
|
/* $Id: tif_dir.h,v 1.55 2017-06-01 12:44:04 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -291,6 +291,7 @@ struct _TIFFField {
|
|||||||
extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32);
|
extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32);
|
||||||
extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType);
|
extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType);
|
||||||
extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType);
|
extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType);
|
||||||
|
extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+183
-20
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_dirinfo.c,v 1.114 2011-05-17 00:21:17 fwarmerdam Exp $ */
|
/* $Id: tif_dirinfo.c,v 1.127 2017-06-01 12:44:04 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -37,15 +37,23 @@
|
|||||||
*
|
*
|
||||||
* NOTE: The second field (field_readcount) and third field (field_writecount)
|
* NOTE: The second field (field_readcount) and third field (field_writecount)
|
||||||
* sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3)
|
* sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3)
|
||||||
* and TIFFTAG_SPP (-2). The macros should be used but would throw off
|
* and TIFF_SPP (-2). The macros should be used but would throw off
|
||||||
* the formatting of the code, so please interprete the -1, -2 and -3
|
* the formatting of the code, so please interpret the -1, -2 and -3
|
||||||
* values accordingly.
|
* values accordingly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static TIFFFieldArray tiffFieldArray;
|
/* const object should be initialized */
|
||||||
static TIFFFieldArray exifFieldArray;
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning( push )
|
||||||
|
#pragma warning( disable : 4132 )
|
||||||
|
#endif
|
||||||
|
static const TIFFFieldArray tiffFieldArray;
|
||||||
|
static const TIFFFieldArray exifFieldArray;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning( pop )
|
||||||
|
#endif
|
||||||
|
|
||||||
static TIFFField
|
static const TIFFField
|
||||||
tiffFields[] = {
|
tiffFields[] = {
|
||||||
{ TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL },
|
{ 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_SUBFILETYPE, 1, 0, "OldSubfileType", NULL },
|
{ TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "OldSubfileType", NULL },
|
||||||
@@ -95,7 +103,7 @@ tiffFields[] = {
|
|||||||
{ TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", 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_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_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 },
|
{ 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_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_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_CUSTOM, 1, 0, "NumberOfInks", NULL },
|
{ TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NumberOfInks", NULL },
|
||||||
@@ -128,11 +136,13 @@ tiffFields[] = {
|
|||||||
{ TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", 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_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_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL },
|
||||||
|
{ TIFFTAG_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFARepeatPatternDim", NULL },
|
||||||
|
{ TIFFTAG_CFAPATTERN, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFAPattern" , NULL},
|
||||||
{ TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL },
|
{ TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL },
|
||||||
/* end Pixar tags */
|
/* end Pixar tags */
|
||||||
{ TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL },
|
{ TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL },
|
||||||
{ TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Photoshop", NULL },
|
{ TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Photoshop", NULL },
|
||||||
{ TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "EXIFIFDOffset", &exifFieldArray },
|
{ TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "EXIFIFDOffset", (TIFFFieldArray*) &exifFieldArray },
|
||||||
{ TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ICC Profile", NULL },
|
{ TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ICC Profile", NULL },
|
||||||
{ TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GPSIFDOffset", NULL },
|
{ TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GPSIFDOffset", NULL },
|
||||||
{ TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL },
|
{ TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL },
|
||||||
@@ -190,12 +200,26 @@ tiffFields[] = {
|
|||||||
{ TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotPreProfileMatrix", NULL },
|
{ TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotPreProfileMatrix", NULL },
|
||||||
{ TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentICCProfile", NULL },
|
{ TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentICCProfile", NULL },
|
||||||
{ TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentPreProfileMatrix", NULL },
|
{ TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentPreProfileMatrix", NULL },
|
||||||
/* end DNG tags */
|
|
||||||
/* begin pseudo tags */
|
|
||||||
{ TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL},
|
{ TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL},
|
||||||
|
/* end DNG tags */
|
||||||
|
/* begin TIFF/FX tags */
|
||||||
|
{ TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Indexed", NULL },
|
||||||
|
{ TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GlobalParametersIFD", NULL },
|
||||||
|
{ TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ProfileType", NULL },
|
||||||
|
{ TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "FaxProfile", NULL },
|
||||||
|
{ TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CodingMethods", NULL },
|
||||||
|
{ TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "VersionYear", NULL },
|
||||||
|
{ TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ModeNumber", NULL },
|
||||||
|
{ TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Decode", NULL },
|
||||||
|
{ TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ImageBaseColor", NULL },
|
||||||
|
{ TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "T82Options", NULL },
|
||||||
|
{ TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "StripRowCounts", NULL },
|
||||||
|
{ TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ImageLayer", NULL },
|
||||||
|
/* end TIFF/FX tags */
|
||||||
|
/* begin pseudo tags */
|
||||||
};
|
};
|
||||||
|
|
||||||
static TIFFField
|
static const TIFFField
|
||||||
exifFields[] = {
|
exifFields[] = {
|
||||||
{ EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL },
|
{ EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL },
|
||||||
{ EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL },
|
{ EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL },
|
||||||
@@ -255,13 +279,13 @@ exifFields[] = {
|
|||||||
{ EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL }
|
{ EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static TIFFFieldArray
|
static const TIFFFieldArray
|
||||||
tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), tiffFields };
|
tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), (TIFFField*) tiffFields };
|
||||||
static TIFFFieldArray
|
static const TIFFFieldArray
|
||||||
exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), exifFields };
|
exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), (TIFFField*) exifFields };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have our own local lfind() equivelent to avoid subtle differences
|
* We have our own local lfind() equivalent to avoid subtle differences
|
||||||
* in types passed to lfind() on different systems.
|
* in types passed to lfind() on different systems.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -348,7 +372,7 @@ _TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n)
|
|||||||
{
|
{
|
||||||
static const char module[] = "_TIFFMergeFields";
|
static const char module[] = "_TIFFMergeFields";
|
||||||
static const char reason[] = "for fields array";
|
static const char reason[] = "for fields array";
|
||||||
TIFFField** tp;
|
/* TIFFField** tp; */
|
||||||
uint32 i;
|
uint32 i;
|
||||||
|
|
||||||
tif->tif_foundfield = NULL;
|
tif->tif_foundfield = NULL;
|
||||||
@@ -369,7 +393,7 @@ _TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp = tif->tif_fields + tif->tif_nfields;
|
/* tp = tif->tif_fields + tif->tif_nfields; */
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
const TIFFField *fip =
|
const TIFFField *fip =
|
||||||
TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
|
TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
|
||||||
@@ -505,7 +529,7 @@ TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt)
|
|||||||
return tif->tif_foundfield = (ret ? *ret : NULL);
|
return tif->tif_foundfield = (ret ? *ret : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIFFField*
|
static const TIFFField*
|
||||||
_TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt)
|
_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 key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
|
||||||
@@ -556,6 +580,42 @@ TIFFFieldWithName(TIFF* tif, const char *field_name)
|
|||||||
return (fip);
|
return (fip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
const TIFFField*
|
const TIFFField*
|
||||||
_TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt)
|
_TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt)
|
||||||
|
|
||||||
@@ -661,7 +721,7 @@ _TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
|
|||||||
* note that this name is a special sign to TIFFClose() and
|
* note that this name is a special sign to TIFFClose() and
|
||||||
* _TIFFSetupFields() to free the field
|
* _TIFFSetupFields() to free the field
|
||||||
*/
|
*/
|
||||||
sprintf(fld->field_name, "Tag %d", (int) tag);
|
(void) snprintf(fld->field_name, 32, "Tag %d", (int) tag);
|
||||||
|
|
||||||
return fld;
|
return fld;
|
||||||
}
|
}
|
||||||
@@ -896,6 +956,109 @@ TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
|
|||||||
return 0;
|
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:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Vendored
+289
-86
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_dirread.c,v 1.174 2012-02-01 02:24:47 fwarmerdam Exp $ */
|
/* $Id: tif_dirread.c,v 1.218 2017-09-09 21:44:42 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -40,6 +40,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tiffiop.h"
|
#include "tiffiop.h"
|
||||||
|
#include <float.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define IGNORE 0 /* tag placeholder used below */
|
#define IGNORE 0 /* tag placeholder used below */
|
||||||
#define FAILED_FII ((uint32) -1)
|
#define FAILED_FII ((uint32) -1)
|
||||||
@@ -166,6 +168,8 @@ static int TIFFFetchSubjectDistance(TIFF*, TIFFDirEntry*);
|
|||||||
static void ChopUpSingleUncompressedStrip(TIFF*);
|
static void ChopUpSingleUncompressedStrip(TIFF*);
|
||||||
static uint64 TIFFReadUInt64(const uint8 *value);
|
static uint64 TIFFReadUInt64(const uint8 *value);
|
||||||
|
|
||||||
|
static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount );
|
||||||
|
|
||||||
typedef union _UInt64Aligned_t
|
typedef union _UInt64Aligned_t
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
@@ -633,6 +637,8 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* d
|
|||||||
err=TIFFReadDirEntryCheckedDouble(tif,direntry,&m);
|
err=TIFFReadDirEntryCheckedDouble(tif,direntry,&m);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
if (err!=TIFFReadDirEntryErrOk)
|
||||||
return(err);
|
return(err);
|
||||||
|
if ((m > FLT_MAX) || (m < FLT_MIN))
|
||||||
|
return(TIFFReadDirEntryErrRange);
|
||||||
*value=(float)m;
|
*value=(float)m;
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
@@ -762,13 +768,80 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* di
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value)
|
|
||||||
|
#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 offset, tmsize_t size, void** pdest)
|
||||||
|
{
|
||||||
|
#if SIZEOF_VOIDP == 8 || 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_VOIDP == 8 || SIZEOF_SIZE_T == 8
|
||||||
|
if( to_read >= threshold && threshold < MAX_THRESHOLD )
|
||||||
|
{
|
||||||
|
to_read = threshold;
|
||||||
|
threshold *= THRESHOLD_MULTIPLIER;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
new_dest = (uint8*) _TIFFrealloc(
|
||||||
|
*pdest, already_read + to_read);
|
||||||
|
if( new_dest == NULL )
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||||
|
"Failed to allocate memory for %s "
|
||||||
|
"(%ld elements of %ld bytes each)",
|
||||||
|
"TIFFReadDirEntryArray",
|
||||||
|
(long) 1, (long) (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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit(
|
||||||
|
TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize,
|
||||||
|
void** value, uint64 maxcount)
|
||||||
{
|
{
|
||||||
int typesize;
|
int typesize;
|
||||||
uint32 datasize;
|
uint32 datasize;
|
||||||
void* data;
|
void* data;
|
||||||
|
uint64 target_count64;
|
||||||
typesize=TIFFDataWidth(direntry->tdir_type);
|
typesize=TIFFDataWidth(direntry->tdir_type);
|
||||||
if ((direntry->tdir_count==0)||(typesize==0))
|
|
||||||
|
target_count64 = (direntry->tdir_count > maxcount) ?
|
||||||
|
maxcount : direntry->tdir_count;
|
||||||
|
|
||||||
|
if ((target_count64==0)||(typesize==0))
|
||||||
{
|
{
|
||||||
*value=0;
|
*value=0;
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
@@ -780,17 +853,30 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* d
|
|||||||
* in either the current data type or the dest data type. This also
|
* in either the current data type or the dest data type. This also
|
||||||
* avoids problems with overflow of tmsize_t on 32bit systems.
|
* avoids problems with overflow of tmsize_t on 32bit systems.
|
||||||
*/
|
*/
|
||||||
if ((uint64)(2147483647/typesize)<direntry->tdir_count)
|
if ((uint64)(2147483647/typesize)<target_count64)
|
||||||
return(TIFFReadDirEntryErrSizesan);
|
return(TIFFReadDirEntryErrSizesan);
|
||||||
if ((uint64)(2147483647/desttypesize)<direntry->tdir_count)
|
if ((uint64)(2147483647/desttypesize)<target_count64)
|
||||||
return(TIFFReadDirEntryErrSizesan);
|
return(TIFFReadDirEntryErrSizesan);
|
||||||
|
|
||||||
*count=(uint32)direntry->tdir_count;
|
*count=(uint32)target_count64;
|
||||||
datasize=(*count)*typesize;
|
datasize=(*count)*typesize;
|
||||||
assert((tmsize_t)datasize>0);
|
assert((tmsize_t)datasize>0);
|
||||||
|
|
||||||
|
if( isMapped(tif) && datasize > (uint32)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");
|
data=_TIFFCheckMalloc(tif, *count, typesize, "ReadDirEntryArray");
|
||||||
if (data==0)
|
if (data==0)
|
||||||
return(TIFFReadDirEntryErrAlloc);
|
return(TIFFReadDirEntryErrAlloc);
|
||||||
|
}
|
||||||
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
||||||
{
|
{
|
||||||
if (datasize<=4)
|
if (datasize<=4)
|
||||||
@@ -801,7 +887,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* d
|
|||||||
uint32 offset = direntry->tdir_offset.toff_long;
|
uint32 offset = direntry->tdir_offset.toff_long;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong(&offset);
|
TIFFSwabLong(&offset);
|
||||||
|
if( isMapped(tif) )
|
||||||
err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data);
|
err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data);
|
||||||
|
else
|
||||||
|
err=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
if (err!=TIFFReadDirEntryErrOk)
|
||||||
{
|
{
|
||||||
_TIFFfree(data);
|
_TIFFfree(data);
|
||||||
@@ -819,7 +908,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* d
|
|||||||
uint64 offset = direntry->tdir_offset.toff_long8;
|
uint64 offset = direntry->tdir_offset.toff_long8;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong8(&offset);
|
TIFFSwabLong8(&offset);
|
||||||
err=TIFFReadDirEntryData(tif,offset,(tmsize_t)datasize,data);
|
if( isMapped(tif) )
|
||||||
|
err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data);
|
||||||
|
else
|
||||||
|
err=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
if (err!=TIFFReadDirEntryErrOk)
|
||||||
{
|
{
|
||||||
_TIFFfree(data);
|
_TIFFfree(data);
|
||||||
@@ -831,6 +923,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* d
|
|||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value)
|
||||||
|
{
|
||||||
|
return TIFFReadDirEntryArrayWithLimit(tif, direntry, count,
|
||||||
|
desttypesize, value, ~((uint64)0));
|
||||||
|
}
|
||||||
|
|
||||||
static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value)
|
static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value)
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
@@ -1860,7 +1958,8 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt
|
|||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value)
|
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit(
|
||||||
|
TIFF* tif, TIFFDirEntry* direntry, uint64** value, uint64 maxcount)
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint32 count;
|
uint32 count;
|
||||||
@@ -1880,7 +1979,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEnt
|
|||||||
default:
|
default:
|
||||||
return(TIFFReadDirEntryErrType);
|
return(TIFFReadDirEntryErrType);
|
||||||
}
|
}
|
||||||
err=TIFFReadDirEntryArray(tif,direntry,&count,8,&origdata);
|
err=TIFFReadDirEntryArrayWithLimit(tif,direntry,&count,8,&origdata,maxcount);
|
||||||
if ((err!=TIFFReadDirEntryErrOk)||(origdata==0))
|
if ((err!=TIFFReadDirEntryErrOk)||(origdata==0))
|
||||||
{
|
{
|
||||||
*value=0;
|
*value=0;
|
||||||
@@ -2026,6 +2125,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEnt
|
|||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value)
|
||||||
|
{
|
||||||
|
return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value, ~((uint64)0));
|
||||||
|
}
|
||||||
|
|
||||||
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value)
|
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value)
|
||||||
{
|
{
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
@@ -2172,11 +2276,6 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_TIFFfree(origdata);
|
_TIFFfree(origdata);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
|
||||||
{
|
|
||||||
_TIFFfree(data);
|
|
||||||
return(err);
|
|
||||||
}
|
|
||||||
*value=data;
|
*value=data;
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
@@ -2409,16 +2508,18 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt
|
|||||||
ma=(double*)origdata;
|
ma=(double*)origdata;
|
||||||
mb=data;
|
mb=data;
|
||||||
for (n=0; n<count; n++)
|
for (n=0; n<count; n++)
|
||||||
*mb++=(float)(*ma++);
|
{
|
||||||
|
double val = *ma++;
|
||||||
|
if( val > FLT_MAX )
|
||||||
|
val = FLT_MAX;
|
||||||
|
else if( val < -FLT_MAX )
|
||||||
|
val = -FLT_MAX;
|
||||||
|
*mb++=(float)val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_TIFFfree(origdata);
|
_TIFFfree(origdata);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
|
||||||
{
|
|
||||||
_TIFFfree(data);
|
|
||||||
return(err);
|
|
||||||
}
|
|
||||||
*value=data;
|
*value=data;
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
@@ -2657,11 +2758,6 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_TIFFfree(origdata);
|
_TIFFfree(origdata);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
|
||||||
{
|
|
||||||
_TIFFfree(data);
|
|
||||||
return(err);
|
|
||||||
}
|
|
||||||
*value=data;
|
*value=data;
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
@@ -2723,11 +2819,6 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntr
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_TIFFfree(origdata);
|
_TIFFfree(origdata);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
|
||||||
{
|
|
||||||
_TIFFfree(data);
|
|
||||||
return(err);
|
|
||||||
}
|
|
||||||
*value=data;
|
*value=data;
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
@@ -2741,7 +2832,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDi
|
|||||||
if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel)
|
if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel)
|
||||||
return(TIFFReadDirEntryErrCount);
|
return(TIFFReadDirEntryErrCount);
|
||||||
err=TIFFReadDirEntryShortArray(tif,direntry,&m);
|
err=TIFFReadDirEntryShortArray(tif,direntry,&m);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
if (err!=TIFFReadDirEntryErrOk || m == NULL)
|
||||||
return(err);
|
return(err);
|
||||||
na=m;
|
na=m;
|
||||||
nb=tif->tif_dir.td_samplesperpixel;
|
nb=tif->tif_dir.td_samplesperpixel;
|
||||||
@@ -2890,7 +2981,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFD
|
|||||||
m.l = direntry->tdir_offset.toff_long8;
|
m.l = direntry->tdir_offset.toff_long8;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabArrayOfLong(m.i,2);
|
TIFFSwabArrayOfLong(m.i,2);
|
||||||
if (m.i[0]==0)
|
/* 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;
|
*value=0.0;
|
||||||
else
|
else
|
||||||
*value=(double)m.i[0]/(double)m.i[1];
|
*value=(double)m.i[0]/(double)m.i[1];
|
||||||
@@ -2918,7 +3012,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF
|
|||||||
m.l=direntry->tdir_offset.toff_long8;
|
m.l=direntry->tdir_offset.toff_long8;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabArrayOfLong(m.i,2);
|
TIFFSwabArrayOfLong(m.i,2);
|
||||||
if ((int32)m.i[0]==0)
|
/* 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)m.i[0]==0 || m.i[1]==0)
|
||||||
*value=0.0;
|
*value=0.0;
|
||||||
else
|
else
|
||||||
*value=(double)((int32)m.i[0])/(double)m.i[1];
|
*value=(double)((int32)m.i[0])/(double)m.i[1];
|
||||||
@@ -3194,11 +3291,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value)
|
|||||||
/*
|
/*
|
||||||
* Largest 32-bit unsigned integer value.
|
* Largest 32-bit unsigned integer value.
|
||||||
*/
|
*/
|
||||||
#if defined(__WIN32__) && defined(_MSC_VER)
|
#define TIFF_UINT32_MAX 0xFFFFFFFFU
|
||||||
# define TIFF_UINT32_MAX 0xFFFFFFFFI64
|
|
||||||
#else
|
|
||||||
# define TIFF_UINT32_MAX 0xFFFFFFFFLL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static enum TIFFReadDirEntryErr
|
static enum TIFFReadDirEntryErr
|
||||||
TIFFReadDirEntryCheckRangeLongLong8(uint64 value)
|
TIFFReadDirEntryCheckRangeLongLong8(uint64 value)
|
||||||
@@ -3212,7 +3305,7 @@ TIFFReadDirEntryCheckRangeLongLong8(uint64 value)
|
|||||||
static enum TIFFReadDirEntryErr
|
static enum TIFFReadDirEntryErr
|
||||||
TIFFReadDirEntryCheckRangeLongSlong8(int64 value)
|
TIFFReadDirEntryCheckRangeLongSlong8(int64 value)
|
||||||
{
|
{
|
||||||
if ((value<0) || (value > TIFF_UINT32_MAX))
|
if ((value < 0) || (value > (int64) TIFF_UINT32_MAX))
|
||||||
return(TIFFReadDirEntryErrRange);
|
return(TIFFReadDirEntryErrRange);
|
||||||
else
|
else
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
@@ -3229,19 +3322,21 @@ TIFFReadDirEntryCheckRangeSlongLong(uint32 value)
|
|||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check that the 8-byte unsigned value can fit in a 4-byte unsigned range */
|
||||||
static enum TIFFReadDirEntryErr
|
static enum TIFFReadDirEntryErr
|
||||||
TIFFReadDirEntryCheckRangeSlongLong8(uint64 value)
|
TIFFReadDirEntryCheckRangeSlongLong8(uint64 value)
|
||||||
{
|
{
|
||||||
if (value > 0x7FFFFFFFUL)
|
if (value > 0x7FFFFFFF)
|
||||||
return(TIFFReadDirEntryErrRange);
|
return(TIFFReadDirEntryErrRange);
|
||||||
else
|
else
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check that the 8-byte signed value can fit in a 4-byte signed range */
|
||||||
static enum TIFFReadDirEntryErr
|
static enum TIFFReadDirEntryErr
|
||||||
TIFFReadDirEntryCheckRangeSlongSlong8(int64 value)
|
TIFFReadDirEntryCheckRangeSlongSlong8(int64 value)
|
||||||
{
|
{
|
||||||
if ((value < 0L-0x80000000L) || (value > 0x7FFFFFFFL))
|
if ((value < 0-((int64) 0x7FFFFFFF+1)) || (value > 0x7FFFFFFF))
|
||||||
return(TIFFReadDirEntryErrRange);
|
return(TIFFReadDirEntryErrRange);
|
||||||
else
|
else
|
||||||
return(TIFFReadDirEntryErrOk);
|
return(TIFFReadDirEntryErrOk);
|
||||||
@@ -3286,11 +3381,7 @@ TIFFReadDirEntryCheckRangeLong8Slong8(int64 value)
|
|||||||
/*
|
/*
|
||||||
* Largest 64-bit signed integer value.
|
* Largest 64-bit signed integer value.
|
||||||
*/
|
*/
|
||||||
#if defined(__WIN32__) && defined(_MSC_VER)
|
#define TIFF_INT64_MAX ((int64)(((uint64) ~0) >> 1))
|
||||||
# define TIFF_INT64_MAX 0x7FFFFFFFFFFFFFFFI64
|
|
||||||
#else
|
|
||||||
# define TIFF_INT64_MAX 0x7FFFFFFFFFFFFFFFLL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static enum TIFFReadDirEntryErr
|
static enum TIFFReadDirEntryErr
|
||||||
TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value)
|
TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value)
|
||||||
@@ -3313,10 +3404,15 @@ TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest)
|
|||||||
if (!ReadOK(tif,dest,size))
|
if (!ReadOK(tif,dest,size))
|
||||||
return(TIFFReadDirEntryErrIo);
|
return(TIFFReadDirEntryErrIo);
|
||||||
} else {
|
} else {
|
||||||
tmsize_t ma,mb;
|
size_t ma,mb;
|
||||||
ma=(tmsize_t)offset;
|
ma=(size_t)offset;
|
||||||
mb=ma+size;
|
mb=ma+size;
|
||||||
if (((uint64)ma!=offset)||(mb<ma)||(mb<size)||(mb>tif->tif_size))
|
if (((uint64)ma!=offset)
|
||||||
|
|| (mb < ma)
|
||||||
|
|| (mb - ma != (size_t) size)
|
||||||
|
|| (mb < (size_t)size)
|
||||||
|
|| (mb > (size_t)tif->tif_size)
|
||||||
|
)
|
||||||
return(TIFFReadDirEntryErrIo);
|
return(TIFFReadDirEntryErrIo);
|
||||||
_TIFFmemcpy(dest,tif->tif_base+ma,size);
|
_TIFFmemcpy(dest,tif->tif_base+ma,size);
|
||||||
}
|
}
|
||||||
@@ -3369,7 +3465,7 @@ static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, c
|
|||||||
} else {
|
} else {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case TIFFReadDirEntryErrCount:
|
case TIFFReadDirEntryErrCount:
|
||||||
TIFFErrorExt(tif->tif_clientdata, module,
|
TIFFWarningExt(tif->tif_clientdata, module,
|
||||||
"Incorrect count for \"%s\"; tag ignored",
|
"Incorrect count for \"%s\"; tag ignored",
|
||||||
tagname);
|
tagname);
|
||||||
break;
|
break;
|
||||||
@@ -3425,6 +3521,8 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
const TIFFField* fip;
|
const TIFFField* fip;
|
||||||
uint32 fii=FAILED_FII;
|
uint32 fii=FAILED_FII;
|
||||||
toff_t nextdiroff;
|
toff_t nextdiroff;
|
||||||
|
int bitspersample_read = FALSE;
|
||||||
|
|
||||||
tif->tif_diroff=tif->tif_nextdiroff;
|
tif->tif_diroff=tif->tif_nextdiroff;
|
||||||
if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff))
|
if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff))
|
||||||
return 0; /* last offset or bad offset (IFD looping) */
|
return 0; /* last offset or bad offset (IFD looping) */
|
||||||
@@ -3476,12 +3574,12 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
* the fields to check type and tag information,
|
* the fields to check type and tag information,
|
||||||
* and to extract info required to size data
|
* and to extract info required to size data
|
||||||
* structures. A second pass is made afterwards
|
* structures. A second pass is made afterwards
|
||||||
* to read in everthing not taken in the first pass.
|
* to read in everything not taken in the first pass.
|
||||||
* But we must process the Compression tag first
|
* But we must process the Compression tag first
|
||||||
* in order to merge in codec-private tag definitions (otherwise
|
* in order to merge in codec-private tag definitions (otherwise
|
||||||
* we may get complaints about unknown tags). However, the
|
* we may get complaints about unknown tags). However, the
|
||||||
* Compression tag may be dependent on the SamplesPerPixel
|
* Compression tag may be dependent on the SamplesPerPixel
|
||||||
* tag value because older TIFF specs permited Compression
|
* tag value because older TIFF specs permitted Compression
|
||||||
* to be written as a SamplesPerPixel-count tag entry.
|
* to be written as a SamplesPerPixel-count tag entry.
|
||||||
* Thus if we don't first figure out the correct SamplesPerPixel
|
* Thus if we don't first figure out the correct SamplesPerPixel
|
||||||
* tag value then we may end up ignoring the Compression tag
|
* tag value then we may end up ignoring the Compression tag
|
||||||
@@ -3583,6 +3681,10 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
goto bad;
|
goto bad;
|
||||||
dp->tdir_tag=IGNORE;
|
dp->tdir_tag=IGNORE;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if( !_TIFFCheckFieldIsValidForCodec(tif, dp->tdir_tag) )
|
||||||
|
dp->tdir_tag=IGNORE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3645,6 +3747,7 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE)
|
if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||||
tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel;
|
tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel;
|
||||||
if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) {
|
if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) {
|
||||||
|
#ifdef OJPEG_SUPPORT
|
||||||
if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG) &&
|
if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG) &&
|
||||||
(isTiled(tif)==0) &&
|
(isTiled(tif)==0) &&
|
||||||
(tif->tif_dir.td_nstrips==1)) {
|
(tif->tif_dir.td_nstrips==1)) {
|
||||||
@@ -3657,7 +3760,9 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
* JpegInterchangeFormat stream.
|
* JpegInterchangeFormat stream.
|
||||||
*/
|
*/
|
||||||
TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
|
TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
MissingRequired(tif,
|
MissingRequired(tif,
|
||||||
isTiled(tif) ? "TileOffsets" : "StripOffsets");
|
isTiled(tif) ? "TileOffsets" : "StripOffsets");
|
||||||
goto bad;
|
goto bad;
|
||||||
@@ -3682,7 +3787,7 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
* DataType and SampleFormat tags are supposed to be
|
* DataType and SampleFormat tags are supposed to be
|
||||||
* written as one value/sample, but some vendors
|
* written as one value/sample, but some vendors
|
||||||
* incorrectly write one value only -- so we accept
|
* incorrectly write one value only -- so we accept
|
||||||
* that as well (yech). Other vendors write correct
|
* that as well (yuck). Other vendors write correct
|
||||||
* value for NumberOfSamples, but incorrect one for
|
* value for NumberOfSamples, but incorrect one for
|
||||||
* BitsPerSample and friends, and we will read this
|
* BitsPerSample and friends, and we will read this
|
||||||
* too.
|
* too.
|
||||||
@@ -3701,13 +3806,15 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
}
|
}
|
||||||
if (!TIFFSetField(tif,dp->tdir_tag,value))
|
if (!TIFFSetField(tif,dp->tdir_tag,value))
|
||||||
goto bad;
|
goto bad;
|
||||||
|
if( dp->tdir_tag == TIFFTAG_BITSPERSAMPLE )
|
||||||
|
bitspersample_read = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_SMINSAMPLEVALUE:
|
case TIFFTAG_SMINSAMPLEVALUE:
|
||||||
case TIFFTAG_SMAXSAMPLEVALUE:
|
case TIFFTAG_SMAXSAMPLEVALUE:
|
||||||
{
|
{
|
||||||
|
|
||||||
double *data = 0;
|
double *data = NULL;
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint32 saved_flags;
|
uint32 saved_flags;
|
||||||
int m;
|
int m;
|
||||||
@@ -3736,6 +3843,14 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
_TIFFmemcpy( &(tif->tif_dir.td_stripoffset_entry),
|
_TIFFmemcpy( &(tif->tif_dir.td_stripoffset_entry),
|
||||||
dp, sizeof(TIFFDirEntry) );
|
dp, sizeof(TIFFDirEntry) );
|
||||||
#else
|
#else
|
||||||
|
if( tif->tif_dir.td_stripoffset != NULL )
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
|
"tif->tif_dir.td_stripoffset is "
|
||||||
|
"already allocated. Likely duplicated "
|
||||||
|
"StripOffsets/TileOffsets tag");
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripoffset))
|
if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripoffset))
|
||||||
goto bad;
|
goto bad;
|
||||||
#endif
|
#endif
|
||||||
@@ -3746,6 +3861,14 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
_TIFFmemcpy( &(tif->tif_dir.td_stripbytecount_entry),
|
_TIFFmemcpy( &(tif->tif_dir.td_stripbytecount_entry),
|
||||||
dp, sizeof(TIFFDirEntry) );
|
dp, sizeof(TIFFDirEntry) );
|
||||||
#else
|
#else
|
||||||
|
if( tif->tif_dir.td_stripbytecount != NULL )
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
|
"tif->tif_dir.td_stripbytecount is "
|
||||||
|
"already allocated. Likely duplicated "
|
||||||
|
"StripByteCounts/TileByteCounts tag");
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripbytecount))
|
if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripbytecount))
|
||||||
goto bad;
|
goto bad;
|
||||||
#endif
|
#endif
|
||||||
@@ -3758,7 +3881,32 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
uint32 countrequired;
|
uint32 countrequired;
|
||||||
uint32 incrementpersample;
|
uint32 incrementpersample;
|
||||||
uint16* value=NULL;
|
uint16* value=NULL;
|
||||||
countpersample=(1L<<tif->tif_dir.td_bitspersample);
|
/* 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);
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,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);
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,module,
|
||||||
|
"Ignoring %s because BitsPerSample=%d>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)countpersample))
|
if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample))
|
||||||
{
|
{
|
||||||
countrequired=countpersample;
|
countrequired=countpersample;
|
||||||
@@ -3936,12 +4084,14 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
#define BYTECOUNTLOOKSBAD \
|
#define BYTECOUNTLOOKSBAD \
|
||||||
( (tif->tif_dir.td_stripbytecount[0] == 0 && tif->tif_dir.td_stripoffset[0] != 0) || \
|
( (tif->tif_dir.td_stripbytecount[0] == 0 && tif->tif_dir.td_stripoffset[0] != 0) || \
|
||||||
(tif->tif_dir.td_compression == COMPRESSION_NONE && \
|
(tif->tif_dir.td_compression == COMPRESSION_NONE && \
|
||||||
tif->tif_dir.td_stripbytecount[0] > TIFFGetFileSize(tif) - tif->tif_dir.td_stripoffset[0]) || \
|
(tif->tif_dir.td_stripoffset[0] <= TIFFGetFileSize(tif) && \
|
||||||
|
tif->tif_dir.td_stripbytecount[0] > TIFFGetFileSize(tif) - tif->tif_dir.td_stripoffset[0])) || \
|
||||||
(tif->tif_mode == O_RDONLY && \
|
(tif->tif_mode == O_RDONLY && \
|
||||||
tif->tif_dir.td_compression == COMPRESSION_NONE && \
|
tif->tif_dir.td_compression == COMPRESSION_NONE && \
|
||||||
tif->tif_dir.td_stripbytecount[0] < TIFFScanlineSize64(tif) * tif->tif_dir.td_imagelength) )
|
tif->tif_dir.td_stripbytecount[0] < TIFFScanlineSize64(tif) * tif->tif_dir.td_imagelength) )
|
||||||
|
|
||||||
} else if (tif->tif_dir.td_nstrips == 1
|
} else if (tif->tif_dir.td_nstrips == 1
|
||||||
|
&& !(tif->tif_flags&TIFF_ISTILED)
|
||||||
&& _TIFFFillStriles(tif)
|
&& _TIFFFillStriles(tif)
|
||||||
&& tif->tif_dir.td_stripoffset[0] != 0
|
&& tif->tif_dir.td_stripoffset[0] != 0
|
||||||
&& BYTECOUNTLOOKSBAD) {
|
&& BYTECOUNTLOOKSBAD) {
|
||||||
@@ -4146,7 +4296,7 @@ TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read custom directory from the arbitarry offset.
|
* Read custom directory from the arbitrary offset.
|
||||||
* The code is very similar to TIFFReadDirectory().
|
* The code is very similar to TIFFReadDirectory().
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@@ -4273,7 +4423,9 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
|
|||||||
TIFFDirectory *td = &tif->tif_dir;
|
TIFFDirectory *td = &tif->tif_dir;
|
||||||
uint32 strip;
|
uint32 strip;
|
||||||
|
|
||||||
_TIFFFillStriles( tif );
|
/* Do not try to load stripbytecount as we will compute it */
|
||||||
|
if( !_TIFFFillStrilesInternal( tif, 0 ) )
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (td->td_stripbytecount)
|
if (td->td_stripbytecount)
|
||||||
_TIFFfree(td->td_stripbytecount);
|
_TIFFfree(td->td_stripbytecount);
|
||||||
@@ -4295,7 +4447,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
|
|||||||
/* calculate amount of space used by indirect values */
|
/* calculate amount of space used by indirect values */
|
||||||
for (dp = dir, n = dircount; n > 0; n--, dp++)
|
for (dp = dir, n = dircount; n > 0; n--, dp++)
|
||||||
{
|
{
|
||||||
uint32 typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type);
|
uint32 typewidth;
|
||||||
uint64 datasize;
|
uint64 datasize;
|
||||||
typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type);
|
typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type);
|
||||||
if (typewidth == 0) {
|
if (typewidth == 0) {
|
||||||
@@ -4317,6 +4469,10 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
|
|||||||
}
|
}
|
||||||
space+=datasize;
|
space+=datasize;
|
||||||
}
|
}
|
||||||
|
if( filesize < space )
|
||||||
|
/* we should perhaps return in error ? */
|
||||||
|
space = filesize;
|
||||||
|
else
|
||||||
space = filesize - space;
|
space = filesize - space;
|
||||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||||
space /= td->td_samplesperpixel;
|
space /= td->td_samplesperpixel;
|
||||||
@@ -4372,6 +4528,11 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff)
|
|||||||
|
|
||||||
if (diroff == 0) /* no more directories */
|
if (diroff == 0) /* no more directories */
|
||||||
return 0;
|
return 0;
|
||||||
|
if (tif->tif_dirnumber == 65535) {
|
||||||
|
TIFFErrorExt(tif->tif_clientdata, "TIFFCheckDirOffset",
|
||||||
|
"Cannot handle more than 65535 TIFF directories");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (n = 0; n < tif->tif_dirnumber && tif->tif_dirlist; n++) {
|
for (n = 0; n < tif->tif_dirnumber && tif->tif_dirlist; n++) {
|
||||||
if (tif->tif_dirlist[n] == diroff)
|
if (tif->tif_dirlist[n] == diroff)
|
||||||
@@ -4380,7 +4541,7 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff)
|
|||||||
|
|
||||||
tif->tif_dirnumber++;
|
tif->tif_dirnumber++;
|
||||||
|
|
||||||
if (tif->tif_dirnumber > tif->tif_dirlistsize) {
|
if (tif->tif_dirlist == NULL || tif->tif_dirnumber > tif->tif_dirlistsize) {
|
||||||
uint64* new_dirlist;
|
uint64* new_dirlist;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -4391,6 +4552,9 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff)
|
|||||||
tif->tif_dirnumber, 2 * sizeof(uint64), "for IFD list");
|
tif->tif_dirnumber, 2 * sizeof(uint64), "for IFD list");
|
||||||
if (!new_dirlist)
|
if (!new_dirlist)
|
||||||
return 0;
|
return 0;
|
||||||
|
if( tif->tif_dirnumber >= 32768 )
|
||||||
|
tif->tif_dirlistsize = 65535;
|
||||||
|
else
|
||||||
tif->tif_dirlistsize = 2 * tif->tif_dirnumber;
|
tif->tif_dirlistsize = 2 * tif->tif_dirnumber;
|
||||||
tif->tif_dirlist = new_dirlist;
|
tif->tif_dirlist = new_dirlist;
|
||||||
}
|
}
|
||||||
@@ -4567,7 +4731,6 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmsize_t m;
|
|
||||||
uint64 dircount64;
|
uint64 dircount64;
|
||||||
m=off+sizeof(uint64);
|
m=off+sizeof(uint64);
|
||||||
if ((m<off)||(m<(tmsize_t)sizeof(uint64))||(m>tif->tif_size)) {
|
if ((m<off)||(m<(tmsize_t)sizeof(uint64))||(m>tif->tif_size)) {
|
||||||
@@ -4703,6 +4866,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fip=tif->tif_fields[fii];
|
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_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 */
|
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;
|
err=TIFFReadDirEntryErrOk;
|
||||||
@@ -4761,7 +4925,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
|
|||||||
break;
|
break;
|
||||||
case TIFF_SETGET_UINT8:
|
case TIFF_SETGET_UINT8:
|
||||||
{
|
{
|
||||||
uint8 data;
|
uint8 data=0;
|
||||||
assert(fip->field_readcount==1);
|
assert(fip->field_readcount==1);
|
||||||
assert(fip->field_passcount==0);
|
assert(fip->field_passcount==0);
|
||||||
err=TIFFReadDirEntryByte(tif,dp,&data);
|
err=TIFFReadDirEntryByte(tif,dp,&data);
|
||||||
@@ -4855,8 +5019,12 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
|
|||||||
uint16* data;
|
uint16* data;
|
||||||
assert(fip->field_readcount==2);
|
assert(fip->field_readcount==2);
|
||||||
assert(fip->field_passcount==0);
|
assert(fip->field_passcount==0);
|
||||||
if (dp->tdir_count!=2)
|
if (dp->tdir_count!=2) {
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,module,
|
||||||
|
"incorrect count for field \"%s\", expected 2, got %d",
|
||||||
|
fip->field_name,(int)dp->tdir_count);
|
||||||
return(0);
|
return(0);
|
||||||
|
}
|
||||||
err=TIFFReadDirEntryShortArray(tif,dp,&data);
|
err=TIFFReadDirEntryShortArray(tif,dp,&data);
|
||||||
if (err==TIFFReadDirEntryErrOk)
|
if (err==TIFFReadDirEntryErrOk)
|
||||||
{
|
{
|
||||||
@@ -4873,8 +5041,12 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
|
|||||||
uint8* data;
|
uint8* data;
|
||||||
assert(fip->field_readcount>=1);
|
assert(fip->field_readcount>=1);
|
||||||
assert(fip->field_passcount==0);
|
assert(fip->field_passcount==0);
|
||||||
if (dp->tdir_count!=(uint64)fip->field_readcount)
|
if (dp->tdir_count!=(uint64)fip->field_readcount) {
|
||||||
/* corrupt file */;
|
TIFFWarningExt(tif->tif_clientdata,module,
|
||||||
|
"incorrect count for field \"%s\", expected %d, got %d",
|
||||||
|
fip->field_name,(int) fip->field_readcount, (int)dp->tdir_count);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err=TIFFReadDirEntryByteArray(tif,dp,&data);
|
err=TIFFReadDirEntryByteArray(tif,dp,&data);
|
||||||
@@ -4969,6 +5141,11 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
|
|||||||
if (err==TIFFReadDirEntryErrOk)
|
if (err==TIFFReadDirEntryErrOk)
|
||||||
{
|
{
|
||||||
int m;
|
int m;
|
||||||
|
if( dp->tdir_count > 0 && data[dp->tdir_count-1] != '\0' )
|
||||||
|
{
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte. Forcing it to be null",fip->field_name);
|
||||||
|
data[dp->tdir_count-1] = '\0';
|
||||||
|
}
|
||||||
m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data);
|
m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data);
|
||||||
if (data!=0)
|
if (data!=0)
|
||||||
_TIFFfree(data);
|
_TIFFfree(data);
|
||||||
@@ -5141,6 +5318,11 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
|
|||||||
if (err==TIFFReadDirEntryErrOk)
|
if (err==TIFFReadDirEntryErrOk)
|
||||||
{
|
{
|
||||||
int m;
|
int m;
|
||||||
|
if( dp->tdir_count > 0 && data[dp->tdir_count-1] != '\0' )
|
||||||
|
{
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte. Forcing it to be null",fip->field_name);
|
||||||
|
data[dp->tdir_count-1] = '\0';
|
||||||
|
}
|
||||||
m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data);
|
m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data);
|
||||||
if (data!=0)
|
if (data!=0)
|
||||||
_TIFFfree(data);
|
_TIFFfree(data);
|
||||||
@@ -5342,7 +5524,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
|
|||||||
}
|
}
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
if (err!=TIFFReadDirEntryErrOk)
|
||||||
{
|
{
|
||||||
TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",recover);
|
TIFFReadDirEntryOutputErr(tif,err,module,fip->field_name,recover);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
return(1);
|
return(1);
|
||||||
@@ -5358,28 +5540,39 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp)
|
|||||||
static const char module[] = "TIFFFetchStripThing";
|
static const char module[] = "TIFFFetchStripThing";
|
||||||
enum TIFFReadDirEntryErr err;
|
enum TIFFReadDirEntryErr err;
|
||||||
uint64* data;
|
uint64* data;
|
||||||
err=TIFFReadDirEntryLong8Array(tif,dir,&data);
|
err=TIFFReadDirEntryLong8ArrayWithLimit(tif,dir,&data,nstrips);
|
||||||
if (err!=TIFFReadDirEntryErrOk)
|
if (err!=TIFFReadDirEntryErrOk)
|
||||||
{
|
{
|
||||||
const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag);
|
const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag);
|
||||||
TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0);
|
TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (dir->tdir_count!=(uint64)nstrips)
|
if (dir->tdir_count<(uint64)nstrips)
|
||||||
{
|
{
|
||||||
uint64* resizeddata;
|
uint64* resizeddata;
|
||||||
|
const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag);
|
||||||
|
const char* pszMax = getenv("LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT");
|
||||||
|
uint32 max_nstrips = 1000000;
|
||||||
|
if( pszMax )
|
||||||
|
max_nstrips = (uint32) atoi(pszMax);
|
||||||
|
TIFFReadDirEntryOutputErr(tif,TIFFReadDirEntryErrCount,
|
||||||
|
module,
|
||||||
|
fip ? fip->field_name : "unknown tagname",
|
||||||
|
( nstrips <= max_nstrips ) );
|
||||||
|
|
||||||
|
if( nstrips > max_nstrips )
|
||||||
|
{
|
||||||
|
_TIFFfree(data);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for strip array");
|
resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for strip array");
|
||||||
if (resizeddata==0) {
|
if (resizeddata==0) {
|
||||||
_TIFFfree(data);
|
_TIFFfree(data);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (dir->tdir_count<(uint64)nstrips)
|
|
||||||
{
|
|
||||||
_TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64));
|
_TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64));
|
||||||
_TIFFmemset(resizeddata+(uint32)dir->tdir_count,0,(nstrips-(uint32)dir->tdir_count)*sizeof(uint64));
|
_TIFFmemset(resizeddata+(uint32)dir->tdir_count,0,(nstrips-(uint32)dir->tdir_count)*sizeof(uint64));
|
||||||
}
|
|
||||||
else
|
|
||||||
_TIFFmemcpy(resizeddata,data,nstrips*sizeof(uint64));
|
|
||||||
_TIFFfree(data);
|
_TIFFfree(data);
|
||||||
data=resizeddata;
|
data=resizeddata;
|
||||||
}
|
}
|
||||||
@@ -5461,13 +5654,17 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
|
|||||||
uint64 rowblockbytes;
|
uint64 rowblockbytes;
|
||||||
uint64 stripbytes;
|
uint64 stripbytes;
|
||||||
uint32 strip;
|
uint32 strip;
|
||||||
uint64 nstrips64;
|
uint32 nstrips;
|
||||||
uint32 nstrips32;
|
|
||||||
uint32 rowsperstrip;
|
uint32 rowsperstrip;
|
||||||
uint64* newcounts;
|
uint64* newcounts;
|
||||||
uint64* newoffsets;
|
uint64* newoffsets;
|
||||||
|
|
||||||
bytecount = td->td_stripbytecount[0];
|
bytecount = td->td_stripbytecount[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 = td->td_stripoffset[0];
|
offset = td->td_stripoffset[0];
|
||||||
assert(td->td_planarconfig == PLANARCONFIG_CONTIG);
|
assert(td->td_planarconfig == PLANARCONFIG_CONTIG);
|
||||||
if ((td->td_photometric == PHOTOMETRIC_YCBCR)&&
|
if ((td->td_photometric == PHOTOMETRIC_YCBCR)&&
|
||||||
@@ -5493,18 +5690,17 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* never increase the number of strips in an image
|
* never increase the number of rows per strip
|
||||||
*/
|
*/
|
||||||
if (rowsperstrip >= td->td_rowsperstrip)
|
if (rowsperstrip >= td->td_rowsperstrip)
|
||||||
return;
|
return;
|
||||||
nstrips64 = TIFFhowmany_64(bytecount, stripbytes);
|
nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip);
|
||||||
if ((nstrips64==0)||(nstrips64>0xFFFFFFFF)) /* something is wonky, do nothing. */
|
if( nstrips == 0 )
|
||||||
return;
|
return;
|
||||||
nstrips32 = (uint32)nstrips64;
|
|
||||||
|
|
||||||
newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64),
|
newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64),
|
||||||
"for chopped \"StripByteCounts\" array");
|
"for chopped \"StripByteCounts\" array");
|
||||||
newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64),
|
newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64),
|
||||||
"for chopped \"StripOffsets\" array");
|
"for chopped \"StripOffsets\" array");
|
||||||
if (newcounts == NULL || newoffsets == NULL) {
|
if (newcounts == NULL || newoffsets == NULL) {
|
||||||
/*
|
/*
|
||||||
@@ -5521,18 +5717,18 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
|
|||||||
* Fill the strip information arrays with new bytecounts and offsets
|
* Fill the strip information arrays with new bytecounts and offsets
|
||||||
* that reflect the broken-up format.
|
* that reflect the broken-up format.
|
||||||
*/
|
*/
|
||||||
for (strip = 0; strip < nstrips32; strip++) {
|
for (strip = 0; strip < nstrips; strip++) {
|
||||||
if (stripbytes > bytecount)
|
if (stripbytes > bytecount)
|
||||||
stripbytes = bytecount;
|
stripbytes = bytecount;
|
||||||
newcounts[strip] = stripbytes;
|
newcounts[strip] = stripbytes;
|
||||||
newoffsets[strip] = offset;
|
newoffsets[strip] = stripbytes ? offset : 0;
|
||||||
offset += stripbytes;
|
offset += stripbytes;
|
||||||
bytecount -= stripbytes;
|
bytecount -= stripbytes;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Replace old single strip info with multi-strip info.
|
* Replace old single strip info with multi-strip info.
|
||||||
*/
|
*/
|
||||||
td->td_stripsperimage = td->td_nstrips = nstrips32;
|
td->td_stripsperimage = td->td_nstrips = nstrips;
|
||||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
|
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
|
||||||
|
|
||||||
_TIFFfree(td->td_stripbytecount);
|
_TIFFfree(td->td_stripbytecount);
|
||||||
@@ -5543,6 +5739,11 @@ ChopUpSingleUncompressedStrip(TIFF* tif)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int _TIFFFillStriles( TIFF *tif )
|
int _TIFFFillStriles( TIFF *tif )
|
||||||
|
{
|
||||||
|
return _TIFFFillStrilesInternal( tif, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount )
|
||||||
{
|
{
|
||||||
#if defined(DEFER_STRILE_LOAD)
|
#if defined(DEFER_STRILE_LOAD)
|
||||||
register TIFFDirectory *td = &tif->tif_dir;
|
register TIFFDirectory *td = &tif->tif_dir;
|
||||||
@@ -5560,7 +5761,8 @@ int _TIFFFillStriles( TIFF *tif )
|
|||||||
return_value = 0;
|
return_value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TIFFFetchStripThing(tif,&(td->td_stripbytecount_entry),
|
if (loadStripByteCount &&
|
||||||
|
!TIFFFetchStripThing(tif,&(td->td_stripbytecount_entry),
|
||||||
td->td_nstrips,&td->td_stripbytecount))
|
td->td_nstrips,&td->td_stripbytecount))
|
||||||
{
|
{
|
||||||
return_value = 0;
|
return_value = 0;
|
||||||
@@ -5585,6 +5787,7 @@ int _TIFFFillStriles( TIFF *tif )
|
|||||||
return return_value;
|
return return_value;
|
||||||
#else /* !defined(DEFER_STRILE_LOAD) */
|
#else /* !defined(DEFER_STRILE_LOAD) */
|
||||||
(void) tif;
|
(void) tif;
|
||||||
|
(void) loadStripByteCount;
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+167
-53
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_dirwrite.c,v 1.76 2011-02-18 20:53:04 fwarmerdam Exp $ */
|
/* $Id: tif_dirwrite.c,v 1.89 2017-08-23 13:33:42 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
* Directory Write Support Routines.
|
* Directory Write Support Routines.
|
||||||
*/
|
*/
|
||||||
#include "tiffiop.h"
|
#include "tiffiop.h"
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#ifdef HAVE_IEEEFP
|
#ifdef HAVE_IEEEFP
|
||||||
#define TIFFCvtNativeToIEEEFloat(tif, n, fp)
|
#define TIFFCvtNativeToIEEEFloat(tif, n, fp)
|
||||||
@@ -542,7 +543,19 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
{
|
{
|
||||||
if (!isTiled(tif))
|
if (!isTiled(tif))
|
||||||
{
|
{
|
||||||
if (!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_STRIPOFFSETS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripoffset))
|
/* td_stripoffset 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 != NULL &&
|
||||||
|
!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_STRIPOFFSETS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripoffset))
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -645,7 +658,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
assert(o->field_passcount==0);
|
assert(o->field_passcount==0);
|
||||||
TIFFGetField(tif,o->field_tag,&pb);
|
TIFFGetField(tif,o->field_tag,&pb);
|
||||||
pa=(uint32)(strlen(pb));
|
pa=(uint32)(strlen(pb));
|
||||||
if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,o->field_tag,pa,pb))
|
if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,(uint16)o->field_tag,pa,pb))
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -656,7 +669,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
assert(o->field_readcount==1);
|
assert(o->field_readcount==1);
|
||||||
assert(o->field_passcount==0);
|
assert(o->field_passcount==0);
|
||||||
TIFFGetField(tif,o->field_tag,&p);
|
TIFFGetField(tif,o->field_tag,&p);
|
||||||
if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,o->field_tag,p))
|
if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,(uint16)o->field_tag,p))
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -667,7 +680,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
assert(o->field_readcount==1);
|
assert(o->field_readcount==1);
|
||||||
assert(o->field_passcount==0);
|
assert(o->field_passcount==0);
|
||||||
TIFFGetField(tif,o->field_tag,&p);
|
TIFFGetField(tif,o->field_tag,&p);
|
||||||
if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,o->field_tag,p))
|
if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,(uint16)o->field_tag,p))
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -679,7 +692,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
assert(o->field_readcount==TIFF_VARIABLE2);
|
assert(o->field_readcount==TIFF_VARIABLE2);
|
||||||
assert(o->field_passcount==1);
|
assert(o->field_passcount==1);
|
||||||
TIFFGetField(tif,o->field_tag,&pa,&pb);
|
TIFFGetField(tif,o->field_tag,&pa,&pb);
|
||||||
if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,o->field_tag,pa,pb))
|
if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,(uint16)o->field_tag,pa,pb))
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -693,70 +706,72 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
}
|
}
|
||||||
for (m=0; m<(uint32)(tif->tif_dir.td_customValueCount); m++)
|
for (m=0; m<(uint32)(tif->tif_dir.td_customValueCount); m++)
|
||||||
{
|
{
|
||||||
|
uint16 tag = (uint16)tif->tif_dir.td_customValues[m].info->field_tag;
|
||||||
|
uint32 count = tif->tif_dir.td_customValues[m].count;
|
||||||
switch (tif->tif_dir.td_customValues[m].info->field_type)
|
switch (tif->tif_dir.td_customValues[m].info->field_type)
|
||||||
{
|
{
|
||||||
case TIFF_ASCII:
|
case TIFF_ASCII:
|
||||||
if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_UNDEFINED:
|
case TIFF_UNDEFINED:
|
||||||
if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_BYTE:
|
case TIFF_BYTE:
|
||||||
if (!TIFFWriteDirectoryTagByteArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagByteArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_SBYTE:
|
case TIFF_SBYTE:
|
||||||
if (!TIFFWriteDirectoryTagSbyteArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagSbyteArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_SHORT:
|
case TIFF_SHORT:
|
||||||
if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_SSHORT:
|
case TIFF_SSHORT:
|
||||||
if (!TIFFWriteDirectoryTagSshortArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagSshortArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_LONG:
|
case TIFF_LONG:
|
||||||
if (!TIFFWriteDirectoryTagLongArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagLongArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_SLONG:
|
case TIFF_SLONG:
|
||||||
if (!TIFFWriteDirectoryTagSlongArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagSlongArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_LONG8:
|
case TIFF_LONG8:
|
||||||
if (!TIFFWriteDirectoryTagLong8Array(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagLong8Array(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_SLONG8:
|
case TIFF_SLONG8:
|
||||||
if (!TIFFWriteDirectoryTagSlong8Array(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagSlong8Array(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_RATIONAL:
|
case TIFF_RATIONAL:
|
||||||
if (!TIFFWriteDirectoryTagRationalArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagRationalArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_SRATIONAL:
|
case TIFF_SRATIONAL:
|
||||||
if (!TIFFWriteDirectoryTagSrationalArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagSrationalArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_FLOAT:
|
case TIFF_FLOAT:
|
||||||
if (!TIFFWriteDirectoryTagFloatArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagFloatArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_DOUBLE:
|
case TIFF_DOUBLE:
|
||||||
if (!TIFFWriteDirectoryTagDoubleArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagDoubleArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_IFD:
|
case TIFF_IFD:
|
||||||
if (!TIFFWriteDirectoryTagIfdArray(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagIfdArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
case TIFF_IFD8:
|
case TIFF_IFD8:
|
||||||
if (!TIFFWriteDirectoryTagIfdIfd8Array(tif,&ndir,dir,tif->tif_dir.td_customValues[m].info->field_tag,tif->tif_dir.td_customValues[m].count,tif->tif_dir.td_customValues[m].value))
|
if (!TIFFWriteDirectoryTagIfdIfd8Array(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value))
|
||||||
goto bad;
|
goto bad;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -778,7 +793,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tif->tif_diroff=(TIFFSeekFile(tif,0,SEEK_END)+1)&(~1);
|
tif->tif_diroff=(TIFFSeekFile(tif,0,SEEK_END)+1)&(~((toff_t)1));
|
||||||
if (pdiroff!=NULL)
|
if (pdiroff!=NULL)
|
||||||
*pdiroff=tif->tif_diroff;
|
*pdiroff=tif->tif_diroff;
|
||||||
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
||||||
@@ -806,7 +821,12 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
TIFFDirEntry* nb;
|
TIFFDirEntry* nb;
|
||||||
for (na=0, nb=dir; ; na++, nb++)
|
for (na=0, nb=dir; ; na++, nb++)
|
||||||
{
|
{
|
||||||
assert(na<ndir);
|
if( na == ndir )
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,module,
|
||||||
|
"Cannot find SubIFD tag");
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
if (nb->tdir_tag==TIFFTAG_SUBIFD)
|
if (nb->tdir_tag==TIFFTAG_SUBIFD)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -828,7 +848,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff)
|
|||||||
uint32 nTmp;
|
uint32 nTmp;
|
||||||
TIFFDirEntry* o;
|
TIFFDirEntry* o;
|
||||||
n=dirmem;
|
n=dirmem;
|
||||||
*(uint16*)n=ndir;
|
*(uint16*)n=(uint16)ndir;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabShort((uint16*)n);
|
TIFFSwabShort((uint16*)n);
|
||||||
n+=2;
|
n+=2;
|
||||||
@@ -925,6 +945,69 @@ bad:
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static float TIFFClampDoubleToFloat( double val )
|
||||||
|
{
|
||||||
|
if( val > FLT_MAX )
|
||||||
|
return FLT_MAX;
|
||||||
|
if( val < -FLT_MAX )
|
||||||
|
return -FLT_MAX;
|
||||||
|
return (float)val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int8 TIFFClampDoubleToInt8( double val )
|
||||||
|
{
|
||||||
|
if( val > 127 )
|
||||||
|
return 127;
|
||||||
|
if( val < -128 || val != val )
|
||||||
|
return -128;
|
||||||
|
return (int8)val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int16 TIFFClampDoubleToInt16( double val )
|
||||||
|
{
|
||||||
|
if( val > 32767 )
|
||||||
|
return 32767;
|
||||||
|
if( val < -32768 || val != val )
|
||||||
|
return -32768;
|
||||||
|
return (int16)val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32 TIFFClampDoubleToInt32( double val )
|
||||||
|
{
|
||||||
|
if( val > 0x7FFFFFFF )
|
||||||
|
return 0x7FFFFFFF;
|
||||||
|
if( val < -0x7FFFFFFF-1 || val != val )
|
||||||
|
return -0x7FFFFFFF-1;
|
||||||
|
return (int32)val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8 TIFFClampDoubleToUInt8( double val )
|
||||||
|
{
|
||||||
|
if( val < 0 )
|
||||||
|
return 0;
|
||||||
|
if( val > 255 || val != val )
|
||||||
|
return 255;
|
||||||
|
return (uint8)val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16 TIFFClampDoubleToUInt16( double val )
|
||||||
|
{
|
||||||
|
if( val < 0 )
|
||||||
|
return 0;
|
||||||
|
if( val > 65535 || val != val )
|
||||||
|
return 65535;
|
||||||
|
return (uint16)val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32 TIFFClampDoubleToUInt32( double val )
|
||||||
|
{
|
||||||
|
if( val < 0 )
|
||||||
|
return 0;
|
||||||
|
if( val > 0xFFFFFFFFU || val != val )
|
||||||
|
return 0xFFFFFFFFU;
|
||||||
|
return (uint32)val;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value)
|
TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value)
|
||||||
{
|
{
|
||||||
@@ -945,7 +1028,7 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di
|
|||||||
if (tif->tif_dir.td_bitspersample<=32)
|
if (tif->tif_dir.td_bitspersample<=32)
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
((float*)conv)[i] = (float)value[i];
|
((float*)conv)[i] = TIFFClampDoubleToFloat(value[i]);
|
||||||
ok = TIFFWriteDirectoryTagFloatArray(tif,ndir,dir,tag,count,(float*)conv);
|
ok = TIFFWriteDirectoryTagFloatArray(tif,ndir,dir,tag,count,(float*)conv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -957,19 +1040,19 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di
|
|||||||
if (tif->tif_dir.td_bitspersample<=8)
|
if (tif->tif_dir.td_bitspersample<=8)
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
((int8*)conv)[i] = (int8)value[i];
|
((int8*)conv)[i] = TIFFClampDoubleToInt8(value[i]);
|
||||||
ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8*)conv);
|
ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8*)conv);
|
||||||
}
|
}
|
||||||
else if (tif->tif_dir.td_bitspersample<=16)
|
else if (tif->tif_dir.td_bitspersample<=16)
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
((int16*)conv)[i] = (int16)value[i];
|
((int16*)conv)[i] = TIFFClampDoubleToInt16(value[i]);
|
||||||
ok = TIFFWriteDirectoryTagSshortArray(tif,ndir,dir,tag,count,(int16*)conv);
|
ok = TIFFWriteDirectoryTagSshortArray(tif,ndir,dir,tag,count,(int16*)conv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
((int32*)conv)[i] = (int32)value[i];
|
((int32*)conv)[i] = TIFFClampDoubleToInt32(value[i]);
|
||||||
ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)conv);
|
ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)conv);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -977,19 +1060,19 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di
|
|||||||
if (tif->tif_dir.td_bitspersample<=8)
|
if (tif->tif_dir.td_bitspersample<=8)
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
((uint8*)conv)[i] = (uint8)value[i];
|
((uint8*)conv)[i] = TIFFClampDoubleToUInt8(value[i]);
|
||||||
ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8*)conv);
|
ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8*)conv);
|
||||||
}
|
}
|
||||||
else if (tif->tif_dir.td_bitspersample<=16)
|
else if (tif->tif_dir.td_bitspersample<=16)
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
((uint16*)conv)[i] = (uint16)value[i];
|
((uint16*)conv)[i] = TIFFClampDoubleToUInt16(value[i]);
|
||||||
ok = TIFFWriteDirectoryTagShortArray(tif,ndir,dir,tag,count,(uint16*)conv);
|
ok = TIFFWriteDirectoryTagShortArray(tif,ndir,dir,tag,count,(uint16*)conv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
((uint32*)conv)[i] = (uint32)value[i];
|
((uint32*)conv)[i] = TIFFClampDoubleToUInt32(value[i]);
|
||||||
ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv);
|
ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1866,7 +1949,14 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir)
|
|||||||
for (p=0; p < tif->tif_dir.td_nsubifd; p++)
|
for (p=0; p < tif->tif_dir.td_nsubifd; p++)
|
||||||
{
|
{
|
||||||
assert(pa != 0);
|
assert(pa != 0);
|
||||||
assert(*pa <= 0xFFFFFFFFUL);
|
|
||||||
|
/* Could happen if an classicTIFF has a SubIFD of type LONG8 (which is illegal) */
|
||||||
|
if( *pa > 0xFFFFFFFFUL)
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,module,"Illegal value for SubIFD tag");
|
||||||
|
_TIFFfree(o);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
*pb++=(uint32)(*pa++);
|
*pb++=(uint32)(*pa++);
|
||||||
}
|
}
|
||||||
n=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,o);
|
n=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,o);
|
||||||
@@ -2033,7 +2123,10 @@ TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui
|
|||||||
{
|
{
|
||||||
uint64 m;
|
uint64 m;
|
||||||
assert(sizeof(uint64)==8);
|
assert(sizeof(uint64)==8);
|
||||||
assert(tif->tif_flags&TIFF_BIGTIFF);
|
if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","LONG8 not allowed for ClassicTIFF");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
m=value;
|
m=value;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong8(&m);
|
TIFFSwabLong8(&m);
|
||||||
@@ -2046,7 +2139,10 @@ TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* di
|
|||||||
{
|
{
|
||||||
assert(count<0x20000000);
|
assert(count<0x20000000);
|
||||||
assert(sizeof(uint64)==8);
|
assert(sizeof(uint64)==8);
|
||||||
assert(tif->tif_flags&TIFF_BIGTIFF);
|
if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8Array","LONG8 not allowed for ClassicTIFF");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabArrayOfLong8(value,count);
|
TIFFSwabArrayOfLong8(value,count);
|
||||||
return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,count,count*8,value));
|
return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,count,count*8,value));
|
||||||
@@ -2058,7 +2154,10 @@ TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u
|
|||||||
{
|
{
|
||||||
int64 m;
|
int64 m;
|
||||||
assert(sizeof(int64)==8);
|
assert(sizeof(int64)==8);
|
||||||
assert(tif->tif_flags&TIFF_BIGTIFF);
|
if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedSlong8","SLONG8 not allowed for ClassicTIFF");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
m=value;
|
m=value;
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabLong8((uint64*)(&m));
|
TIFFSwabLong8((uint64*)(&m));
|
||||||
@@ -2071,7 +2170,10 @@ TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* d
|
|||||||
{
|
{
|
||||||
assert(count<0x20000000);
|
assert(count<0x20000000);
|
||||||
assert(sizeof(int64)==8);
|
assert(sizeof(int64)==8);
|
||||||
assert(tif->tif_flags&TIFF_BIGTIFF);
|
if( !(tif->tif_flags&TIFF_BIGTIFF) ) {
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedSlong8Array","SLONG8 not allowed for ClassicTIFF");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
TIFFSwabArrayOfLong8((uint64*)value,count);
|
TIFFSwabArrayOfLong8((uint64*)value,count);
|
||||||
return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value));
|
return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value));
|
||||||
@@ -2080,15 +2182,25 @@ TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* d
|
|||||||
static int
|
static int
|
||||||
TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value)
|
TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value)
|
||||||
{
|
{
|
||||||
|
static const char module[] = "TIFFWriteDirectoryTagCheckedRational";
|
||||||
uint32 m[2];
|
uint32 m[2];
|
||||||
assert(value>=0.0);
|
|
||||||
assert(sizeof(uint32)==4);
|
assert(sizeof(uint32)==4);
|
||||||
if (value<=0.0)
|
if( value < 0 )
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,module,"Negative value is illegal");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if( value != value )
|
||||||
|
{
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,module,"Not-a-number value is illegal");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (value==0.0)
|
||||||
{
|
{
|
||||||
m[0]=0;
|
m[0]=0;
|
||||||
m[1]=1;
|
m[1]=1;
|
||||||
}
|
}
|
||||||
else if (value==(double)(uint32)value)
|
else if (value <= 0xFFFFFFFFU && value==(double)(uint32)value)
|
||||||
{
|
{
|
||||||
m[0]=(uint32)value;
|
m[0]=(uint32)value;
|
||||||
m[1]=1;
|
m[1]=1;
|
||||||
@@ -2129,25 +2241,26 @@ TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry*
|
|||||||
}
|
}
|
||||||
for (na=value, nb=m, nc=0; nc<count; na++, nb+=2, nc++)
|
for (na=value, nb=m, nc=0; nc<count; na++, nb+=2, nc++)
|
||||||
{
|
{
|
||||||
if (*na<=0.0)
|
if (*na<=0.0 || *na != *na)
|
||||||
{
|
{
|
||||||
nb[0]=0;
|
nb[0]=0;
|
||||||
nb[1]=1;
|
nb[1]=1;
|
||||||
}
|
}
|
||||||
else if (*na==(float)(uint32)(*na))
|
else if (*na >= 0 && *na <= (float)0xFFFFFFFFU &&
|
||||||
|
*na==(float)(uint32)(*na))
|
||||||
{
|
{
|
||||||
nb[0]=(uint32)(*na);
|
nb[0]=(uint32)(*na);
|
||||||
nb[1]=1;
|
nb[1]=1;
|
||||||
}
|
}
|
||||||
else if (*na<1.0)
|
else if (*na<1.0)
|
||||||
{
|
{
|
||||||
nb[0]=(uint32)((*na)*0xFFFFFFFF);
|
nb[0]=(uint32)((double)(*na)*0xFFFFFFFF);
|
||||||
nb[1]=0xFFFFFFFF;
|
nb[1]=0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nb[0]=0xFFFFFFFF;
|
nb[0]=0xFFFFFFFF;
|
||||||
nb[1]=(uint32)(0xFFFFFFFF/(*na));
|
nb[1]=(uint32)((double)0xFFFFFFFF/(*na));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tif->tif_flags&TIFF_SWAB)
|
if (tif->tif_flags&TIFF_SWAB)
|
||||||
@@ -2184,13 +2297,13 @@ TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry
|
|||||||
}
|
}
|
||||||
else if (*na>-1.0)
|
else if (*na>-1.0)
|
||||||
{
|
{
|
||||||
nb[0]=-(int32)((-*na)*0x7FFFFFFF);
|
nb[0]=-(int32)((double)(-*na)*0x7FFFFFFF);
|
||||||
nb[1]=0x7FFFFFFF;
|
nb[1]=0x7FFFFFFF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nb[0]=-0x7FFFFFFF;
|
nb[0]=-0x7FFFFFFF;
|
||||||
nb[1]=(int32)(0x7FFFFFFF/(-*na));
|
nb[1]=(int32)((double)0x7FFFFFFF/(-*na));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2202,13 +2315,13 @@ TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry
|
|||||||
}
|
}
|
||||||
else if (*na<1.0)
|
else if (*na<1.0)
|
||||||
{
|
{
|
||||||
nb[0]=(int32)((*na)*0x7FFFFFFF);
|
nb[0]=(int32)((double)(*na)*0x7FFFFFFF);
|
||||||
nb[1]=0x7FFFFFFF;
|
nb[1]=0x7FFFFFFF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nb[0]=0x7FFFFFFF;
|
nb[0]=0x7FFFFFFF;
|
||||||
nb[1]=(int32)(0x7FFFFFFF/(*na));
|
nb[1]=(int32)((double)0x7FFFFFFF/(*na));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2368,7 +2481,7 @@ TIFFLinkDirectory(TIFF* tif)
|
|||||||
{
|
{
|
||||||
static const char module[] = "TIFFLinkDirectory";
|
static const char module[] = "TIFFLinkDirectory";
|
||||||
|
|
||||||
tif->tif_diroff = (TIFFSeekFile(tif,0,SEEK_END)+1) &~ 1;
|
tif->tif_diroff = (TIFFSeekFile(tif,0,SEEK_END)+1) & (~((toff_t)1));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle SubIFDs
|
* Handle SubIFDs
|
||||||
@@ -2570,7 +2683,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype,
|
|||||||
tmsize_t count, void* data)
|
tmsize_t count, void* data)
|
||||||
{
|
{
|
||||||
static const char module[] = "TIFFResetField";
|
static const char module[] = "TIFFResetField";
|
||||||
const TIFFField* fip = NULL;
|
/* const TIFFField* fip = NULL; */
|
||||||
uint16 dircount;
|
uint16 dircount;
|
||||||
tmsize_t dirsize;
|
tmsize_t dirsize;
|
||||||
uint8 direntry_raw[20];
|
uint8 direntry_raw[20];
|
||||||
@@ -2586,7 +2699,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype,
|
|||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* Find field definition. */
|
/* Find field definition. */
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
fip = TIFFFindField(tif, tag, TIFF_ANY);
|
/*fip =*/ TIFFFindField(tif, tag, TIFF_ANY);
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* Do some checking this is a straight forward case. */
|
/* Do some checking this is a straight forward case. */
|
||||||
@@ -2839,14 +2952,15 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype,
|
|||||||
"Error writing directory link");
|
"Error writing directory link");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_TIFFfree( buf_to_write );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype));
|
memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_TIFFfree( buf_to_write );
|
||||||
|
buf_to_write = 0;
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* Adjust the directory entry. */
|
/* Adjust the directory entry. */
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.14 2011-04-02 20:54:09 bfriesen Exp $ */
|
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.15 2015-12-12 18:04:26 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -66,7 +66,7 @@ DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
|||||||
cc -= n;
|
cc -= n;
|
||||||
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
|
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
|
||||||
!TIFFFlushData1(tif))
|
!TIFFFlushData1(tif))
|
||||||
return (-1);
|
return (0);
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+13
-5
@@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.5 2010-03-10 18:56:48 bfriesen Exp $ */
|
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.6 2017-07-04 12:54:42 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -51,25 +51,33 @@ void
|
|||||||
TIFFError(const char* module, const char* fmt, ...)
|
TIFFError(const char* module, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
if (_TIFFerrorHandler) {
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if (_TIFFerrorHandler)
|
|
||||||
(*_TIFFerrorHandler)(module, fmt, ap);
|
(*_TIFFerrorHandler)(module, fmt, ap);
|
||||||
if (_TIFFerrorHandlerExt)
|
va_end(ap);
|
||||||
|
}
|
||||||
|
if (_TIFFerrorHandlerExt) {
|
||||||
|
va_start(ap, fmt);
|
||||||
(*_TIFFerrorHandlerExt)(0, module, fmt, ap);
|
(*_TIFFerrorHandlerExt)(0, module, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)
|
TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
if (_TIFFerrorHandler) {
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if (_TIFFerrorHandler)
|
|
||||||
(*_TIFFerrorHandler)(module, fmt, ap);
|
(*_TIFFerrorHandler)(module, fmt, ap);
|
||||||
if (_TIFFerrorHandlerExt)
|
va_end(ap);
|
||||||
|
}
|
||||||
|
if (_TIFFerrorHandlerExt) {
|
||||||
|
va_start(ap, fmt);
|
||||||
(*_TIFFerrorHandlerExt)(fd, module, fmt, ap);
|
(*_TIFFerrorHandlerExt)(fd, module, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
|
|||||||
Vendored
+19
-19
@@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.7 2010-03-10 18:56:48 bfriesen Exp $ */
|
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.8 2015-12-06 11:13:43 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -66,13 +66,13 @@ TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif )
|
|||||||
void *TIFFGetClientInfo( TIFF *tif, const char *name )
|
void *TIFFGetClientInfo( TIFF *tif, const char *name )
|
||||||
|
|
||||||
{
|
{
|
||||||
TIFFClientInfoLink *link = tif->tif_clientinfo;
|
TIFFClientInfoLink *psLink = tif->tif_clientinfo;
|
||||||
|
|
||||||
while( link != NULL && strcmp(link->name,name) != 0 )
|
while( psLink != NULL && strcmp(psLink->name,name) != 0 )
|
||||||
link = link->next;
|
psLink = psLink->next;
|
||||||
|
|
||||||
if( link != NULL )
|
if( psLink != NULL )
|
||||||
return link->data;
|
return psLink->data;
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -80,18 +80,18 @@ void *TIFFGetClientInfo( TIFF *tif, const char *name )
|
|||||||
void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
|
void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
|
||||||
|
|
||||||
{
|
{
|
||||||
TIFFClientInfoLink *link = tif->tif_clientinfo;
|
TIFFClientInfoLink *psLink = tif->tif_clientinfo;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Do we have an existing link with this name? If so, just
|
** Do we have an existing link with this name? If so, just
|
||||||
** set it.
|
** set it.
|
||||||
*/
|
*/
|
||||||
while( link != NULL && strcmp(link->name,name) != 0 )
|
while( psLink != NULL && strcmp(psLink->name,name) != 0 )
|
||||||
link = link->next;
|
psLink = psLink->next;
|
||||||
|
|
||||||
if( link != NULL )
|
if( psLink != NULL )
|
||||||
{
|
{
|
||||||
link->data = data;
|
psLink->data = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,15 +99,15 @@ void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
|
|||||||
** Create a new link.
|
** Create a new link.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
|
psLink = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
|
||||||
assert (link != NULL);
|
assert (psLink != NULL);
|
||||||
link->next = tif->tif_clientinfo;
|
psLink->next = tif->tif_clientinfo;
|
||||||
link->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));
|
psLink->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));
|
||||||
assert (link->name != NULL);
|
assert (psLink->name != NULL);
|
||||||
strcpy(link->name, name);
|
strcpy(psLink->name, name);
|
||||||
link->data = data;
|
psLink->data = data;
|
||||||
|
|
||||||
tif->tif_clientinfo = link;
|
tif->tif_clientinfo = psLink;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
|
|||||||
Vendored
+100
-47
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_fax3.c,v 1.73 2012-06-13 00:27:20 fwarmerdam Exp $ */
|
/* $Id: tif_fax3.c,v 1.81 2017-06-18 10:31:50 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1990-1997 Sam Leffler
|
* Copyright (c) 1990-1997 Sam Leffler
|
||||||
@@ -329,34 +329,64 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
|||||||
#if SIZEOF_UNSIGNED_LONG == 8
|
#if SIZEOF_UNSIGNED_LONG == 8
|
||||||
# define FILL(n, cp) \
|
# define FILL(n, cp) \
|
||||||
switch (n) { \
|
switch (n) { \
|
||||||
case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\
|
case 15:(cp)[14] = 0xff; /*-fallthrough*/ \
|
||||||
case 12:(cp)[11] = 0xff; case 11:(cp)[10] = 0xff; case 10: (cp)[9] = 0xff;\
|
case 14:(cp)[13] = 0xff; /*-fallthrough*/ \
|
||||||
case 9: (cp)[8] = 0xff; case 8: (cp)[7] = 0xff; case 7: (cp)[6] = 0xff;\
|
case 13:(cp)[12] = 0xff; /*-fallthrough*/ \
|
||||||
case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; case 4: (cp)[3] = 0xff;\
|
case 12:(cp)[11] = 0xff; /*-fallthrough*/ \
|
||||||
case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \
|
case 11:(cp)[10] = 0xff; /*-fallthrough*/ \
|
||||||
case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \
|
case 10: (cp)[9] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 9: (cp)[8] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 8: (cp)[7] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 7: (cp)[6] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 6: (cp)[5] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 5: (cp)[4] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 4: (cp)[3] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 3: (cp)[2] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 2: (cp)[1] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 1: (cp)[0] = 0xff; (cp) += (n); /*-fallthrough*/ \
|
||||||
|
case 0: ; \
|
||||||
}
|
}
|
||||||
# define ZERO(n, cp) \
|
# define ZERO(n, cp) \
|
||||||
switch (n) { \
|
switch (n) { \
|
||||||
case 15:(cp)[14] = 0; case 14:(cp)[13] = 0; case 13: (cp)[12] = 0; \
|
case 15:(cp)[14] = 0; /*-fallthrough*/ \
|
||||||
case 12:(cp)[11] = 0; case 11:(cp)[10] = 0; case 10: (cp)[9] = 0; \
|
case 14:(cp)[13] = 0; /*-fallthrough*/ \
|
||||||
case 9: (cp)[8] = 0; case 8: (cp)[7] = 0; case 7: (cp)[6] = 0; \
|
case 13:(cp)[12] = 0; /*-fallthrough*/ \
|
||||||
case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; case 4: (cp)[3] = 0; \
|
case 12:(cp)[11] = 0; /*-fallthrough*/ \
|
||||||
case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \
|
case 11:(cp)[10] = 0; /*-fallthrough*/ \
|
||||||
case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \
|
case 10: (cp)[9] = 0; /*-fallthrough*/ \
|
||||||
|
case 9: (cp)[8] = 0; /*-fallthrough*/ \
|
||||||
|
case 8: (cp)[7] = 0; /*-fallthrough*/ \
|
||||||
|
case 7: (cp)[6] = 0; /*-fallthrough*/ \
|
||||||
|
case 6: (cp)[5] = 0; /*-fallthrough*/ \
|
||||||
|
case 5: (cp)[4] = 0; /*-fallthrough*/ \
|
||||||
|
case 4: (cp)[3] = 0; /*-fallthrough*/ \
|
||||||
|
case 3: (cp)[2] = 0; /*-fallthrough*/ \
|
||||||
|
case 2: (cp)[1] = 0; /*-fallthrough*/ \
|
||||||
|
case 1: (cp)[0] = 0; (cp) += (n); /*-fallthrough*/ \
|
||||||
|
case 0: ; \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define FILL(n, cp) \
|
# define FILL(n, cp) \
|
||||||
switch (n) { \
|
switch (n) { \
|
||||||
case 7: (cp)[6] = 0xff; case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; \
|
case 7: (cp)[6] = 0xff; /*-fallthrough*/ \
|
||||||
case 4: (cp)[3] = 0xff; case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \
|
case 6: (cp)[5] = 0xff; /*-fallthrough*/ \
|
||||||
case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \
|
case 5: (cp)[4] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 4: (cp)[3] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 3: (cp)[2] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 2: (cp)[1] = 0xff; /*-fallthrough*/ \
|
||||||
|
case 1: (cp)[0] = 0xff; (cp) += (n); /*-fallthrough*/ \
|
||||||
|
case 0: ; \
|
||||||
}
|
}
|
||||||
# define ZERO(n, cp) \
|
# define ZERO(n, cp) \
|
||||||
switch (n) { \
|
switch (n) { \
|
||||||
case 7: (cp)[6] = 0; case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; \
|
case 7: (cp)[6] = 0; /*-fallthrough*/ \
|
||||||
case 4: (cp)[3] = 0; case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \
|
case 6: (cp)[5] = 0; /*-fallthrough*/ \
|
||||||
case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \
|
case 5: (cp)[4] = 0; /*-fallthrough*/ \
|
||||||
|
case 4: (cp)[3] = 0; /*-fallthrough*/ \
|
||||||
|
case 3: (cp)[2] = 0; /*-fallthrough*/ \
|
||||||
|
case 2: (cp)[1] = 0; /*-fallthrough*/ \
|
||||||
|
case 1: (cp)[0] = 0; (cp) += (n); /*-fallthrough*/ \
|
||||||
|
case 0: ; \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -442,8 +472,9 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx)
|
|||||||
FILL(n, cp);
|
FILL(n, cp);
|
||||||
run &= 7;
|
run &= 7;
|
||||||
}
|
}
|
||||||
|
/* Explicit 0xff masking to make icc -check=conversions happy */
|
||||||
if (run)
|
if (run)
|
||||||
cp[0] |= 0xff00 >> run;
|
cp[0] = (unsigned char)((cp[0] | (0xff00 >> run))&0xff);
|
||||||
} else
|
} else
|
||||||
cp[0] |= _fillmasks[run]>>bx;
|
cp[0] |= _fillmasks[run]>>bx;
|
||||||
x += runs[1];
|
x += runs[1];
|
||||||
@@ -526,7 +557,7 @@ Fax3SetupState(TIFF* tif)
|
|||||||
"for Group 3/4 run arrays");
|
"for Group 3/4 run arrays");
|
||||||
if (dsp->runs == NULL)
|
if (dsp->runs == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
memset( dsp->runs, 0, TIFFSafeMultiply(uint32,nruns,2));
|
memset( dsp->runs, 0, TIFFSafeMultiply(uint32,nruns,2)*sizeof(uint32));
|
||||||
dsp->curruns = dsp->runs;
|
dsp->curruns = dsp->runs;
|
||||||
if (needsRefLine)
|
if (needsRefLine)
|
||||||
dsp->refruns = dsp->runs + nruns;
|
dsp->refruns = dsp->runs + nruns;
|
||||||
@@ -643,7 +674,8 @@ putspan(TIFF* tif, int32 span, const tableentry* tab)
|
|||||||
|
|
||||||
while (span >= 2624) {
|
while (span >= 2624) {
|
||||||
const tableentry* te = &tab[63 + (2560>>6)];
|
const tableentry* te = &tab[63 + (2560>>6)];
|
||||||
code = te->code, length = te->length;
|
code = te->code;
|
||||||
|
length = te->length;
|
||||||
#ifdef FAX3_DEBUG
|
#ifdef FAX3_DEBUG
|
||||||
DEBUG_PRINT("MakeUp", te->runlen);
|
DEBUG_PRINT("MakeUp", te->runlen);
|
||||||
#endif
|
#endif
|
||||||
@@ -653,14 +685,16 @@ putspan(TIFF* tif, int32 span, const tableentry* tab)
|
|||||||
if (span >= 64) {
|
if (span >= 64) {
|
||||||
const tableentry* te = &tab[63 + (span>>6)];
|
const tableentry* te = &tab[63 + (span>>6)];
|
||||||
assert(te->runlen == 64*(span>>6));
|
assert(te->runlen == 64*(span>>6));
|
||||||
code = te->code, length = te->length;
|
code = te->code;
|
||||||
|
length = te->length;
|
||||||
#ifdef FAX3_DEBUG
|
#ifdef FAX3_DEBUG
|
||||||
DEBUG_PRINT("MakeUp", te->runlen);
|
DEBUG_PRINT("MakeUp", te->runlen);
|
||||||
#endif
|
#endif
|
||||||
_PutBits(tif, code, length);
|
_PutBits(tif, code, length);
|
||||||
span -= te->runlen;
|
span -= te->runlen;
|
||||||
}
|
}
|
||||||
code = tab[span].code, length = tab[span].length;
|
code = tab[span].code;
|
||||||
|
length = tab[span].length;
|
||||||
#ifdef FAX3_DEBUG
|
#ifdef FAX3_DEBUG
|
||||||
DEBUG_PRINT(" Term", tab[span].runlen);
|
DEBUG_PRINT(" Term", tab[span].runlen);
|
||||||
#endif
|
#endif
|
||||||
@@ -696,14 +730,16 @@ Fax3PutEOL(TIFF* tif)
|
|||||||
align = sp->bit + (8 - align);
|
align = sp->bit + (8 - align);
|
||||||
else
|
else
|
||||||
align = sp->bit - align;
|
align = sp->bit - align;
|
||||||
code = 0;
|
|
||||||
tparm=align;
|
tparm=align;
|
||||||
_PutBits(tif, 0, tparm);
|
_PutBits(tif, 0, tparm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
code = EOL, length = 12;
|
code = EOL;
|
||||||
if (is2DEncoding(sp))
|
length = 12;
|
||||||
code = (code<<1) | (sp->tag == G3_1D), length++;
|
if (is2DEncoding(sp)) {
|
||||||
|
code = (code<<1) | (sp->tag == G3_1D);
|
||||||
|
length++;
|
||||||
|
}
|
||||||
_PutBits(tif, code, length);
|
_PutBits(tif, code, length);
|
||||||
|
|
||||||
sp->data = data;
|
sp->data = data;
|
||||||
@@ -804,7 +840,7 @@ static int32 find1span(unsigned char*, int32, int32);
|
|||||||
* table. The ``base'' of the bit string is supplied
|
* table. The ``base'' of the bit string is supplied
|
||||||
* along with the start+end bit indices.
|
* along with the start+end bit indices.
|
||||||
*/
|
*/
|
||||||
static int32
|
inline static int32
|
||||||
find0span(unsigned char* bp, int32 bs, int32 be)
|
find0span(unsigned char* bp, int32 bs, int32 be)
|
||||||
{
|
{
|
||||||
int32 bits = be - bs;
|
int32 bits = be - bs;
|
||||||
@@ -814,7 +850,7 @@ find0span(unsigned char* bp, int32 bs, int32 be)
|
|||||||
/*
|
/*
|
||||||
* Check partial byte on lhs.
|
* Check partial byte on lhs.
|
||||||
*/
|
*/
|
||||||
if (bits > 0 && (n = (bs & 7))) {
|
if (bits > 0 && (n = (bs & 7)) != 0) {
|
||||||
span = zeroruns[(*bp << n) & 0xff];
|
span = zeroruns[(*bp << n) & 0xff];
|
||||||
if (span > 8-n) /* table value too generous */
|
if (span > 8-n) /* table value too generous */
|
||||||
span = 8-n;
|
span = 8-n;
|
||||||
@@ -834,12 +870,14 @@ find0span(unsigned char* bp, int32 bs, int32 be)
|
|||||||
while (!isAligned(bp, long)) {
|
while (!isAligned(bp, long)) {
|
||||||
if (*bp != 0x00)
|
if (*bp != 0x00)
|
||||||
return (span + zeroruns[*bp]);
|
return (span + zeroruns[*bp]);
|
||||||
span += 8, bits -= 8;
|
span += 8;
|
||||||
|
bits -= 8;
|
||||||
bp++;
|
bp++;
|
||||||
}
|
}
|
||||||
lp = (long*) bp;
|
lp = (long*) bp;
|
||||||
while ((bits >= (int32)(8 * sizeof(long))) && (0 == *lp)) {
|
while ((bits >= (int32)(8 * sizeof(long))) && (0 == *lp)) {
|
||||||
span += 8*sizeof (long), bits -= 8*sizeof (long);
|
span += 8*sizeof (long);
|
||||||
|
bits -= 8*sizeof (long);
|
||||||
lp++;
|
lp++;
|
||||||
}
|
}
|
||||||
bp = (unsigned char*) lp;
|
bp = (unsigned char*) lp;
|
||||||
@@ -850,7 +888,8 @@ find0span(unsigned char* bp, int32 bs, int32 be)
|
|||||||
while (bits >= 8) {
|
while (bits >= 8) {
|
||||||
if (*bp != 0x00) /* end of run */
|
if (*bp != 0x00) /* end of run */
|
||||||
return (span + zeroruns[*bp]);
|
return (span + zeroruns[*bp]);
|
||||||
span += 8, bits -= 8;
|
span += 8;
|
||||||
|
bits -= 8;
|
||||||
bp++;
|
bp++;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -863,7 +902,7 @@ find0span(unsigned char* bp, int32 bs, int32 be)
|
|||||||
return (span);
|
return (span);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32
|
inline static int32
|
||||||
find1span(unsigned char* bp, int32 bs, int32 be)
|
find1span(unsigned char* bp, int32 bs, int32 be)
|
||||||
{
|
{
|
||||||
int32 bits = be - bs;
|
int32 bits = be - bs;
|
||||||
@@ -873,7 +912,7 @@ find1span(unsigned char* bp, int32 bs, int32 be)
|
|||||||
/*
|
/*
|
||||||
* Check partial byte on lhs.
|
* Check partial byte on lhs.
|
||||||
*/
|
*/
|
||||||
if (bits > 0 && (n = (bs & 7))) {
|
if (bits > 0 && (n = (bs & 7)) != 0) {
|
||||||
span = oneruns[(*bp << n) & 0xff];
|
span = oneruns[(*bp << n) & 0xff];
|
||||||
if (span > 8-n) /* table value too generous */
|
if (span > 8-n) /* table value too generous */
|
||||||
span = 8-n;
|
span = 8-n;
|
||||||
@@ -893,12 +932,14 @@ find1span(unsigned char* bp, int32 bs, int32 be)
|
|||||||
while (!isAligned(bp, long)) {
|
while (!isAligned(bp, long)) {
|
||||||
if (*bp != 0xff)
|
if (*bp != 0xff)
|
||||||
return (span + oneruns[*bp]);
|
return (span + oneruns[*bp]);
|
||||||
span += 8, bits -= 8;
|
span += 8;
|
||||||
|
bits -= 8;
|
||||||
bp++;
|
bp++;
|
||||||
}
|
}
|
||||||
lp = (long*) bp;
|
lp = (long*) bp;
|
||||||
while ((bits >= (int32)(8 * sizeof(long))) && (~0 == *lp)) {
|
while ((bits >= (int32)(8 * sizeof(long))) && (~0 == *lp)) {
|
||||||
span += 8*sizeof (long), bits -= 8*sizeof (long);
|
span += 8*sizeof (long);
|
||||||
|
bits -= 8*sizeof (long);
|
||||||
lp++;
|
lp++;
|
||||||
}
|
}
|
||||||
bp = (unsigned char*) lp;
|
bp = (unsigned char*) lp;
|
||||||
@@ -909,7 +950,8 @@ find1span(unsigned char* bp, int32 bs, int32 be)
|
|||||||
while (bits >= 8) {
|
while (bits >= 8) {
|
||||||
if (*bp != 0xff) /* end of run */
|
if (*bp != 0xff) /* end of run */
|
||||||
return (span + oneruns[*bp]);
|
return (span + oneruns[*bp]);
|
||||||
span += 8, bits -= 8;
|
span += 8;
|
||||||
|
bits -= 8;
|
||||||
bp++;
|
bp++;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -1001,7 +1043,11 @@ Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
b2 = finddiff2(rp, b1, bits, PIXEL(rp,b1));
|
b2 = finddiff2(rp, b1, bits, PIXEL(rp,b1));
|
||||||
if (b2 >= a1) {
|
if (b2 >= a1) {
|
||||||
int32 d = b1 - a1;
|
/* Naive computation triggers -fsanitize=undefined,unsigned-integer-overflow */
|
||||||
|
/* although it is correct unless the difference between both is < 31 bit */
|
||||||
|
/* int32 d = b1 - a1; */
|
||||||
|
int32 d = (b1 >= a1 && b1 - a1 <= 3U) ? (int32)(b1 - a1):
|
||||||
|
(b1 < a1 && a1 - b1 <= 3U) ? -(int32)(a1 - b1) : 0x7FFFFFFF;
|
||||||
if (!(-3 <= d && d <= 3)) { /* horizontal mode */
|
if (!(-3 <= d && d <= 3)) { /* horizontal mode */
|
||||||
a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1));
|
a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1));
|
||||||
putcode(tif, &horizcode);
|
putcode(tif, &horizcode);
|
||||||
@@ -1087,14 +1133,16 @@ Fax3PostEncode(TIFF* tif)
|
|||||||
static void
|
static void
|
||||||
Fax3Close(TIFF* tif)
|
Fax3Close(TIFF* tif)
|
||||||
{
|
{
|
||||||
if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0) {
|
if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0 && tif->tif_rawcp) {
|
||||||
Fax3CodecState* sp = EncoderState(tif);
|
Fax3CodecState* sp = EncoderState(tif);
|
||||||
unsigned int code = EOL;
|
unsigned int code = EOL;
|
||||||
unsigned int length = 12;
|
unsigned int length = 12;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (is2DEncoding(sp))
|
if (is2DEncoding(sp)) {
|
||||||
code = (code<<1) | (sp->tag == G3_1D), length++;
|
code = (code<<1) | (sp->tag == G3_1D);
|
||||||
|
length++;
|
||||||
|
}
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
Fax3PutBits(tif, code, length);
|
Fax3PutBits(tif, code, length);
|
||||||
Fax3FlushBits(tif, sp);
|
Fax3FlushBits(tif, sp);
|
||||||
@@ -1181,7 +1229,7 @@ Fax3VSetField(TIFF* tif, uint32 tag, va_list ap)
|
|||||||
return (*sp->vsetparent)(tif, tag, ap);
|
return (*sp->vsetparent)(tif, tag, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fip = TIFFFieldWithTag(tif, tag)))
|
if ((fip = TIFFFieldWithTag(tif, tag)) != NULL)
|
||||||
TIFFSetFieldBit(tif, fip->field_bit);
|
TIFFSetFieldBit(tif, fip->field_bit);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1240,10 +1288,14 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
fprintf(fd, " Group 3 Options:");
|
fprintf(fd, " Group 3 Options:");
|
||||||
if (sp->groupoptions & GROUP3OPT_2DENCODING)
|
if (sp->groupoptions & GROUP3OPT_2DENCODING) {
|
||||||
fprintf(fd, "%s2-d encoding", sep), sep = "+";
|
fprintf(fd, "%s2-d encoding", sep);
|
||||||
if (sp->groupoptions & GROUP3OPT_FILLBITS)
|
sep = "+";
|
||||||
fprintf(fd, "%sEOL padding", sep), sep = "+";
|
}
|
||||||
|
if (sp->groupoptions & GROUP3OPT_FILLBITS) {
|
||||||
|
fprintf(fd, "%sEOL padding", sep);
|
||||||
|
sep = "+";
|
||||||
|
}
|
||||||
if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED)
|
if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED)
|
||||||
fprintf(fd, "%suncompressed data", sep);
|
fprintf(fd, "%suncompressed data", sep);
|
||||||
}
|
}
|
||||||
@@ -1303,6 +1355,7 @@ InitCCITTFax3(TIFF* tif)
|
|||||||
"No space for state block");
|
"No space for state block");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
_TIFFmemset(tif->tif_data, 0, sizeof (Fax3CodecState));
|
||||||
|
|
||||||
sp = Fax3State(tif);
|
sp = Fax3State(tif);
|
||||||
sp->rw_mode = tif->tif_mode;
|
sp->rw_mode = tif->tif_mode;
|
||||||
|
|||||||
Vendored
+5
-3
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_fax3.h,v 1.9 2011-03-10 20:23:07 fwarmerdam Exp $ */
|
/* $Id: tif_fax3.h,v 1.13 2016-12-14 18:36:27 faxguy Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1990-1997 Sam Leffler
|
* Copyright (c) 1990-1997 Sam Leffler
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* To override the default routine used to image decoded
|
* To override the default routine used to image decoded
|
||||||
* spans one can use the pseduo tag TIFFTAG_FAXFILLFUNC.
|
* spans one can use the pseudo tag TIFFTAG_FAXFILLFUNC.
|
||||||
* The routine must have the type signature given below;
|
* The routine must have the type signature given below;
|
||||||
* for example:
|
* for example:
|
||||||
*
|
*
|
||||||
@@ -81,10 +81,12 @@ extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32);
|
|||||||
#define S_MakeUp 11
|
#define S_MakeUp 11
|
||||||
#define S_EOL 12
|
#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 */
|
typedef struct { /* state table entry */
|
||||||
unsigned char State; /* see above */
|
unsigned char State; /* see above */
|
||||||
unsigned char Width; /* width of code in bits */
|
unsigned char Width; /* width of code in bits */
|
||||||
uint32 Param; /* unsigned 32-bit run length in bits */
|
uint32 Param; /* unsigned 32-bit run length in bits (holds on 16 bit actually, but cannot be changed. See above warning) */
|
||||||
} TIFFFaxTabEnt;
|
} TIFFFaxTabEnt;
|
||||||
|
|
||||||
extern const TIFFFaxTabEnt TIFFFaxMainTable[];
|
extern const TIFFFaxTabEnt TIFFFaxMainTable[];
|
||||||
|
|||||||
Vendored
+394
-213
File diff suppressed because it is too large
Load Diff
Vendored
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: tif_jbig.c,v 1.15 2010-03-10 18:56:48 bfriesen Exp $ */
|
/* $Id: tif_jbig.c,v 1.16 2017-06-26 15:20:00 erouault Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@@ -94,6 +94,7 @@ static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)
|
|||||||
jbg_strerror(decodeStatus)
|
jbg_strerror(decodeStatus)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
jbg_dec_free(&decoder);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user