mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
Compare commits
1164 Commits
4.3.0-openvino
...
3.4.14
| Author | SHA1 | Date | |
|---|---|---|---|
| d0e3e638c3 | |||
| 6a72bf5085 | |||
| 0ff57e3292 | |||
| 5db484b6c2 | |||
| 6865787a75 | |||
| 7f664850f5 | |||
| 2907fb88f5 | |||
| d7cb2ea210 | |||
| 4ae2c11520 | |||
| 1b3e0b27af | |||
| e4b0251e9d | |||
| b26f5b9468 | |||
| 5340dc6686 | |||
| 2b86de217a | |||
| 1615afd7f4 | |||
| 908957317f | |||
| 6fa2bdd7f2 | |||
| f82303d614 | |||
| 6773fa03e2 | |||
| d651ff8d6b | |||
| 8069a6b4f8 | |||
| b697b3162f | |||
| 53a16b1186 | |||
| a2a92999be | |||
| 40c0830b63 | |||
| 6f1eefec69 | |||
| bb6e15f2c0 | |||
| 0dcb99cf23 | |||
| cc6d48959e | |||
| aab62aa6dd | |||
| ac9f3a1242 | |||
| 53652a6194 | |||
| 8d232a63ad | |||
| bf03f5fa3a | |||
| 6e8022a3af | |||
| d27eb79fa6 | |||
| 3e48a91d97 | |||
| 144443d011 | |||
| 86d0a86141 | |||
| bf9f67e93f | |||
| 26ea4760ad | |||
| f59917bea1 | |||
| a394c8b10b | |||
| e56e4876e7 | |||
| 56bdd7db5c | |||
| 3df6bc58e9 | |||
| e75f1b071b | |||
| 7a2b3ed471 | |||
| 551d4a8ec1 | |||
| 29a289dfa1 | |||
| bdd2b57e5d | |||
| a97f6f8058 | |||
| c0dd82fb53 | |||
| 1211a8b9cd | |||
| f680505086 | |||
| ae60bbc7e4 | |||
| 7664e6d090 | |||
| 960f501cc1 | |||
| 7a8e171691 | |||
| 7ca9740da5 | |||
| 68fae94cbb | |||
| 6da5c7c1d0 | |||
| 87e607a19b | |||
| cbe236652b | |||
| d4d805cb3e | |||
| 8d29a902e4 | |||
| f136adcad5 | |||
| 95ab9468c1 | |||
| f8181fbef8 | |||
| b995de4ff3 | |||
| 825dadfbdd | |||
| 63048812c7 | |||
| e4692ac079 | |||
| 47337e2196 | |||
| 1d6a1e5f9c | |||
| 84fcc4ab9b | |||
| 65b51e1538 | |||
| 6c9be1bc1d | |||
| 4c48f1eed2 | |||
| 31f66766b7 | |||
| 601690695e | |||
| 85009800b3 | |||
| 04a9ff88d8 | |||
| dc24663e8d | |||
| d2cc63e779 | |||
| 358878caf7 | |||
| 640f188ca2 | |||
| a1e2c4f338 | |||
| 625d4fc884 | |||
| f821530eb0 | |||
| 7894cd3c73 | |||
| 125cc79c17 | |||
| 2a808aeec0 | |||
| 94533e12eb | |||
| a0008de281 | |||
| a42d4da003 | |||
| 0689c70dba | |||
| 75ad74c893 | |||
| cbfd38bd41 | |||
| 2ab1f3f166 | |||
| a123c48d4d | |||
| 1c88e1fd19 | |||
| cc22a73d0f | |||
| ba7d0c5b23 | |||
| 5d499a185b | |||
| eab8ac9a71 | |||
| 19865a26e5 | |||
| 96947c30c0 | |||
| 19f1bac18c | |||
| b3b80f85fe | |||
| 9695165877 | |||
| 84080c12fd | |||
| 1a855fed8f | |||
| 773262bc09 | |||
| fadb25baf8 | |||
| 20a46b31cd | |||
| b2321576bc | |||
| 67b6ef4c2a | |||
| 7ffc4b57aa | |||
| d4d12164aa | |||
| 34d5746553 | |||
| 86cb435adf | |||
| 513f5a8869 | |||
| 1de02b9c57 | |||
| f6bc4fd4c6 | |||
| 9b399f3960 | |||
| 98c2ccfaa3 | |||
| 309e1e2b1d | |||
| af13f61a43 | |||
| d093ac6a0f | |||
| 4badf640bf | |||
| 8f6ba5a089 | |||
| 5cf08b0722 | |||
| 0421c3991d | |||
| 50a1a33d07 | |||
| 96570820ef | |||
| eb90186614 | |||
| 8d21c84e7d | |||
| 601851cc7e | |||
| 29f55810cf | |||
| f76ba285c9 | |||
| 0a7a54f312 | |||
| 5b16b190c1 | |||
| 0885a79c28 | |||
| 6d3502833f | |||
| bc8727786b | |||
| f0445295bd | |||
| 5a06d679cf | |||
| 76cc034df2 | |||
| cbb230fdfc | |||
| 5d1540f4fc | |||
| a5a421a9f1 | |||
| 743099f9f9 | |||
| d2d6eba16a | |||
| cceec84139 | |||
| c909693d45 | |||
| fba70f7991 | |||
| 84a290097b | |||
| 6ee23c9b85 | |||
| cac5b0fe5a | |||
| 93783df42a | |||
| a3fb64d1cd | |||
| 7079e7ea5e | |||
| 4f39f8a8d0 | |||
| 27bada6737 | |||
| 650836d700 | |||
| 3b9aebee11 | |||
| 847b16fb76 | |||
| 2387813428 | |||
| 0be18f5cb0 | |||
| 4f08bb5046 | |||
| 09d2ca17cf | |||
| 83aa711346 | |||
| 863ecded30 | |||
| 0a86ddc36c | |||
| 6c1a433c4c | |||
| 23734aff74 | |||
| 0016c25b58 | |||
| 68eb54dc13 | |||
| b08d67c4e1 | |||
| 5ab4623c2a | |||
| cdf73f2e05 | |||
| 30bef20e22 | |||
| 4be077163f | |||
| b9dfffc237 | |||
| c5bf15e009 | |||
| e2949c7d0a | |||
| e448f4f6ef | |||
| ebd91459f2 | |||
| ff8a624189 | |||
| 449ebc1b70 | |||
| 3f14341629 | |||
| ca9cbab532 | |||
| 5c70a2015f | |||
| 573812d0ff | |||
| c12930cdde | |||
| 857f339914 | |||
| b1ffe7a153 | |||
| 62b60b11bb | |||
| 96e0902f39 | |||
| 1d3207d7c7 | |||
| fb0abdeb4f | |||
| 331f1b9961 | |||
| 3cfe7b9af9 | |||
| 37e656082b | |||
| 0c0cf8b19f | |||
| bbad38b2c5 | |||
| 413febf657 | |||
| d5447d859f | |||
| 38a49f92ab | |||
| 0f968e3b6d | |||
| f65d75f5c8 | |||
| 291dbdfbe6 | |||
| 6ce9bb6f7a | |||
| a0bdb78a99 | |||
| 321f26f450 | |||
| 212815a10d | |||
| 104e64dd0f | |||
| 5967acc9ca | |||
| eea4397b12 | |||
| a122a53e72 | |||
| 8215380336 | |||
| af9597f454 | |||
| 235e648bf5 | |||
| fbcc532de5 | |||
| 72894a1a90 | |||
| e3856dfe5d | |||
| 62420b900e | |||
| 89ef676613 | |||
| 83e14f602f | |||
| 5389309d40 | |||
| 058460ddf4 | |||
| 380009ac58 | |||
| 2775099a32 | |||
| f98e567f49 | |||
| 9fb48d5f44 | |||
| 8f653ba8de | |||
| 87b3b48fe0 | |||
| 0043d9bf13 | |||
| 2d2d72afbb | |||
| 4f9cb3871a | |||
| 5b598c1812 | |||
| 8f66dad65b | |||
| 55f06b76f9 | |||
| 6e1da2ef91 | |||
| 1ec2ade65b | |||
| 13148df9f2 | |||
| 5a10261111 | |||
| 064d48771d | |||
| 7eeba4d485 | |||
| 0681deb3c9 | |||
| 0ffa78b66a | |||
| b51ae87828 | |||
| 68fb8dd873 | |||
| 8869dc7762 | |||
| e6c9291e32 | |||
| a6f14ca97c | |||
| c555a6747d | |||
| dd276dbb59 | |||
| 70d82017fe | |||
| 663bd73518 | |||
| c526705f4f | |||
| c84d2cb32a | |||
| ff211371bc | |||
| e9a4734a57 | |||
| 3359bdc464 | |||
| 17faee5d81 | |||
| 5cd852f9bd | |||
| 4c75b1c102 | |||
| ef27c11d50 | |||
| cd3939a153 | |||
| 9f5463ce42 | |||
| 3bc1b53962 | |||
| de1b919641 | |||
| 03e224ee83 | |||
| c2bc171ef6 | |||
| f8740e124c | |||
| 57da381ae3 | |||
| 935cb4076b | |||
| b2ea15da35 | |||
| 9733177083 | |||
| fa665141bb | |||
| 64720f15a2 | |||
| 8df0f13230 | |||
| 94e7be3714 | |||
| 9b4adc9acb | |||
| e27162397a | |||
| 99d750d597 | |||
| 8391a23600 | |||
| ec3ef520e6 | |||
| 28aab134db | |||
| 752cc26ad6 | |||
| d159417474 | |||
| 7b0d7d0c9a | |||
| 7631056b8a | |||
| 4107dc7355 | |||
| 085a131801 | |||
| 50fed1d774 | |||
| c240355cc6 | |||
| a9edcc1705 | |||
| 4b3d2c8834 | |||
| 48d9031efb | |||
| a8adb99e94 | |||
| b01ae2de05 | |||
| af71b03000 | |||
| 392991fa0b | |||
| 1bfc75ac23 | |||
| def679554f | |||
| 08b6abd711 | |||
| 33761ee06b | |||
| d2b8fd6401 | |||
| 4f236d1c50 | |||
| f9f9e2ad4a | |||
| 23c246882e | |||
| f290ff215e | |||
| 1f3255d76b | |||
| fdeac73a59 | |||
| 175cd03ff2 | |||
| d6a7f5e1e0 | |||
| 8ce08dedfe | |||
| 32377ce57d | |||
| d84a9484b7 | |||
| 55a2bcbe15 | |||
| f2422ace7d | |||
| 3e5d7e1718 | |||
| 8286d84fb1 | |||
| c42d0c8374 | |||
| 37bfb3c48d | |||
| b3937288e5 | |||
| 7eaa548b6d | |||
| d7e936de5c | |||
| d2bc0e5fe0 | |||
| d8107a5125 | |||
| a82c50eac2 | |||
| 7fa9efbfd8 | |||
| fe3893ff01 | |||
| e8348e5f64 | |||
| fb85974d01 | |||
| 3377ddaf09 | |||
| 962f5c9b82 | |||
| 2c634eeef2 | |||
| c6e60f06eb | |||
| e5d2642780 | |||
| a9f4f8ded4 | |||
| 26e8048a0a | |||
| 6bfb0dda85 | |||
| 8ae1552a5b | |||
| 00f36a3149 | |||
| 12a36b5a94 | |||
| e371592f75 | |||
| 84a3654371 | |||
| 7e5c4fe1cd | |||
| 773ccc4bf8 | |||
| b31ce408ae | |||
| 7983c484b2 | |||
| 6502737bd5 | |||
| b98dd728ca | |||
| 7f3ba5963d | |||
| 43e58de918 | |||
| e309ad8465 | |||
| 2fa624aef0 | |||
| e958600f32 | |||
| 484251c52b | |||
| 512be4ab65 | |||
| 6f8120cb3a | |||
| c42d47d94a | |||
| d35e2f5339 | |||
| 91ce6ef190 | |||
| aac30e772f | |||
| acc142d4ba | |||
| 24fac5f56d | |||
| 4e4458416d | |||
| da2978f607 | |||
| 7c78c59e64 | |||
| 0cc92bd67c | |||
| 2cf2456f4c | |||
| 8c5b3c4150 | |||
| 36d771affc | |||
| 387a76ba59 | |||
| f601e817fe | |||
| 3fd0d0dafb | |||
| f28895cd6b | |||
| 0800f6f91b | |||
| f4f462c50b | |||
| 359ecda4fc | |||
| bf0846f0ea | |||
| 0401d5920c | |||
| ac418e999d | |||
| ae42815b7d | |||
| 5a3a915a9b | |||
| 632a08ff40 | |||
| 1b3dd8f38b | |||
| ce31c9c448 | |||
| bc434e8f67 | |||
| e05c2e0f1d | |||
| 2255973b0f | |||
| ac24a72e66 | |||
| bb067c7ebf | |||
| 599bb9c457 | |||
| 12b8d542b7 | |||
| fef23768fe | |||
| 328883b6ea | |||
| 87ed750510 | |||
| cc7f17f011 | |||
| 3c25fd1ba5 | |||
| 301c078d19 | |||
| 9485113923 | |||
| 4f3130f562 | |||
| a783bf4a93 | |||
| f7e8dc770a | |||
| 34909d97b4 | |||
| 474a67231c | |||
| b645fc10a3 | |||
| 8e1e08ee38 | |||
| d266fee8bb | |||
| 8357e865bc | |||
| fe9a8ebea2 | |||
| 2b558a3787 | |||
| 72d06080c6 | |||
| 3cdf926454 | |||
| 025a9647af | |||
| 32e7ef8a3d | |||
| 2b82f8f12c | |||
| 3a184ae677 | |||
| 564d1a0f79 | |||
| 05c011e842 | |||
| 61144f935e | |||
| d23435baac | |||
| 41c2669476 | |||
| ed3591ed1f | |||
| 5dae278652 | |||
| 30d91e8ed6 | |||
| c69417149d | |||
| 08271e5591 | |||
| a104e7c593 | |||
| c3e7a23da5 | |||
| 083edb201c | |||
| df7bf9a048 | |||
| bed5debca6 | |||
| caa1658a4c | |||
| bb5b628cce | |||
| 127a44f2b9 | |||
| ad71a1633c | |||
| fb69620a27 | |||
| a6e15b2f57 | |||
| 39ecd96b09 | |||
| 21a8d9569d | |||
| 24d60da553 | |||
| 039795b405 | |||
| 716450ceb5 | |||
| 97eaddd93b | |||
| e3ce0fbee3 | |||
| 364702b1c9 | |||
| 0f7b2eb79f | |||
| 4a0760719e | |||
| d011383a3d | |||
| 0ec94630d4 | |||
| c71f2714c6 | |||
| 71462d9f99 | |||
| 61a8cf8ba7 | |||
| 8869d3212f | |||
| aac7c5465b | |||
| 22ee5c0c4d | |||
| 7f3d8de26f | |||
| 331b73c8e4 | |||
| 9138c98b25 | |||
| 456af21d8b | |||
| c82417697a | |||
| bd19f991a5 | |||
| e87ba1d317 | |||
| f9d1f5196a | |||
| b5717f82a0 | |||
| bc6a70c689 | |||
| 1fb6c6e6e5 | |||
| d2dbc9d7a0 | |||
| 8c4d415412 | |||
| 25163eb008 | |||
| 96e8b83d41 | |||
| de93782fab | |||
| 7ed82aea38 | |||
| dc15187f1b | |||
| ae1a249a0a | |||
| 171fbf879f | |||
| 8a1caa0d16 | |||
| cdcf7e62f3 | |||
| 083727b0a6 | |||
| 718dd9f170 | |||
| 6c218c7b0f | |||
| e87a0baa4b | |||
| 8ee5f2ad89 | |||
| ee76cef1ff | |||
| 6da05f7086 | |||
| e24b1629a0 | |||
| d9ea9bedb2 | |||
| 1546b9bf99 | |||
| 62b5d37b6b | |||
| d78d9bf151 | |||
| a5f0fb6008 | |||
| f2bb3d0d80 | |||
| 037a72debd | |||
| 1ef4b7ae5a | |||
| b314cc4c23 | |||
| 644de8f22a | |||
| 36f61f3879 | |||
| aa11f7d8a3 | |||
| f30aafc3cc | |||
| 2f065b8b4c | |||
| aece3e732e | |||
| ebe9327a92 | |||
| 102d8f67cd | |||
| a00fe15abd | |||
| 3acf8cfd63 | |||
| d34717d8c9 | |||
| a5b8f163d7 | |||
| 6add3b9161 | |||
| 1ddd61f98a | |||
| 3503a36e5e | |||
| 2ea7269450 | |||
| a968eadbf1 | |||
| c6b63e0e28 | |||
| 7bd8ddc8fa | |||
| 14e264f646 | |||
| 969b55036f | |||
| cbf978d1f7 | |||
| 94e0ac7d9f | |||
| 08b36e4f48 | |||
| d62d880316 | |||
| 361b5e0ebf | |||
| c16e2e6234 | |||
| c08f29c803 | |||
| ecb6d03ccd | |||
| e59793cc75 | |||
| 236ad4aeda | |||
| 97bb91d5fa | |||
| 233030e417 | |||
| 6256e425f3 | |||
| 48368dc9a1 | |||
| 691c655630 | |||
| b88ad7f2d9 | |||
| b300b6b3bd | |||
| 234117800f | |||
| ac58b2f857 | |||
| 220b37144b | |||
| 74c8ccb45b | |||
| 9cfe981e1f | |||
| 2f9072efdc | |||
| 5e90802b1a | |||
| 45fee13f3d | |||
| 261ad78122 | |||
| 4fa82809df | |||
| 3e3787ecb6 | |||
| a723aaedd8 | |||
| ebb528976f | |||
| f77c2d700f | |||
| 8c44b8306b | |||
| e668cff573 | |||
| fa953e4205 | |||
| 540982cc9d | |||
| a61546680b | |||
| 8cb7eae5c9 | |||
| 18440c1faf | |||
| 9f69ca503a | |||
| 49ba744130 | |||
| 4b24ddd70d | |||
| 1612db5f91 | |||
| 7dfe68cac6 | |||
| 83807811cd | |||
| 23e71d1aa2 | |||
| b542a1804c | |||
| 2dff2f36bf | |||
| 6b674709b8 | |||
| f56445d7ca | |||
| 03bee14372 | |||
| 50ff40d684 | |||
| c31164bf1e | |||
| 3835ab394e | |||
| 20b23da8e2 | |||
| f6795d75a6 | |||
| fa11b98800 | |||
| 64c67a93d3 | |||
| 154380ccf5 | |||
| 1f2c83845d | |||
| 2349a09736 | |||
| 1df533c914 | |||
| 44bf748479 | |||
| f9fbd29c14 | |||
| 31dc3e9256 | |||
| 698b2bf729 | |||
| 1d42560018 | |||
| efcf307b4c | |||
| 6876f3b91d | |||
| 7495a4722f | |||
| 7ce56b3a47 | |||
| 5376863c0c | |||
| a86e036594 | |||
| 01324b02e7 | |||
| 792722865f | |||
| 9aa401a7d0 | |||
| a160e4fb6b | |||
| c7422e4d90 | |||
| 485d2b593c | |||
| 1bea537731 | |||
| 75e88d613f | |||
| 379b83e946 | |||
| dda1bf1887 | |||
| f7e524cbe6 | |||
| e503ac508e | |||
| f5ba3f51ce | |||
| d392b11dfb | |||
| cd01ee9a54 | |||
| 8c1af09989 | |||
| f53ff0d01c | |||
| 4f48dab023 | |||
| a7ffcaab28 | |||
| f617f18e46 | |||
| 4372d75b26 | |||
| da555a2c9b | |||
| 885fb703cf | |||
| cd00d8f3f0 | |||
| b3755e617c | |||
| fc0f9da7a7 | |||
| 277961fa25 | |||
| 14a9103fc0 | |||
| 6d1f7c2b1b | |||
| 2c1f3487a4 | |||
| acc6189da0 | |||
| ac177b849c | |||
| 29aeebf5bc | |||
| cc769ff19d | |||
| 1834eed809 | |||
| b34234ac14 | |||
| 7ec9f52509 | |||
| 68f527267b | |||
| 7f22b34c78 | |||
| ad63d24dba | |||
| 3b5813c035 | |||
| 339b963e6b | |||
| 00890aecdf | |||
| 2171cae8ff | |||
| 3f55152ca0 | |||
| f3cebb3e1b | |||
| 2b227f00f2 | |||
| 98de57c6c4 | |||
| e231be86b7 | |||
| 7ec221e734 | |||
| fe9ff64d64 | |||
| 3f65c12d0c | |||
| 336627a776 | |||
| 6226ea0085 | |||
| 1067cd0649 | |||
| 1537ecd931 | |||
| 5b5c42d2c7 | |||
| 161890dad4 | |||
| 35846fe735 | |||
| 96ce65f021 | |||
| 8457e471fd | |||
| 246de2b7f5 | |||
| e8c26963e9 | |||
| 793e7c0d9f | |||
| 3b337a12c9 | |||
| 2c32cb743c | |||
| 883b995fd6 | |||
| a28533933f | |||
| d695208727 | |||
| 613ff61de7 | |||
| 65b02cc8f2 | |||
| 1c8ee3f957 | |||
| 922108060d | |||
| ce74285c5e | |||
| c262eea84a | |||
| f2ca7e664a | |||
| cf8f65d806 | |||
| bc221bdb90 | |||
| 6bed5c181b | |||
| f162c08cda | |||
| 0d1d452b79 | |||
| 3c3e131c38 | |||
| a218cf3c61 | |||
| 866468cc3e | |||
| f66fc199a2 | |||
| 11ac26bfb4 | |||
| 2241bfb0df | |||
| d92af2aa85 | |||
| e4d573a080 | |||
| f86c8656a3 | |||
| 6697f0ea86 | |||
| e935f06f16 | |||
| 1e18004bdd | |||
| 19646ad049 | |||
| 7e943808b6 | |||
| 88dbee3589 | |||
| 5bfa43f7d5 | |||
| 7ed37b3fa5 | |||
| f0271e54d9 | |||
| 0ac2f0e04c | |||
| ef1690ef45 | |||
| 0fa06b1db0 | |||
| abceef74e0 | |||
| 5444a6b11c | |||
| 9411cd6c07 | |||
| a35d4f9029 | |||
| 284d26da05 | |||
| e8d4259f9a | |||
| 8086afc60a | |||
| b2ebd37ee2 | |||
| 83e6813345 | |||
| 09f24a851e | |||
| 81e027eef7 | |||
| 1c371d07b5 | |||
| 55e8549839 | |||
| f8d6c5b330 | |||
| 435b6df989 | |||
| bf8136eaa6 | |||
| cc584760d3 | |||
| d41b20b268 | |||
| 36da867caf | |||
| c5f540e3d7 | |||
| c90e824342 | |||
| 749bd80091 | |||
| 1c0b70bbd2 | |||
| b75f6c05c0 | |||
| 269b810601 | |||
| e54040d540 | |||
| b96e9a4a4a | |||
| e18df87a15 | |||
| 5cb8619eca | |||
| 476094ad5a | |||
| d2469edd10 | |||
| 0df8fb70b4 | |||
| 4dd9a36a3c | |||
| 41678fe3d3 | |||
| 5bc6b6fc26 | |||
| 8931c68b20 | |||
| f78f908c09 | |||
| 5487bca4f3 | |||
| 762a5c8334 | |||
| 2fed41dfa5 | |||
| e0f9eac521 | |||
| b90a2a8497 | |||
| 950a916952 | |||
| 3f13339071 | |||
| eb6678ebef | |||
| d62e0a3695 | |||
| dcb7fd8520 | |||
| d5713c657b | |||
| 99c4b76a6d | |||
| e4887aaa5b | |||
| d69a7a3bbf | |||
| ccf6dd07b3 | |||
| e8129429e9 | |||
| 2566d13100 | |||
| 5a15369d4d | |||
| deaf1dd458 | |||
| 65f87b114b | |||
| 8f5b453a96 | |||
| b7eec216e9 | |||
| 17c430da88 | |||
| 96a501c08b | |||
| dc57707e60 | |||
| 56b5a7d977 | |||
| 65dbbf712d | |||
| 49497d8e7c | |||
| 728684840c | |||
| 73f7d091f8 | |||
| 00e1bc49c8 | |||
| cb3a098b25 | |||
| 5a7045181a | |||
| 6a045fd678 | |||
| 327f92cc46 | |||
| 482cacd420 | |||
| 93a6be836c | |||
| ef7185ce43 | |||
| 920c180052 | |||
| a84afb6334 | |||
| cdac7c7bec | |||
| fe09c79f4b | |||
| cabad90d6c | |||
| 6dba1733f0 | |||
| daa88c6b9e | |||
| 9b727fa1f3 | |||
| e45d74c8f9 | |||
| 923009b5ff | |||
| 4064d4c7eb | |||
| e58ce89b10 | |||
| 6259ba1bfd | |||
| cd8262eb79 | |||
| d2b854674e | |||
| ad930f6216 | |||
| f061a0ab36 | |||
| 2e165053ef | |||
| 8cc8b0d2b4 | |||
| 06b4292534 | |||
| 29f883feee | |||
| 0e69cddda2 | |||
| ad5e70f94e | |||
| 7fae2e834c | |||
| 8e3f5fb209 | |||
| 05fbd1e5bc | |||
| 1491934d17 | |||
| fce486c4f9 | |||
| 1b4955342f | |||
| 95ac650af6 | |||
| 2b98aa403e | |||
| 425c653a14 | |||
| 52844614c4 | |||
| 85c0c8c7ed | |||
| a8f04359e8 | |||
| cb54f4c2ec | |||
| 77fa1a20bf | |||
| a7cdc42140 | |||
| a8aa9d5ecb | |||
| 52fbfb3ec0 | |||
| d25293b721 | |||
| c07af090f5 | |||
| 456e88a8a4 | |||
| a7cc1159cd | |||
| 6bd87e8146 | |||
| 42a4c3fba6 | |||
| 1cba763189 | |||
| d01cbe9320 | |||
| b10ab79743 | |||
| 619462b029 | |||
| d93b6be3cc | |||
| 9755ab160d | |||
| 2043e06102 | |||
| c7dcdc0e88 | |||
| eb67dc9f50 | |||
| 676b818d6a | |||
| 411ce04f54 | |||
| d321a34f7c | |||
| fb1a58ac76 | |||
| 1644af841b | |||
| b0def9617f | |||
| c2664d912a | |||
| 9697e3ac24 | |||
| d2a9efd039 | |||
| 442999dcdb | |||
| d753ae1489 | |||
| db3e3be8ee | |||
| 0c8da03869 | |||
| 0417c8c9c7 | |||
| d4af89781b | |||
| a8c1cdf88e | |||
| 7a187e9b5e | |||
| 9096b1c768 | |||
| 781fbde449 | |||
| 1b336bb602 | |||
| 0fb3b8db72 | |||
| b44302382d | |||
| 458f1d5ebe | |||
| a43e3bebe6 | |||
| f62fe956d1 | |||
| 852b0226e0 | |||
| ef3844a177 | |||
| 476aa443c6 | |||
| cb0f74ab9f | |||
| 08d1c54364 | |||
| dbbfa003d3 | |||
| 5ffc5bca7c | |||
| 11ac2e1475 | |||
| 59608907b8 | |||
| e454c4891e | |||
| 3ed243abde | |||
| d60524ecfa | |||
| 345e071b24 | |||
| be1a121d0d | |||
| 156406b56c | |||
| f68654a204 | |||
| 8abb312c20 | |||
| adcb943f61 | |||
| 5489735258 | |||
| 8de176988d | |||
| 79c5d07abe | |||
| 74020a084b | |||
| 09acd478f1 | |||
| e6c9e2fa50 | |||
| ab2c59b80e | |||
| a5209c4882 | |||
| f1dd5e49c5 | |||
| c6b60e219d | |||
| 740f6628ec | |||
| 821fac187c | |||
| 73fdf75328 | |||
| f7daa9e4f5 | |||
| e58e545584 | |||
| 319db07b6b | |||
| 407cc5f1b6 | |||
| 80037dc6de | |||
| d9bada9867 | |||
| 6b89154afd | |||
| 1f2d4e4839 | |||
| 4a9904fe62 | |||
| 4b5fdc6bb2 | |||
| 2d11edd103 | |||
| fef6192bca | |||
| 7d9e1be588 | |||
| ba3cf47600 | |||
| 9e09828cc3 | |||
| b236f10792 | |||
| f0bef94a03 | |||
| 1bec7ca540 | |||
| 29bbbaa0a7 | |||
| 73aa5f567b | |||
| d5e8792f55 | |||
| 5393185add | |||
| 9fef09fe89 | |||
| a9b030591b | |||
| d4a9c731ff | |||
| 17d15df6cd | |||
| 98611adeb9 | |||
| 01a8c9ca8d | |||
| 0940c56a3f | |||
| d650b5cc5a | |||
| b624da27bd | |||
| 5b443199ca | |||
| cb82388a84 | |||
| 735c31bb4a | |||
| b7253e3280 | |||
| 94d187e269 | |||
| d991c22090 | |||
| 322960f795 | |||
| b5035ce991 | |||
| 07c56f149f | |||
| 0e1c7eda39 | |||
| 2b2bcc9b38 | |||
| a3b109eca0 | |||
| a1b09a3734 | |||
| d81ac52ce2 | |||
| 220df8252d | |||
| de720ac34a | |||
| 68d59a2913 | |||
| 753e417dec | |||
| 7d1094b7e1 | |||
| 58426c80a3 | |||
| cddd7f10d5 | |||
| ea3c2307dc | |||
| 65b3209441 | |||
| 400a781ebf | |||
| c8689d9d0a | |||
| ea0d1424d8 | |||
| 365f44b094 | |||
| bcf96d637e | |||
| 6ced54a892 | |||
| c5a2d28367 | |||
| b4a6aa335d | |||
| 35245cb76e | |||
| fa349b7a4e | |||
| df305e83fa | |||
| b2464e3379 | |||
| 6856cc7253 | |||
| 508bd3f55d | |||
| 8b51e2df8b | |||
| bd1b252de9 | |||
| f30931848e | |||
| b27ae9c63b | |||
| 79f8b7fd73 | |||
| 48e9e651a4 | |||
| 1bf353b876 | |||
| 23e336ee53 | |||
| ac54bb193c | |||
| e9058ea8f5 | |||
| fd06139c20 | |||
| b43da8aa5d | |||
| 066259b656 | |||
| 64f5471b2a | |||
| 4e789635c9 | |||
| 7c17695be4 | |||
| 73bbabcd04 | |||
| 93d79d2e5d | |||
| 1889d72889 | |||
| 5813d2439c | |||
| 4f1ba5e69e | |||
| c934d9c3cc | |||
| 00b19d6fba | |||
| 8b13b85c5e | |||
| 64b0757758 | |||
| 1622e7cc90 | |||
| 1f9713195b | |||
| ea04f9d12e | |||
| 74e4cfd1da | |||
| 27ee6501eb | |||
| a5696da9ec | |||
| 0b439bcd08 | |||
| b805115c1a | |||
| c41fb45da3 | |||
| cdfa58dde0 | |||
| 6630eac813 | |||
| 63f5f93063 | |||
| 5da4bb7e88 | |||
| dc1b1f2cd7 | |||
| 25ec4ce6f1 | |||
| d30bc0a4c0 | |||
| c05ac8729e | |||
| 9926a93a78 | |||
| 7093752cb5 | |||
| 0daf055fe6 | |||
| 3f38edfd61 | |||
| ee201f4df5 | |||
| 9181ecfc7b | |||
| 4bf94cb5d1 | |||
| 599a3026d1 | |||
| 288fa70ed9 | |||
| 8d05dab32c | |||
| 3c14a8c507 | |||
| ab3b1e9922 | |||
| cd7db168e0 | |||
| cbcdbde29d | |||
| 2df978b8e7 | |||
| 10808ccbb4 | |||
| f756923271 | |||
| a327418767 | |||
| 83c4378d5d | |||
| e74075c689 | |||
| 1c1762d3f6 | |||
| e0ac0cfbe2 | |||
| 775d031366 | |||
| 1a17f402a4 | |||
| 40973bea31 | |||
| 0be2c7018b | |||
| aa08900ac8 | |||
| d37180a2c4 | |||
| 8badf7f354 | |||
| 150bd3aee6 | |||
| a748eba42e | |||
| 935420217c | |||
| 81d4d4948e | |||
| 041da57e87 | |||
| acf1be547d | |||
| 908bf935f7 | |||
| e59e978fcd | |||
| fbaae7ac37 | |||
| dcf7eb972e | |||
| 2840362868 | |||
| d4fc302c7e | |||
| 1cce9db710 | |||
| e92f1eaa3d | |||
| f84cae833a | |||
| ed58b5489f | |||
| ef5fa498d4 | |||
| 78e4fbd2d7 | |||
| 96075ce0c9 | |||
| c007228d0f | |||
| dca9b4283b | |||
| dcec3150f0 | |||
| d015db3de8 | |||
| ef7fb905aa | |||
| 5e5385a814 | |||
| 7aaa918367 | |||
| c2e484a465 | |||
| f64d807863 | |||
| 81c2f3d194 | |||
| 8c77f35fce | |||
| ff4ce9f7b1 | |||
| f39784c584 | |||
| 98e38b2a41 | |||
| 1d8c73cf6c | |||
| ef68cc3d5f | |||
| 18550b4601 | |||
| c8f1948d58 | |||
| f6de25b6cb | |||
| b3514a5708 | |||
| 91b0100287 | |||
| 870a775d7d | |||
| 575a609b80 | |||
| 675342ecd9 | |||
| 245b2fec34 | |||
| 49a75079f2 | |||
| d3f9ad1145 | |||
| 46615ffc4a | |||
| f0ffc52435 | |||
| f7d029cfce | |||
| 1eb63cfc42 | |||
| 43ff8f8e8d | |||
| b11a3a0820 | |||
| bef6b6282c | |||
| 9c58a7cb1e | |||
| 69ac19d82d | |||
| b77fe9d624 | |||
| 5c7c80dd27 | |||
| d7abb641ca | |||
| 4e75f31c55 | |||
| e1f14fcac7 | |||
| 39d3bbb601 | |||
| 4d35a46c48 | |||
| 2c9d149ac2 | |||
| 06bf845783 | |||
| f496a37340 | |||
| b745e1c43a | |||
| 21ed892489 | |||
| 5504d94e36 | |||
| adf54d41d5 | |||
| 75bd9f86b2 | |||
| 734771418e | |||
| 51a8885566 | |||
| 60c382d8f1 | |||
| 3371e679ce | |||
| ce5626db45 | |||
| 1377b9b736 | |||
| 936428cb3b | |||
| c305455cb2 | |||
| 8334932a26 | |||
| 99d29c9d39 | |||
| a448d3a6aa | |||
| 1a6b4d6ce6 | |||
| a15417fe74 | |||
| 3dcb775d16 | |||
| 2d387356de | |||
| 07c3aae315 | |||
| b36eba7fab | |||
| 8574a757f9 | |||
| 0812207db7 | |||
| 1cc1e6fa56 | |||
| 6216bf9221 | |||
| 388a7ce86e | |||
| 5d95a500ad | |||
| 95341c2b1b | |||
| 54063c40de | |||
| 585593e9fc | |||
| f15e885baf | |||
| 9109cb1ec6 | |||
| dc9ee53ff5 | |||
| 1485968fc4 | |||
| 09134ac881 | |||
| 433c5199fd | |||
| 396f43d674 | |||
| e12b1c2209 | |||
| f6b2b49e4a | |||
| e1322cf503 | |||
| 67dfdee33f | |||
| 61c4cfd896 | |||
| be17f532e1 | |||
| 6d85fa3fd2 | |||
| 222a48577f | |||
| 353273579b | |||
| 7373ef0983 | |||
| 2740901378 | |||
| e661ad2a67 | |||
| 3a4b79173b | |||
| bdc29cccb6 | |||
| 7465125f67 | |||
| 340df65fb4 | |||
| 9a463b74dc | |||
| 7e4b2057f2 | |||
| c920b45fb8 | |||
| 2a9a2fff66 | |||
| 2947877871 | |||
| fadb90c579 | |||
| dfb9832a25 | |||
| fd46684bf8 | |||
| 9badb0d903 | |||
| c5f06814bc | |||
| 69d43e2997 | |||
| 0f0dea79fc | |||
| b6d636214e | |||
| 4b64955a12 | |||
| 546239a3a8 | |||
| 8be0a3452d | |||
| 99d914ea3b | |||
| 24284d3d17 | |||
| 9fc872b70b | |||
| e3654d5416 | |||
| d92bee821d | |||
| df10411e05 | |||
| 44e9fb306d |
@@ -1,5 +1,5 @@
|
||||
<!--
|
||||
If you have a question rather than reporting a bug please go to http://answers.opencv.org where you get much faster responses.
|
||||
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
|
||||
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).
|
||||
|
||||
This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
|
||||
@@ -27,4 +27,4 @@ This is a template helping you to create an issue which can be processed as quic
|
||||
// C++ code example
|
||||
```
|
||||
or attach as .txt or .zip file
|
||||
-->
|
||||
-->
|
||||
|
||||
Vendored
+3
-2
@@ -27,7 +27,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(carotene_objs OBJECT
|
||||
add_library(carotene_objs OBJECT EXCLUDE_FROM_ALL
|
||||
${carotene_headers}
|
||||
${carotene_sources}
|
||||
)
|
||||
@@ -40,4 +40,5 @@ if(WITH_NEON)
|
||||
target_compile_definitions(carotene_objs PRIVATE "-DWITH_NEON")
|
||||
endif()
|
||||
|
||||
add_library(carotene STATIC EXCLUDE_FROM_ALL "$<TARGET_OBJECTS:carotene_objs>")
|
||||
# we add dummy file to fix XCode build
|
||||
add_library(carotene STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} "$<TARGET_OBJECTS:carotene_objs>" "${CAROTENE_SOURCE_DIR}/dummy.cpp")
|
||||
|
||||
Vendored
+2
-1
@@ -80,7 +80,8 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${carotene_defs})
|
||||
# set_source_files_properties(impl.cpp $<TARGET_OBJECTS:carotene_objs> COMPILE_FLAGS "--param ipcp-unit-growth=100000 --param inline-unit-growth=100000 --param large-stack-frame-growth=5000")
|
||||
endif()
|
||||
|
||||
add_library(tegra_hal STATIC $<TARGET_OBJECTS:carotene_objs>)
|
||||
# we add dummy file to fix XCode build
|
||||
add_library(tegra_hal STATIC $<TARGET_OBJECTS:carotene_objs> "dummy.cpp")
|
||||
set_target_properties(tegra_hal PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH})
|
||||
set(OPENCV_SRC_DIR "${CMAKE_SOURCE_DIR}")
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// This file is needed for compilation on some platforms e.g. with XCode generator
|
||||
// Related issue: https://gitlab.kitware.com/cmake/cmake/-/issues/17457
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
// This file is needed for compilation on some platforms e.g. with XCode generator
|
||||
// Related issue: https://gitlab.kitware.com/cmake/cmake/-/issues/17457
|
||||
Vendored
+1
-1
@@ -758,7 +758,7 @@ inline void resizeAreaRounding(const Size2D &ssize, const Size2D &dsize,
|
||||
}
|
||||
else if (channels == 3)
|
||||
{
|
||||
if ((wr == 2.0f) && (wr == 2.0f))
|
||||
if ((wr == 2.0f) && (hr == 2.0f))
|
||||
{
|
||||
#ifndef __ANDROID__
|
||||
size_t roiw16 = dsize.width >= 15 ? (dsize.width - 15) * 3 : 0;
|
||||
|
||||
Vendored
+2
-2
@@ -14,7 +14,7 @@ if(NOT DEFINED CPUFEATURES_SOURCES)
|
||||
endif()
|
||||
|
||||
include_directories(${CPUFEATURES_INCLUDE_DIRS})
|
||||
add_library(${OPENCV_CPUFEATURES_TARGET_NAME} STATIC ${CPUFEATURES_SOURCES})
|
||||
add_library(${OPENCV_CPUFEATURES_TARGET_NAME} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${CPUFEATURES_SOURCES})
|
||||
|
||||
set_target_properties(${OPENCV_CPUFEATURES_TARGET_NAME}
|
||||
PROPERTIES OUTPUT_NAME cpufeatures
|
||||
@@ -29,7 +29,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${OPENCV_CPUFEATURES_TARGET_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${OPENCV_CPUFEATURES_TARGET_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(cpufeatures LICENSE README.md)
|
||||
|
||||
Vendored
+5
-5
@@ -1,8 +1,8 @@
|
||||
# Binaries branch name: ffmpeg/3.4_20200310
|
||||
# Binaries were created for OpenCV: 4966186e10e2a940514d8c20447ca4a828af5f46
|
||||
ocv_update(FFMPEG_BINARIES_COMMIT "e81ccda615672833b578c6cefdb859ad69c560ba")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN32 "301ae2000e25f800ab8e0065f277ad28")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN64 "d87ce032289c3f811d02f0c3d8dbe366")
|
||||
# Binaries branch name: ffmpeg/3.4_20210302
|
||||
# Binaries were created for OpenCV: 2ab1f3f166fccc3a01497209cc01c5cea44ff201
|
||||
ocv_update(FFMPEG_BINARIES_COMMIT "e99214251d9f3cde7c48abd46b2259bddc9885b6")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN32 "fad5ada9be36120bba8966709e7953a8")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN64 "650e2272728491923e566f784f79cfef")
|
||||
ocv_update(FFMPEG_FILE_HASH_CMAKE "3b90f67f4b429e77d3da36698cef700c")
|
||||
|
||||
function(download_win_ffmpeg script_var)
|
||||
|
||||
Vendored
+2
-2
@@ -17,7 +17,7 @@ file(GLOB lib_hdrs ${IPP_IW_PATH}/include/*.h ${IPP_IW_PATH}/include/iw/*.h ${IP
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
add_library(${IPP_IW_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
add_library(${IPP_IW_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if(UNIX)
|
||||
if(CV_GCC OR CV_CLANG OR CV_ICC)
|
||||
@@ -41,5 +41,5 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${IPP_IW_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${IPP_IW_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
Vendored
+2
-2
@@ -37,7 +37,7 @@ set(ITT_SRCS
|
||||
src/ittnotify/jitprofiling.c
|
||||
)
|
||||
|
||||
add_library(${ITT_LIBRARY} STATIC ${ITT_SRCS} ${ITT_PUBLIC_HDRS} ${ITT_PRIVATE_HDRS})
|
||||
add_library(${ITT_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${ITT_SRCS} ${ITT_PUBLIC_HDRS} ${ITT_PRIVATE_HDRS})
|
||||
|
||||
if(NOT WIN32)
|
||||
if(HAVE_DL_LIBRARY)
|
||||
@@ -60,7 +60,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${ITT_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${ITT_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(ittnotify src/ittnotify/LICENSE.BSD src/ittnotify/LICENSE.GPL)
|
||||
|
||||
Vendored
+2
-2
@@ -17,7 +17,7 @@ file(GLOB lib_ext_hdrs jasper/*.h)
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
add_library(${JASPER_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs} ${lib_ext_hdrs})
|
||||
add_library(${JASPER_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs} ${lib_ext_hdrs})
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
add_definitions(-DJAS_WIN_MSVC_BUILD)
|
||||
@@ -46,7 +46,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${JASPER_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${JASPER_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(jasper LICENSE README copyright)
|
||||
|
||||
+6
-4
@@ -4,9 +4,9 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wsign-compare -Wshorten-6
|
||||
|
||||
set(VERSION_MAJOR 2)
|
||||
set(VERSION_MINOR 0)
|
||||
set(VERSION_REVISION 4)
|
||||
set(VERSION_REVISION 6)
|
||||
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION})
|
||||
set(LIBJPEG_TURBO_VERSION_NUMBER 2000004)
|
||||
set(LIBJPEG_TURBO_VERSION_NUMBER 2000006)
|
||||
|
||||
string(TIMESTAMP BUILD "opencv-${OPENCV_VERSION}-libjpeg-turbo")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
@@ -65,6 +65,8 @@ set(JPEG_LIB_VERSION 62)
|
||||
# OpenCV
|
||||
set(JPEG_LIB_VERSION "${VERSION}-${JPEG_LIB_VERSION}" PARENT_SCOPE)
|
||||
|
||||
set(THREAD_LOCAL "") # WITH_TURBOJPEG is not used
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-W3 -wd4996 -wd4018)
|
||||
endif()
|
||||
@@ -104,7 +106,7 @@ set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
|
||||
|
||||
ocv_list_add_prefix(JPEG_SOURCES src/)
|
||||
|
||||
add_library(${JPEG_LIBRARY} STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
|
||||
add_library(${JPEG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${JPEG_SOURCES} ${SIMD_OBJS})
|
||||
|
||||
set_target_properties(${JPEG_LIBRARY}
|
||||
PROPERTIES OUTPUT_NAME ${JPEG_LIBRARY}
|
||||
@@ -119,7 +121,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(libjpeg-turbo README.md LICENSE.md README.ijg)
|
||||
|
||||
Vendored
+1
-1
@@ -91,7 +91,7 @@ best of our understanding.
|
||||
The Modified (3-clause) BSD License
|
||||
===================================
|
||||
|
||||
Copyright (C)2009-2019 D. R. Commander. All Rights Reserved.
|
||||
Copyright (C)2009-2020 D. R. Commander. All Rights Reserved.
|
||||
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
Vendored
+8
-14
@@ -223,12 +223,12 @@ https://www.iso.org/standard/54989.html and http://www.itu.int/rec/T-REC-T.871.
|
||||
A PDF file of the older JFIF 1.02 specification is available at
|
||||
http://www.w3.org/Graphics/JPEG/jfif3.pdf.
|
||||
|
||||
The TIFF 6.0 file format specification can be obtained by FTP from
|
||||
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
|
||||
found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
|
||||
IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).
|
||||
Instead, we recommend the JPEG design proposed by TIFF Technical Note #2
|
||||
(Compression tag 7). Copies of this Note can be obtained from
|
||||
The TIFF 6.0 file format specification can be obtained from
|
||||
http://mirrors.ctan.org/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation
|
||||
scheme found in the TIFF 6.0 spec of 3-June-92 has a number of serious
|
||||
problems. IJG does not recommend use of the TIFF 6.0 design (TIFF Compression
|
||||
tag 6). Instead, we recommend the JPEG design proposed by TIFF Technical Note
|
||||
#2 (Compression tag 7). Copies of this Note can be obtained from
|
||||
http://www.ijg.org/files/. It is expected that the next revision
|
||||
of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
|
||||
Although IJG's own code does not support TIFF/JPEG, the free libtiff library
|
||||
@@ -243,14 +243,8 @@ The most recent released version can always be found there in
|
||||
directory "files".
|
||||
|
||||
The JPEG FAQ (Frequently Asked Questions) article is a source of some
|
||||
general information about JPEG.
|
||||
It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/
|
||||
and other news.answers archive sites, including the official news.answers
|
||||
archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/.
|
||||
If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu
|
||||
with body
|
||||
send usenet/news.answers/jpeg-faq/part1
|
||||
send usenet/news.answers/jpeg-faq/part2
|
||||
general information about JPEG. It is available at
|
||||
http://www.faqs.org/faqs/jpeg-faq.
|
||||
|
||||
|
||||
FILE FORMAT COMPATIBILITY
|
||||
|
||||
Vendored
+11
-10
@@ -2,7 +2,7 @@ Background
|
||||
==========
|
||||
|
||||
libjpeg-turbo is a JPEG image codec that uses SIMD instructions to accelerate
|
||||
baseline JPEG compression and decompression on x86, x86-64, ARM, PowerPC, and
|
||||
baseline JPEG compression and decompression on x86, x86-64, Arm, PowerPC, and
|
||||
MIPS systems, as well as progressive JPEG compression on x86 and x86-64
|
||||
systems. On such systems, libjpeg-turbo is generally 2-6x as fast as libjpeg,
|
||||
all else being equal. On other types of systems, libjpeg-turbo can still
|
||||
@@ -179,8 +179,8 @@ supported and which aren't.
|
||||
|
||||
NOTE: As of this writing, extensive research has been conducted into the
|
||||
usefulness of DCT scaling as a means of data reduction and SmartScale as a
|
||||
means of quality improvement. The reader is invited to peruse the research at
|
||||
<http://www.libjpeg-turbo.org/About/SmartScale> and draw his/her own conclusions,
|
||||
means of quality improvement. Readers are invited to peruse the research at
|
||||
<http://www.libjpeg-turbo.org/About/SmartScale> and draw their own conclusions,
|
||||
but it is the general belief of our project that these features have not
|
||||
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
|
||||
|
||||
@@ -287,12 +287,13 @@ following reasons:
|
||||
(and slightly faster) floating point IDCT algorithm introduced in libjpeg
|
||||
v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
|
||||
however, that this algorithm basically brings the accuracy of the floating
|
||||
point IDCT in line with the accuracy of the slow integer IDCT. The floating
|
||||
point DCT/IDCT algorithms are mainly a legacy feature, and they do not
|
||||
produce significantly more accuracy than the slow integer algorithms (to put
|
||||
numbers on this, the typical difference in PNSR between the two algorithms
|
||||
is less than 0.10 dB, whereas changing the quality level by 1 in the upper
|
||||
range of the quality scale is typically more like a 1.0 dB difference.)
|
||||
point IDCT in line with the accuracy of the accurate integer IDCT. The
|
||||
floating point DCT/IDCT algorithms are mainly a legacy feature, and they do
|
||||
not produce significantly more accuracy than the accurate integer algorithms
|
||||
(to put numbers on this, the typical difference in PNSR between the two
|
||||
algorithms is less than 0.10 dB, whereas changing the quality level by 1 in
|
||||
the upper range of the quality scale is typically more like a 1.0 dB
|
||||
difference.)
|
||||
|
||||
- If the floating point algorithms in libjpeg-turbo are not implemented using
|
||||
SIMD instructions on a particular platform, then the accuracy of the
|
||||
@@ -340,7 +341,7 @@ The algorithm used by the SIMD-accelerated quantization function cannot produce
|
||||
correct results whenever the fast integer forward DCT is used along with a JPEG
|
||||
quality of 98-100. Thus, libjpeg-turbo must use the non-SIMD quantization
|
||||
function in those cases. This causes performance to drop by as much as 40%.
|
||||
It is therefore strongly advised that you use the slow integer forward DCT
|
||||
It is therefore strongly advised that you use the accurate integer forward DCT
|
||||
whenever encoding images with a JPEG quality of 98 or higher.
|
||||
|
||||
|
||||
|
||||
+3
@@ -15,6 +15,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* How to obtain thread-local storage */
|
||||
#define THREAD_LOCAL @THREAD_LOCAL@
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "@CMAKE_PROJECT_NAME@"
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -34,10 +34,10 @@
|
||||
* memory footprint by 64k, which is important for some mobile applications
|
||||
* that create many isolated instances of libjpeg-turbo (web browsers, for
|
||||
* instance.) This may improve performance on some mobile platforms as well.
|
||||
* This feature is enabled by default only on ARM processors, because some x86
|
||||
* This feature is enabled by default only on Arm processors, because some x86
|
||||
* chips have a slow implementation of bsr, and the use of clz/bsr cannot be
|
||||
* shown to have a significant performance impact even on the x86 chips that
|
||||
* have a fast implementation of it. When building for ARMv6, you can
|
||||
* have a fast implementation of it. When building for Armv6, you can
|
||||
* explicitly disable the use of clz/bsr by adding -mthumb to the compiler
|
||||
* flags (this defines __thumb__).
|
||||
*/
|
||||
|
||||
Vendored
+4
-1
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jcinit.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -19,6 +21,7 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jpegcomp.h"
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+2
-2
@@ -43,10 +43,10 @@
|
||||
* memory footprint by 64k, which is important for some mobile applications
|
||||
* that create many isolated instances of libjpeg-turbo (web browsers, for
|
||||
* instance.) This may improve performance on some mobile platforms as well.
|
||||
* This feature is enabled by default only on ARM processors, because some x86
|
||||
* This feature is enabled by default only on Arm processors, because some x86
|
||||
* chips have a slow implementation of bsr, and the use of clz/bsr cannot be
|
||||
* shown to have a significant performance impact even on the x86 chips that
|
||||
* have a fast implementation of it. When building for ARMv6, you can
|
||||
* have a fast implementation of it. When building for Armv6, you can
|
||||
* explicitly disable the use of clz/bsr by adding -mthumb to the compiler
|
||||
* flags (this defines __thumb__).
|
||||
*/
|
||||
|
||||
Vendored
+3
-2
@@ -4,8 +4,8 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1998, Thomas G. Lane.
|
||||
* Modified 2000-2009 by Guido Vollbeding.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -17,6 +17,7 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jpegcomp.h"
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
+36
-9
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2015-2018, D. R. Commander.
|
||||
* Copyright (C) 2010, 2015-2018, 2020, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "jinclude.h"
|
||||
#include "jdmainct.h"
|
||||
#include "jdcoefct.h"
|
||||
#include "jdmaster.h"
|
||||
#include "jdmerge.h"
|
||||
#include "jdsample.h"
|
||||
#include "jmemsys.h"
|
||||
|
||||
@@ -316,6 +318,8 @@ LOCAL(void)
|
||||
read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
{
|
||||
JDIMENSION n;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
JSAMPARRAY scanlines = NULL;
|
||||
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows) = NULL;
|
||||
@@ -332,8 +336,13 @@ read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
cinfo->cquantize->color_quantize = noop_quantize;
|
||||
}
|
||||
|
||||
if (master->using_merged_upsample && cinfo->max_v_samp_factor == 2) {
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
scanlines = &upsample->spare_row;
|
||||
}
|
||||
|
||||
for (n = 0; n < num_lines; n++)
|
||||
jpeg_read_scanlines(cinfo, NULL, 1);
|
||||
jpeg_read_scanlines(cinfo, scanlines, 1);
|
||||
|
||||
if (color_convert)
|
||||
cinfo->cconvert->color_convert = color_convert;
|
||||
@@ -353,6 +362,12 @@ increment_simple_rowgroup_ctr(j_decompress_ptr cinfo, JDIMENSION rows)
|
||||
{
|
||||
JDIMENSION rows_left;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
if (master->using_merged_upsample && cinfo->max_v_samp_factor == 2) {
|
||||
read_and_discard_scanlines(cinfo, rows);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Increment the counter to the next row group after the skipped rows. */
|
||||
main_ptr->rowgroup_ctr += rows / cinfo->max_v_samp_factor;
|
||||
@@ -382,21 +397,27 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
JDIMENSION i, x;
|
||||
int y;
|
||||
JDIMENSION lines_per_iMCU_row, lines_left_in_iMCU_row, lines_after_iMCU_row;
|
||||
JDIMENSION lines_to_skip, lines_to_read;
|
||||
|
||||
/* Two-pass color quantization is not supported. */
|
||||
if (cinfo->quantize_colors && cinfo->two_pass_quantize)
|
||||
ERREXIT(cinfo, JERR_NOTIMPL);
|
||||
|
||||
if (cinfo->global_state != DSTATE_SCANNING)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
|
||||
/* Do not skip past the bottom of the image. */
|
||||
if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
|
||||
num_lines = cinfo->output_height - cinfo->output_scanline;
|
||||
cinfo->output_scanline = cinfo->output_height;
|
||||
(*cinfo->inputctl->finish_input_pass) (cinfo);
|
||||
cinfo->inputctl->eoi_reached = TRUE;
|
||||
return cinfo->output_height - cinfo->output_scanline;
|
||||
return num_lines;
|
||||
}
|
||||
|
||||
if (num_lines == 0)
|
||||
@@ -445,8 +466,10 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
main_ptr->buffer_full = FALSE;
|
||||
main_ptr->rowgroup_ctr = 0;
|
||||
main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
if (!master->using_merged_upsample) {
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
}
|
||||
}
|
||||
|
||||
/* Skipping is much simpler when context rows are not required. */
|
||||
@@ -458,8 +481,10 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
cinfo->output_scanline += lines_left_in_iMCU_row;
|
||||
main_ptr->buffer_full = FALSE;
|
||||
main_ptr->rowgroup_ctr = 0;
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
if (!master->using_merged_upsample) {
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +519,8 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
cinfo->output_iMCU_row += lines_to_skip / lines_per_iMCU_row;
|
||||
increment_simple_rowgroup_ctr(cinfo, lines_to_read);
|
||||
}
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
if (!master->using_merged_upsample)
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
return num_lines;
|
||||
}
|
||||
|
||||
@@ -535,7 +561,8 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
* bit odd, since "rows_to_go" seems to be redundantly keeping track of
|
||||
* output_scanline.
|
||||
*/
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
if (!master->using_merged_upsample)
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
|
||||
/* Always skip the requested number of lines. */
|
||||
return num_lines;
|
||||
|
||||
+1
-2
@@ -143,8 +143,7 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
|
||||
|
||||
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
|
||||
|
||||
if (dest->newbuffer != NULL)
|
||||
free(dest->newbuffer);
|
||||
free(dest->newbuffer);
|
||||
|
||||
dest->newbuffer = nextbuffer;
|
||||
|
||||
|
||||
+5
-3
@@ -6,7 +6,7 @@
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2010, 2015-2016, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* Copyright (C) 2015, 2020, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -495,11 +495,13 @@ decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
if (first_row && block_row == 0)
|
||||
prev_block_row = buffer_ptr;
|
||||
else
|
||||
prev_block_row = buffer[block_row - 1];
|
||||
prev_block_row = buffer[block_row - 1] +
|
||||
cinfo->master->first_MCU_col[ci];
|
||||
if (last_row && block_row == block_rows - 1)
|
||||
next_block_row = buffer_ptr;
|
||||
else
|
||||
next_block_row = buffer[block_row + 1];
|
||||
next_block_row = buffer[block_row + 1] +
|
||||
cinfo->master->first_MCU_col[ci];
|
||||
/* We fetch the surrounding DC values using a sliding-register approach.
|
||||
* Initialize all nine here so as to do the right thing on narrow pics.
|
||||
*/
|
||||
|
||||
Vendored
+4
-5
@@ -571,11 +571,10 @@ ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
* RGB565 conversion
|
||||
*/
|
||||
|
||||
#define PACK_SHORT_565_LE(r, g, b) ((((r) << 8) & 0xF800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) (((r) & 0xF8) | ((g) >> 5) | \
|
||||
(((g) << 11) & 0xE000) | \
|
||||
(((b) << 5) & 0x1F00))
|
||||
#define PACK_SHORT_565_LE(r, g, b) \
|
||||
((((r) << 8) & 0xF800) | (((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) \
|
||||
(((r) & 0xF8) | ((g) >> 5) | (((g) << 11) & 0xE000) | (((b) << 5) & 0x1F00))
|
||||
|
||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||
|
||||
Vendored
+13
-42
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2020, D. R. Commander.
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -40,41 +40,13 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jdmerge.h"
|
||||
#include "jsimd.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_upsampler pub; /* public fields */
|
||||
|
||||
/* Pointer to routine to do actual upsampling/conversion of one row group */
|
||||
void (*upmethod) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
|
||||
/* Private state for YCC->RGB conversion */
|
||||
int *Cr_r_tab; /* => table for Cr to R conversion */
|
||||
int *Cb_b_tab; /* => table for Cb to B conversion */
|
||||
JLONG *Cr_g_tab; /* => table for Cr to G conversion */
|
||||
JLONG *Cb_g_tab; /* => table for Cb to G conversion */
|
||||
|
||||
/* For 2:1 vertical sampling, we produce two output rows at a time.
|
||||
* We need a "spare" row buffer to hold the second output row if the
|
||||
* application provides just a one-row buffer; we also use the spare
|
||||
* to discard the dummy last row if the image height is odd.
|
||||
*/
|
||||
JSAMPROW spare_row;
|
||||
boolean spare_full; /* T if spare buffer is occupied */
|
||||
|
||||
JDIMENSION out_row_width; /* samples per output row */
|
||||
JDIMENSION rows_to_go; /* counts rows remaining in image */
|
||||
} my_upsampler;
|
||||
|
||||
typedef my_upsampler *my_upsample_ptr;
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
@@ -189,7 +161,7 @@ typedef my_upsampler *my_upsample_ptr;
|
||||
LOCAL(void)
|
||||
build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
int i;
|
||||
JLONG x;
|
||||
SHIFT_TEMPS
|
||||
@@ -232,7 +204,7 @@ build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
METHODDEF(void)
|
||||
start_pass_merged_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Mark the spare buffer empty */
|
||||
upsample->spare_full = FALSE;
|
||||
@@ -254,7 +226,7 @@ merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 2:1 vertical sampling case: may need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
JSAMPROW work_ptrs[2];
|
||||
JDIMENSION num_rows; /* number of rows returned to caller */
|
||||
|
||||
@@ -305,7 +277,7 @@ merged_1v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 1:1 vertical sampling case: much easier, never need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Just do the upsampling. */
|
||||
(*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr,
|
||||
@@ -420,11 +392,10 @@ h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
* RGB565 conversion
|
||||
*/
|
||||
|
||||
#define PACK_SHORT_565_LE(r, g, b) ((((r) << 8) & 0xF800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) (((r) & 0xF8) | ((g) >> 5) | \
|
||||
(((g) << 11) & 0xE000) | \
|
||||
(((b) << 5) & 0x1F00))
|
||||
#define PACK_SHORT_565_LE(r, g, b) \
|
||||
((((r) << 8) & 0xF800) | (((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) \
|
||||
(((r) & 0xF8) | ((g) >> 5) | (((g) << 11) & 0xE000) | (((b) << 5) & 0x1F00))
|
||||
|
||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||
@@ -566,11 +537,11 @@ h2v2_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
GLOBAL(void)
|
||||
jinit_merged_upsampler(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
my_merged_upsample_ptr upsample;
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
upsample = (my_merged_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_upsampler));
|
||||
sizeof(my_merged_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *)upsample;
|
||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||
upsample->pub.need_context_rows = FALSE;
|
||||
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* jdmerge.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
#include "jpeglib.h"
|
||||
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_upsampler pub; /* public fields */
|
||||
|
||||
/* Pointer to routine to do actual upsampling/conversion of one row group */
|
||||
void (*upmethod) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
|
||||
/* Private state for YCC->RGB conversion */
|
||||
int *Cr_r_tab; /* => table for Cr to R conversion */
|
||||
int *Cb_b_tab; /* => table for Cb to B conversion */
|
||||
JLONG *Cr_g_tab; /* => table for Cr to G conversion */
|
||||
JLONG *Cb_g_tab; /* => table for Cb to G conversion */
|
||||
|
||||
/* For 2:1 vertical sampling, we produce two output rows at a time.
|
||||
* We need a "spare" row buffer to hold the second output row if the
|
||||
* application provides just a one-row buffer; we also use the spare
|
||||
* to discard the dummy last row if the image height is odd.
|
||||
*/
|
||||
JSAMPROW spare_row;
|
||||
boolean spare_full; /* T if spare buffer is occupied */
|
||||
|
||||
JDIMENSION out_row_width; /* samples per output row */
|
||||
JDIMENSION rows_to_go; /* counts rows remaining in image */
|
||||
} my_merged_upsampler;
|
||||
|
||||
typedef my_merged_upsampler *my_merged_upsample_ptr;
|
||||
|
||||
#endif /* UPSAMPLE_MERGING_SUPPORTED */
|
||||
+5
-5
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* Copyright (C) 2014-2015, 2018, D. R. Commander.
|
||||
* Copyright (C) 2014-2015, 2018, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -19,7 +19,7 @@ h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
@@ -90,7 +90,7 @@ h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
@@ -163,7 +163,7 @@ h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
@@ -259,7 +259,7 @@ h2v2_merged_upsample_565D_internal(j_decompress_ptr cinfo,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2011, 2015, D. R. Commander.
|
||||
* Copyright (C) 2011, 2015, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -25,7 +25,7 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
@@ -97,7 +97,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
|
||||
Vendored
+3
-2
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -16,6 +16,7 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jpegcomp.h"
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
+2
-2
@@ -4,11 +4,11 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
* This file contains a slow-but-accurate integer implementation of the
|
||||
* This file contains a slower but more accurate integer implementation of the
|
||||
* forward DCT (Discrete Cosine Transform).
|
||||
*
|
||||
* A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modification developed 2002-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
* This file contains a slow-but-accurate integer implementation of the
|
||||
* This file contains a slower but more accurate integer implementation of the
|
||||
* inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
|
||||
* must also perform dequantization of the input coefficients.
|
||||
*
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2018, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -273,9 +273,9 @@ typedef int boolean;
|
||||
|
||||
/* Capability options common to encoder and decoder: */
|
||||
|
||||
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
|
||||
#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
|
||||
#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
|
||||
#define DCT_ISLOW_SUPPORTED /* accurate integer method */
|
||||
#define DCT_IFAST_SUPPORTED /* less accurate int method [legacy feature] */
|
||||
#define DCT_FLOAT_SUPPORTED /* floating-point method [legacy feature] */
|
||||
|
||||
/* Encoder capability options: */
|
||||
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jpegcomp.h
|
||||
*
|
||||
* Copyright (C) 2010, D. R. Commander.
|
||||
* Copyright (C) 2010, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -19,6 +19,7 @@
|
||||
#define _min_DCT_v_scaled_size min_DCT_v_scaled_size
|
||||
#define _jpeg_width jpeg_width
|
||||
#define _jpeg_height jpeg_height
|
||||
#define JERR_ARITH_NOTIMPL JERR_NOT_COMPILED
|
||||
#else
|
||||
#define _DCT_scaled_size DCT_scaled_size
|
||||
#define _DCT_h_scaled_size DCT_scaled_size
|
||||
|
||||
Vendored
+4
-4
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2002-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, 2013-2014, 2016-2017, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -244,9 +244,9 @@ typedef enum {
|
||||
/* DCT/IDCT algorithm options. */
|
||||
|
||||
typedef enum {
|
||||
JDCT_ISLOW, /* slow but accurate integer algorithm */
|
||||
JDCT_IFAST, /* faster, less accurate integer method */
|
||||
JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
|
||||
JDCT_ISLOW, /* accurate integer method */
|
||||
JDCT_IFAST, /* less accurate integer method [legacy feature] */
|
||||
JDCT_FLOAT /* floating-point method [legacy feature] */
|
||||
} J_DCT_METHOD;
|
||||
|
||||
#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
|
||||
|
||||
Vendored
+3
-3
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2009, 2014-2015, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -1145,7 +1145,7 @@ start_pass_2_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
int i;
|
||||
|
||||
/* Only F-S dithering or no dithering is supported. */
|
||||
/* If user asks for ordered dither, give him F-S. */
|
||||
/* If user asks for ordered dither, give them F-S. */
|
||||
if (cinfo->dither_mode != JDITHER_NONE)
|
||||
cinfo->dither_mode = JDITHER_FS;
|
||||
|
||||
@@ -1263,7 +1263,7 @@ jinit_2pass_quantizer(j_decompress_ptr cinfo)
|
||||
cquantize->sv_colormap = NULL;
|
||||
|
||||
/* Only F-S dithering or no dithering is supported. */
|
||||
/* If user asks for ordered dither, give him F-S. */
|
||||
/* If user asks for ordered dither, give them F-S. */
|
||||
if (cinfo->dither_mode != JDITHER_NONE)
|
||||
cinfo->dither_mode = JDITHER_FS;
|
||||
|
||||
|
||||
+11
-9
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2012-2019, D. R. Commander.
|
||||
* Copyright (C) 2010, 2012-2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -30,23 +30,25 @@
|
||||
* NOTE: It is our convention to place the authors in the following order:
|
||||
* - libjpeg-turbo authors (2009-) in descending order of the date of their
|
||||
* most recent contribution to the project, then in ascending order of the
|
||||
* date of their first contribution to the project
|
||||
* date of their first contribution to the project, then in alphabetical
|
||||
* order
|
||||
* - Upstream authors in descending order of the date of the first inclusion of
|
||||
* their code
|
||||
*/
|
||||
|
||||
#define JCOPYRIGHT \
|
||||
"Copyright (C) 2009-2019 D. R. Commander\n" \
|
||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||
"Copyright (C) 2009-2020 D. R. Commander\n" \
|
||||
"Copyright (C) 2015, 2020 Google, Inc.\n" \
|
||||
"Copyright (C) 2019 Arm Limited\n" \
|
||||
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
|
||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||
"Copyright (C) 2015 Intel Corporation\n" \
|
||||
"Copyright (C) 2015 Google, Inc.\n" \
|
||||
"Copyright (C) 2013-2014 Linaro Limited\n" \
|
||||
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
||||
"Copyright (C) 2013 Linaro Limited\n" \
|
||||
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
|
||||
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
||||
"Copyright (C) 2009 Pierre Ossman for Cendio AB\n" \
|
||||
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
||||
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding"
|
||||
"Copyright (C) 1991-2017 Thomas G. Lane, Guido Vollbeding"
|
||||
|
||||
#define JCOPYRIGHT_SHORT \
|
||||
"Copyright (C) 1991-2019 The libjpeg-turbo Project and many others"
|
||||
"Copyright (C) 1991-2020 The libjpeg-turbo Project and many others"
|
||||
|
||||
Vendored
+2
-2
@@ -19,7 +19,7 @@ endif()
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
add_library(${JPEG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
add_library(${JPEG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1")
|
||||
@@ -42,7 +42,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(libjpeg README)
|
||||
|
||||
Vendored
+6
-13
@@ -1,7 +1,7 @@
|
||||
The Independent JPEG Group's JPEG software
|
||||
==========================================
|
||||
|
||||
README for release 9c of 14-Jan-2018
|
||||
README for release 9d of 12-Jan-2020
|
||||
====================================
|
||||
|
||||
This distribution contains the ninth public release of the Independent JPEG
|
||||
@@ -10,8 +10,8 @@ to use it for any purpose, subject to the conditions under LEGAL ISSUES, below.
|
||||
|
||||
This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone,
|
||||
Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson,
|
||||
Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, Ge' Weijers,
|
||||
and other members of the Independent JPEG Group.
|
||||
John Korejwa, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi,
|
||||
Ge' Weijers, and other members of the Independent JPEG Group.
|
||||
|
||||
IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
|
||||
(previously known as JPEG, together with ITU-T SG16).
|
||||
@@ -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,
|
||||
its user, assume the entire risk as to its quality and accuracy.
|
||||
|
||||
This software is copyright (C) 1991-2018, Thomas G. Lane, Guido Vollbeding.
|
||||
This software is copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
|
||||
All Rights Reserved except as specified below.
|
||||
|
||||
Permission is hereby granted to use, copy, modify, and distribute this
|
||||
@@ -152,13 +152,6 @@ The same holds for its supporting scripts (config.guess, config.sub,
|
||||
ltmain.sh). Another support script, install-sh, is copyright by X Consortium
|
||||
but is also freely distributable.
|
||||
|
||||
The IJG distribution formerly included code to read and write GIF files.
|
||||
To avoid entanglement with the Unisys LZW patent (now expired), GIF reading
|
||||
support has been removed altogether, and the GIF writer has been simplified
|
||||
to produce "uncompressed GIFs". This technique does not use the LZW
|
||||
algorithm; the resulting GIF files are larger than usual, but are readable
|
||||
by all standard GIF decoders.
|
||||
|
||||
|
||||
REFERENCES
|
||||
==========
|
||||
@@ -246,8 +239,8 @@ ARCHIVE LOCATIONS
|
||||
The "official" archive site for this software is www.ijg.org.
|
||||
The most recent released version can always be found there in
|
||||
directory "files". This particular version will be archived as
|
||||
http://www.ijg.org/files/jpegsrc.v9c.tar.gz, and in Windows-compatible
|
||||
"zip" archive format as http://www.ijg.org/files/jpegsr9c.zip.
|
||||
http://www.ijg.org/files/jpegsrc.v9d.tar.gz, and in Windows-compatible
|
||||
"zip" archive format as http://www.ijg.org/files/jpegsr9d.zip.
|
||||
|
||||
The JPEG FAQ (Frequently Asked Questions) article is a source of some
|
||||
general information about JPEG.
|
||||
|
||||
Vendored
+49
@@ -1,6 +1,55 @@
|
||||
CHANGE LOG for Independent JPEG Group's JPEG software
|
||||
|
||||
|
||||
Version 9d 12-Jan-2020
|
||||
-----------------------
|
||||
|
||||
Optimize the optimal Huffman code table generation to produce
|
||||
slightly smaller files. Thank to John Korejwa for suggestion.
|
||||
Note: Requires rebuild of testimgp.jpg.
|
||||
|
||||
Decoding Huffman: Use default tables if tables are not defined.
|
||||
Thank to Simone Azzalin for report (Motion JPEG),
|
||||
and to Martin Strunz for hint.
|
||||
|
||||
Add sanity check in optimal Huffman code table generation.
|
||||
Thank to Adam Farley for suggestion.
|
||||
|
||||
rdtarga.c: use read_byte(), with EOF check, instead of getc()
|
||||
in read_*_pixel().
|
||||
Thank to Chijin Zhou for cjpeg potential vulnerability report.
|
||||
|
||||
jmemnobs.c: respect the max_memory_to_use setting in
|
||||
jpeg_mem_available() computation. Thank to Sheng Shu and
|
||||
Dongdong She for djpeg potential vulnerability report.
|
||||
|
||||
jdarith.c, jdhuff.c: avoid left shift of negative value
|
||||
compiler warning in decode_mcu_AC_refine().
|
||||
Thank to Indu Bhagat for suggestion.
|
||||
|
||||
Add x64 (64-bit) platform support, avoid compiler warnings.
|
||||
Thank to Jonathan Potter, Feiyun Wang, and Sheng Shu for suggestion.
|
||||
|
||||
Adjust libjpeg version specification for pkg-config file.
|
||||
Thank to Chen Chen for suggestion.
|
||||
|
||||
Restore GIF read and write support from libjpeg version 6a.
|
||||
Thank to Wolfgang Werner (W.W.) Heinz for suggestion.
|
||||
|
||||
Improve consistency in raw (downsampled) image data processing mode.
|
||||
Thank to Zhongyuan Zhou for hint.
|
||||
|
||||
Avoid out of bounds array read (AC derived table pointers)
|
||||
in start pass in jdhuff.c. Thank to Peng Li for report.
|
||||
|
||||
Improve code sanity (jdhuff.c).
|
||||
Thank to Reza Mirzazade farkhani for reports.
|
||||
|
||||
Add jpegtran -drop option; add options to the crop extension and wipe
|
||||
to fill the extra area with content from the source image region,
|
||||
instead of gray out.
|
||||
|
||||
|
||||
Version 9c 14-Jan-2018
|
||||
-----------------------
|
||||
|
||||
|
||||
Vendored
+9
-8
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jcarith.c
|
||||
*
|
||||
* Developed 1997-2013 by Guido Vollbeding.
|
||||
* Developed 1997-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -181,11 +181,11 @@ finish_pass (j_compress_ptr cinfo)
|
||||
if (e->zc) /* output final pending zero bytes */
|
||||
do emit_byte(0x00, cinfo);
|
||||
while (--e->zc);
|
||||
emit_byte((e->c >> 19) & 0xFF, cinfo);
|
||||
emit_byte((int) ((e->c >> 19) & 0xFF), cinfo);
|
||||
if (((e->c >> 19) & 0xFF) == 0xFF)
|
||||
emit_byte(0x00, cinfo);
|
||||
if (e->c & 0x7F800L) {
|
||||
emit_byte((e->c >> 11) & 0xFF, cinfo);
|
||||
emit_byte((int) ((e->c >> 11) & 0xFF), cinfo);
|
||||
if (((e->c >> 11) & 0xFF) == 0xFF)
|
||||
emit_byte(0x00, cinfo);
|
||||
}
|
||||
@@ -280,7 +280,8 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
/* Note: The 3 spacer bits in the C register guarantee
|
||||
* that the new buffer byte can't be 0xFF here
|
||||
* (see page 160 in the P&M JPEG book). */
|
||||
e->buffer = temp & 0xFF; /* new output byte, might overflow later */
|
||||
/* New output byte, might overflow later */
|
||||
e->buffer = (int) (temp & 0xFF);
|
||||
} else if (temp == 0xFF) {
|
||||
++e->sc; /* stack 0xFF byte (which might overflow later) */
|
||||
} else {
|
||||
@@ -302,7 +303,8 @@ arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
|
||||
emit_byte(0x00, cinfo);
|
||||
} while (--e->sc);
|
||||
}
|
||||
e->buffer = temp & 0xFF; /* new output byte (can still overflow) */
|
||||
/* New output byte (can still overflow) */
|
||||
e->buffer = (int) (temp & 0xFF);
|
||||
}
|
||||
e->c &= 0x7FFFFL;
|
||||
e->ct += 8;
|
||||
@@ -926,9 +928,8 @@ jinit_arith_encoder (j_compress_ptr cinfo)
|
||||
arith_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(arith_entropy_encoder));
|
||||
entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_encoder));
|
||||
cinfo->entropy = &entropy->pub;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
entropy->pub.finish_pass = finish_pass;
|
||||
|
||||
Vendored
+47
-50
@@ -2,7 +2,7 @@
|
||||
* jccolor.c
|
||||
*
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* Modified 2011-2013 by Guido Vollbeding.
|
||||
* Modified 2011-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -105,14 +105,14 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * SIZEOF(INT32)));
|
||||
TABLE_SIZE * SIZEOF(INT32));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
||||
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.587) * i;
|
||||
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
|
||||
rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.168735892)) * i;
|
||||
rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.331264108)) * i;
|
||||
rgb_ycc_tab[i+R_CB_OFF] = (- FIX(0.168735892)) * 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.
|
||||
* This ensures that the maximum output will round to MAXJSAMPLE
|
||||
* not MAXJSAMPLE+1, and thus that we don't have to range-limit.
|
||||
@@ -121,8 +121,8 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
||||
/* B=>Cb and R=>Cr tables are the same
|
||||
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.418687589)) * i;
|
||||
rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.081312411)) * i;
|
||||
rgb_ycc_tab[i+G_CR_OFF] = (- FIX(0.418687589)) * i;
|
||||
rgb_ycc_tab[i+B_CR_OFF] = (- FIX(0.081312411)) * i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,12 +131,12 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
||||
* Convert some rows of samples to the JPEG colorspace.
|
||||
*
|
||||
* Note that we change from the application's interleaved-pixel format
|
||||
* to our internal noninterleaved, one-plane-per-component format.
|
||||
* The input buffer is therefore three times as wide as the output buffer.
|
||||
* to our internal noninterleaved, one-plane-per-component format. The
|
||||
* input buffer is therefore three times as wide as the output buffer.
|
||||
*
|
||||
* A starting row offset is provided only for the output buffer. The caller
|
||||
* can easily adjust the passed input_buf value to accommodate any row
|
||||
* offset required on that side.
|
||||
* A starting row offset is provided only for the output buffer. The
|
||||
* caller can easily adjust the passed input_buf value to accommodate
|
||||
* any row offset required on that side.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
@@ -145,8 +145,8 @@ rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
||||
register int r, g, b;
|
||||
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2;
|
||||
register JDIMENSION col;
|
||||
@@ -162,6 +162,7 @@ rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
r = GETJSAMPLE(inptr[RGB_RED]);
|
||||
g = GETJSAMPLE(inptr[RGB_GREEN]);
|
||||
b = GETJSAMPLE(inptr[RGB_BLUE]);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
/* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
|
||||
* must be too; we do not need an explicit range-limiting operation.
|
||||
* Hence the value being shifted is never negative, and we don't
|
||||
@@ -179,7 +180,6 @@ rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
outptr2[col] = (JSAMPLE)
|
||||
((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
|
||||
>> SCALEBITS);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,8 +201,8 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
||||
register int r, g, b;
|
||||
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
@@ -215,11 +215,11 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
||||
r = GETJSAMPLE(inptr[RGB_RED]);
|
||||
g = GETJSAMPLE(inptr[RGB_GREEN]);
|
||||
b = GETJSAMPLE(inptr[RGB_BLUE]);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
/* Y */
|
||||
outptr[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,8 +228,8 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
||||
/*
|
||||
* Convert some rows of samples to the JPEG colorspace.
|
||||
* This version handles Adobe-style CMYK->YCCK conversion,
|
||||
* where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same
|
||||
* conversion as above, while passing K (black) unchanged.
|
||||
* where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the
|
||||
* same conversion as above, while passing K (black) unchanged.
|
||||
* We assume rgb_ycc_start has been called.
|
||||
*/
|
||||
|
||||
@@ -239,8 +239,8 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
||||
register int r, g, b;
|
||||
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr0, outptr1, outptr2, outptr3;
|
||||
register JDIMENSION col;
|
||||
@@ -259,6 +259,7 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
b = MAXJSAMPLE - GETJSAMPLE(inptr[2]);
|
||||
/* K passes through as-is */
|
||||
outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */
|
||||
inptr += 4;
|
||||
/* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
|
||||
* must be too; we do not need an explicit range-limiting operation.
|
||||
* Hence the value being shifted is never negative, and we don't
|
||||
@@ -276,7 +277,6 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
|
||||
outptr2[col] = (JSAMPLE)
|
||||
((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF])
|
||||
>> SCALEBITS);
|
||||
inptr += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,13 +312,13 @@ rgb_rgb1_convert (j_compress_ptr cinfo,
|
||||
r = GETJSAMPLE(inptr[RGB_RED]);
|
||||
g = GETJSAMPLE(inptr[RGB_GREEN]);
|
||||
b = GETJSAMPLE(inptr[RGB_BLUE]);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
|
||||
* (modulo) operator is equivalent to the bitmask operator AND.
|
||||
*/
|
||||
outptr0[col] = (JSAMPLE) ((r - g + CENTERJSAMPLE) & MAXJSAMPLE);
|
||||
outptr1[col] = (JSAMPLE) g;
|
||||
outptr2[col] = (JSAMPLE) ((b - g + CENTERJSAMPLE) & MAXJSAMPLE);
|
||||
inptr += RGB_PIXELSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,17 +335,17 @@ grayscale_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
int instride = cinfo->input_components;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
register JDIMENSION count;
|
||||
register int instride = cinfo->input_components;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
inptr = *input_buf++;
|
||||
outptr = output_buf[0][output_row++];
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */
|
||||
for (count = num_cols; count > 0; count--) {
|
||||
*outptr++ = *inptr; /* don't need GETJSAMPLE() here */
|
||||
inptr += instride;
|
||||
}
|
||||
}
|
||||
@@ -396,21 +396,21 @@ null_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
int ci;
|
||||
register int nc = cinfo->num_components;
|
||||
register JSAMPROW inptr;
|
||||
register JSAMPROW outptr;
|
||||
register JDIMENSION col;
|
||||
register JDIMENSION count;
|
||||
register int num_comps = cinfo->num_components;
|
||||
JDIMENSION num_cols = cinfo->image_width;
|
||||
int ci;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
/* It seems fastest to make a separate pass for each component. */
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
for (ci = 0; ci < num_comps; ci++) {
|
||||
inptr = input_buf[0] + ci;
|
||||
outptr = output_buf[ci][output_row];
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
for (count = num_cols; count > 0; count--) {
|
||||
*outptr++ = *inptr; /* don't need GETJSAMPLE() here */
|
||||
inptr += nc;
|
||||
inptr += num_comps;
|
||||
}
|
||||
}
|
||||
input_buf++;
|
||||
@@ -439,9 +439,8 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
{
|
||||
my_cconvert_ptr cconvert;
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_color_converter));
|
||||
cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_converter));
|
||||
cinfo->cconvert = &cconvert->pub;
|
||||
/* set start_pass to null method until we find out differently */
|
||||
cconvert->pub.start_pass = null_method;
|
||||
@@ -455,9 +454,11 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
|
||||
case JCS_RGB:
|
||||
case JCS_BG_RGB:
|
||||
#if RGB_PIXELSIZE != 3
|
||||
if (cinfo->input_components != RGB_PIXELSIZE)
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
break;
|
||||
#endif /* else share code with YCbCr */
|
||||
|
||||
case JCS_YCbCr:
|
||||
case JCS_BG_YCC:
|
||||
@@ -474,7 +475,6 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
default: /* JCS_UNKNOWN can be anything */
|
||||
if (cinfo->input_components < 1)
|
||||
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Support color transform only for RGB colorspaces */
|
||||
@@ -507,19 +507,18 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
case JCS_BG_RGB:
|
||||
if (cinfo->num_components != 3)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
if (cinfo->in_color_space == cinfo->jpeg_color_space) {
|
||||
switch (cinfo->color_transform) {
|
||||
case JCT_NONE:
|
||||
cconvert->pub.color_convert = rgb_convert;
|
||||
break;
|
||||
case JCT_SUBTRACT_GREEN:
|
||||
cconvert->pub.color_convert = rgb_rgb1_convert;
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
} else
|
||||
if (cinfo->in_color_space != cinfo->jpeg_color_space)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
switch (cinfo->color_transform) {
|
||||
case JCT_NONE:
|
||||
cconvert->pub.color_convert = rgb_convert;
|
||||
break;
|
||||
case JCT_SUBTRACT_GREEN:
|
||||
cconvert->pub.color_convert = rgb_rgb1_convert;
|
||||
break;
|
||||
default:
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_YCbCr:
|
||||
@@ -572,10 +571,9 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
case JCS_CMYK:
|
||||
if (cinfo->num_components != 4)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
if (cinfo->in_color_space == JCS_CMYK)
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
else
|
||||
if (cinfo->in_color_space != JCS_CMYK)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
break;
|
||||
|
||||
case JCS_YCCK:
|
||||
@@ -599,6 +597,5 @@ jinit_color_converter (j_compress_ptr cinfo)
|
||||
cinfo->num_components != cinfo->input_components)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+109
-42
@@ -2,7 +2,7 @@
|
||||
* jchuff.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2006-2013 by Guido Vollbeding.
|
||||
* Modified 2006-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -178,13 +178,12 @@ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
|
||||
htbl =
|
||||
isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
|
||||
if (htbl == NULL)
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
|
||||
htbl = jpeg_std_huff_table((j_common_ptr) cinfo, isDC, tblno);
|
||||
|
||||
/* Allocate a workspace if we haven't already done so. */
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (c_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(c_derived_tbl));
|
||||
*pdtbl = (c_derived_tbl *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(c_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
|
||||
/* Figure C.1: make table of Huffman code length for each symbol */
|
||||
@@ -1256,22 +1255,88 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */
|
||||
int codesize[257]; /* codesize[k] = code length of symbol k */
|
||||
int others[257]; /* next symbol in current branch of tree */
|
||||
int c1, c2;
|
||||
int p, i, j;
|
||||
int c1, c2, i, j;
|
||||
UINT8 *p;
|
||||
long v;
|
||||
|
||||
freq[256] = 1; /* make sure 256 has a nonzero count */
|
||||
/* Including the pseudo-symbol 256 in the Huffman procedure guarantees
|
||||
* that no real symbol is given code-value of all ones, because 256
|
||||
* will be placed last in the largest codeword category.
|
||||
* In the symbol list build procedure this element serves as sentinel
|
||||
* for the zero run loop.
|
||||
*/
|
||||
|
||||
#ifndef DONT_USE_FANCY_HUFF_OPT
|
||||
|
||||
/* Build list of symbols sorted in order of descending frequency */
|
||||
/* This approach has several benefits (thank to John Korejwa for the idea):
|
||||
* 1.
|
||||
* If a codelength category is split during the length limiting procedure
|
||||
* below, the feature that more frequent symbols are assigned shorter
|
||||
* codewords remains valid for the adjusted code.
|
||||
* 2.
|
||||
* To reduce consecutive ones in a Huffman data stream (thus reducing the
|
||||
* number of stuff bytes in JPEG) it is preferable to follow 0 branches
|
||||
* (and avoid 1 branches) as much as possible. This is easily done by
|
||||
* assigning symbols to leaves of the Huffman tree in order of decreasing
|
||||
* frequency, with no secondary sort based on codelengths.
|
||||
* 3.
|
||||
* The symbol list can be built independently from the assignment of code
|
||||
* lengths by the Huffman procedure below.
|
||||
* Note: The symbol list build procedure must be performed first, because
|
||||
* the Huffman procedure assigning the codelengths clobbers the frequency
|
||||
* counts!
|
||||
*/
|
||||
|
||||
/* Here we use the others array as a linked list of nonzero frequencies
|
||||
* to be sorted. Already sorted elements are removed from the list.
|
||||
*/
|
||||
|
||||
/* Building list */
|
||||
|
||||
/* This item does not correspond to a valid symbol frequency and is used
|
||||
* as starting index.
|
||||
*/
|
||||
j = 256;
|
||||
|
||||
for (i = 0;; i++) {
|
||||
if (freq[i] == 0) /* skip zero frequencies */
|
||||
continue;
|
||||
if (i > 255)
|
||||
break;
|
||||
others[j] = i; /* this symbol value */
|
||||
j = i; /* previous symbol value */
|
||||
}
|
||||
others[j] = -1; /* mark end of list */
|
||||
|
||||
/* Sorting list */
|
||||
|
||||
p = htbl->huffval;
|
||||
while ((c1 = others[256]) >= 0) {
|
||||
v = freq[c1];
|
||||
i = c1; /* first symbol value */
|
||||
j = 256; /* pseudo symbol value for starting index */
|
||||
while ((c2 = others[c1]) >= 0) {
|
||||
if (freq[c2] > v) {
|
||||
v = freq[c2];
|
||||
i = c2; /* this symbol value */
|
||||
j = c1; /* previous symbol value */
|
||||
}
|
||||
c1 = c2;
|
||||
}
|
||||
others[j] = others[i]; /* remove this symbol i from list */
|
||||
*p++ = (UINT8) i;
|
||||
}
|
||||
|
||||
#endif /* DONT_USE_FANCY_HUFF_OPT */
|
||||
|
||||
/* This algorithm is explained in section K.2 of the JPEG standard */
|
||||
|
||||
MEMZERO(bits, SIZEOF(bits));
|
||||
MEMZERO(codesize, SIZEOF(codesize));
|
||||
for (i = 0; i < 257; i++)
|
||||
others[i] = -1; /* init links to empty */
|
||||
|
||||
freq[256] = 1; /* make sure 256 has a nonzero count */
|
||||
/* Including the pseudo-symbol 256 in the Huffman procedure guarantees
|
||||
* that no real symbol is given code-value of all ones, because 256
|
||||
* will be placed last in the largest codeword category.
|
||||
*/
|
||||
|
||||
/* Huffman's basic algorithm to assign optimal code lengths to symbols */
|
||||
|
||||
@@ -1301,7 +1366,7 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
/* Done if we've merged everything into one frequency */
|
||||
if (c2 < 0)
|
||||
break;
|
||||
|
||||
|
||||
/* Else merge the two counts/trees */
|
||||
freq[c1] += freq[c2];
|
||||
freq[c2] = 0;
|
||||
@@ -1312,9 +1377,9 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
c1 = others[c1];
|
||||
codesize[c1]++;
|
||||
}
|
||||
|
||||
|
||||
others[c1] = c2; /* chain c2 onto c1's tree branch */
|
||||
|
||||
|
||||
/* Increment the codesize of everything in c2's tree branch */
|
||||
codesize[c2]++;
|
||||
while (others[c2] >= 0) {
|
||||
@@ -1329,7 +1394,7 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
/* The JPEG standard seems to think that this can't happen, */
|
||||
/* but I'm paranoid... */
|
||||
if (codesize[i] > MAX_CLEN)
|
||||
ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);
|
||||
ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS);
|
||||
|
||||
bits[codesize[i]]++;
|
||||
}
|
||||
@@ -1345,13 +1410,16 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
* shortest nonzero BITS entry is converted into a prefix for two code words
|
||||
* one bit longer.
|
||||
*/
|
||||
|
||||
|
||||
for (i = MAX_CLEN; i > 16; i--) {
|
||||
while (bits[i] > 0) {
|
||||
j = i - 2; /* find length of new prefix to be used */
|
||||
while (bits[j] == 0)
|
||||
while (bits[j] == 0) {
|
||||
if (j == 0)
|
||||
ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS);
|
||||
j--;
|
||||
|
||||
}
|
||||
|
||||
bits[i] -= 2; /* remove two symbols */
|
||||
bits[i-1]++; /* one goes in this length */
|
||||
bits[j+1] += 2; /* two new symbols in this length */
|
||||
@@ -1363,24 +1431,27 @@ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
|
||||
while (bits[i] == 0) /* find largest codelength still in use */
|
||||
i--;
|
||||
bits[i]--;
|
||||
|
||||
|
||||
/* Return final symbol counts (only for lengths 0..16) */
|
||||
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
|
||||
|
||||
|
||||
#ifdef DONT_USE_FANCY_HUFF_OPT
|
||||
|
||||
/* Return a list of the symbols sorted by code length */
|
||||
/* It's not real clear to me why we don't need to consider the codelength
|
||||
* changes made above, but the JPEG spec seems to think this works.
|
||||
/* Note: Due to the codelength changes made above, it can happen
|
||||
* that more frequent symbols are assigned longer codewords.
|
||||
*/
|
||||
p = 0;
|
||||
p = htbl->huffval;
|
||||
for (i = 1; i <= MAX_CLEN; i++) {
|
||||
for (j = 0; j <= 255; j++) {
|
||||
if (codesize[j] == i) {
|
||||
htbl->huffval[p] = (UINT8) j;
|
||||
p++;
|
||||
*p++ = (UINT8) j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DONT_USE_FANCY_HUFF_OPT */
|
||||
|
||||
/* Set sent_table FALSE so updated table will be written to JPEG file. */
|
||||
htbl->sent_table = FALSE;
|
||||
}
|
||||
@@ -1400,13 +1471,13 @@ finish_pass_gather (j_compress_ptr cinfo)
|
||||
boolean did_dc[NUM_HUFF_TBLS];
|
||||
boolean did_ac[NUM_HUFF_TBLS];
|
||||
|
||||
/* It's important not to apply jpeg_gen_optimal_table more than once
|
||||
* per table, because it clobbers the input frequency counts!
|
||||
*/
|
||||
if (cinfo->progressive_mode)
|
||||
/* Flush out buffered data (all we care about is counting the EOB symbol) */
|
||||
emit_eobrun(entropy);
|
||||
|
||||
/* It's important not to apply jpeg_gen_optimal_table more than once
|
||||
* per table, because it clobbers the input frequency counts!
|
||||
*/
|
||||
MEMZERO(did_dc, SIZEOF(did_dc));
|
||||
MEMZERO(did_ac, SIZEOF(did_ac));
|
||||
|
||||
@@ -1475,9 +1546,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
entropy->pub.encode_mcu = encode_mcu_AC_refine;
|
||||
/* AC refinement needs a correction bit buffer */
|
||||
if (entropy->bit_buffer == NULL)
|
||||
entropy->bit_buffer = (char *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
MAX_CORR_BITS * SIZEOF(char));
|
||||
entropy->bit_buffer = (char *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, MAX_CORR_BITS * SIZEOF(char));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1505,9 +1575,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
/* Allocate and zero the statistics tables */
|
||||
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
|
||||
if (entropy->dc_count_ptrs[tbl] == NULL)
|
||||
entropy->dc_count_ptrs[tbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
257 * SIZEOF(long));
|
||||
entropy->dc_count_ptrs[tbl] = (long *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, 257 * SIZEOF(long));
|
||||
MEMZERO(entropy->dc_count_ptrs[tbl], 257 * SIZEOF(long));
|
||||
} else {
|
||||
/* Compute derived values for Huffman tables */
|
||||
@@ -1525,9 +1594,8 @@ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||
if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
|
||||
if (entropy->ac_count_ptrs[tbl] == NULL)
|
||||
entropy->ac_count_ptrs[tbl] = (long *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
257 * SIZEOF(long));
|
||||
entropy->ac_count_ptrs[tbl] = (long *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, 257 * SIZEOF(long));
|
||||
MEMZERO(entropy->ac_count_ptrs[tbl], 257 * SIZEOF(long));
|
||||
} else {
|
||||
jpeg_make_c_derived_tbl(cinfo, FALSE, tbl,
|
||||
@@ -1556,9 +1624,8 @@ jinit_huff_encoder (j_compress_ptr cinfo)
|
||||
huff_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(huff_entropy_encoder));
|
||||
entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_encoder));
|
||||
cinfo->entropy = &entropy->pub;
|
||||
entropy->pub.start_pass = start_pass_huff;
|
||||
|
||||
|
||||
Vendored
+3
-5
@@ -2,7 +2,7 @@
|
||||
* jcmarker.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2003-2013 by Guido Vollbeding.
|
||||
* Modified 2003-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -471,7 +471,6 @@ emit_adobe_app14 (j_compress_ptr cinfo)
|
||||
break;
|
||||
default:
|
||||
emit_byte(cinfo, 0); /* Color transform = 0 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -702,9 +701,8 @@ jinit_marker_writer (j_compress_ptr cinfo)
|
||||
my_marker_ptr marker;
|
||||
|
||||
/* Create the subobject */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_marker_writer));
|
||||
marker = (my_marker_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_marker_writer));
|
||||
cinfo->marker = &marker->pub;
|
||||
/* Initialize method pointers */
|
||||
marker->pub.write_file_header = write_file_header;
|
||||
|
||||
Vendored
+18
-15
@@ -2,7 +2,7 @@
|
||||
* jcmaster.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2003-2017 by Guido Vollbeding.
|
||||
* Modified 2003-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -62,7 +62,7 @@ initial_setup (j_compress_ptr cinfo)
|
||||
case 5: cinfo->natural_order = jpeg_natural_order5; break;
|
||||
case 6: cinfo->natural_order = jpeg_natural_order6; break;
|
||||
case 7: cinfo->natural_order = jpeg_natural_order7; break;
|
||||
default: cinfo->natural_order = jpeg_natural_order; break;
|
||||
default: cinfo->natural_order = jpeg_natural_order;
|
||||
}
|
||||
|
||||
/* Derive lim_Se from block_size */
|
||||
@@ -114,20 +114,24 @@ initial_setup (j_compress_ptr cinfo)
|
||||
*/
|
||||
ssize = 1;
|
||||
#ifdef DCT_SCALING_SUPPORTED
|
||||
while (cinfo->min_DCT_h_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
if (! cinfo->raw_data_in)
|
||||
while (cinfo->min_DCT_h_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) ==
|
||||
0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
#endif
|
||||
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
|
||||
ssize = 1;
|
||||
#ifdef DCT_SCALING_SUPPORTED
|
||||
while (cinfo->min_DCT_v_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
if (! cinfo->raw_data_in)
|
||||
while (cinfo->min_DCT_v_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) ==
|
||||
0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
#endif
|
||||
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
|
||||
|
||||
@@ -620,9 +624,8 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||
{
|
||||
my_master_ptr master;
|
||||
|
||||
master = (my_master_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_comp_master));
|
||||
master = (my_master_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_comp_master));
|
||||
cinfo->master = &master->pub;
|
||||
master->pub.prepare_for_pass = prepare_for_pass;
|
||||
master->pub.pass_startup = pass_startup;
|
||||
|
||||
Vendored
+138
@@ -2,6 +2,7 @@
|
||||
* jcomapi.c
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -104,3 +105,140 @@ jpeg_alloc_huff_table (j_common_ptr cinfo)
|
||||
tbl->sent_table = FALSE; /* make sure this is false in any new table */
|
||||
return tbl;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set up the standard Huffman tables (cf. JPEG standard section K.3).
|
||||
* IMPORTANT: these are only valid for 8-bit data precision!
|
||||
* (Would jutils.c be a more reasonable place to put this?)
|
||||
*/
|
||||
|
||||
GLOBAL(JHUFF_TBL *)
|
||||
jpeg_std_huff_table (j_common_ptr cinfo, boolean isDC, int tblno)
|
||||
{
|
||||
JHUFF_TBL **htblptr, *htbl;
|
||||
const UINT8 *bits, *val;
|
||||
int nsymbols, len;
|
||||
|
||||
static const UINT8 bits_dc_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_luminance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
|
||||
static const UINT8 bits_dc_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_chrominance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
|
||||
static const UINT8 bits_ac_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
|
||||
static const UINT8 val_ac_luminance[] =
|
||||
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
|
||||
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
|
||||
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
|
||||
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
|
||||
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
||||
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
||||
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
||||
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
|
||||
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
|
||||
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
|
||||
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
|
||||
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
|
||||
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
|
||||
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
|
||||
static const UINT8 bits_ac_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
|
||||
static const UINT8 val_ac_chrominance[] =
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
|
||||
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
|
||||
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
|
||||
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
|
||||
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
|
||||
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
|
||||
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
|
||||
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
|
||||
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
|
||||
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
|
||||
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
|
||||
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
|
||||
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
|
||||
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
|
||||
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
|
||||
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
|
||||
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
|
||||
if (cinfo->is_decompressor) {
|
||||
if (isDC)
|
||||
htblptr = ((j_decompress_ptr) cinfo)->dc_huff_tbl_ptrs;
|
||||
else
|
||||
htblptr = ((j_decompress_ptr) cinfo)->ac_huff_tbl_ptrs;
|
||||
} else {
|
||||
if (isDC)
|
||||
htblptr = ((j_compress_ptr) cinfo)->dc_huff_tbl_ptrs;
|
||||
else
|
||||
htblptr = ((j_compress_ptr) cinfo)->ac_huff_tbl_ptrs;
|
||||
}
|
||||
|
||||
switch (tblno) {
|
||||
case 0:
|
||||
if (isDC) {
|
||||
bits = bits_dc_luminance;
|
||||
val = val_dc_luminance;
|
||||
} else {
|
||||
bits = bits_ac_luminance;
|
||||
val = val_ac_luminance;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (isDC) {
|
||||
bits = bits_dc_chrominance;
|
||||
val = val_dc_chrominance;
|
||||
} else {
|
||||
bits = bits_ac_chrominance;
|
||||
val = val_ac_chrominance;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
|
||||
return NULL; /* avoid compiler warnings for uninitialized variables */
|
||||
}
|
||||
|
||||
if (htblptr[tblno] == NULL)
|
||||
htblptr[tblno] = jpeg_alloc_huff_table(cinfo);
|
||||
|
||||
htbl = htblptr[tblno];
|
||||
|
||||
/* Copy the number-of-symbols-of-each-code-length counts */
|
||||
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
|
||||
|
||||
/* Validate the counts. We do this here mainly so we can copy the right
|
||||
* number of symbols from the val[] array, without risking marching off
|
||||
* the end of memory. jxhuff.c will do a more thorough test later.
|
||||
*/
|
||||
nsymbols = 0;
|
||||
for (len = 1; len <= 16; len++)
|
||||
nsymbols += bits[len];
|
||||
if (nsymbols > 256)
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
if (nsymbols > 0)
|
||||
MEMCOPY(htbl->huffval, val, nsymbols * SIZEOF(UINT8));
|
||||
|
||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||
htbl->sent_table = FALSE;
|
||||
|
||||
return htbl;
|
||||
}
|
||||
|
||||
Vendored
+14
-103
@@ -2,7 +2,7 @@
|
||||
* jcparam.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2003-2013 by Guido Vollbeding.
|
||||
* Modified 2003-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -162,112 +162,23 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||
|
||||
|
||||
/*
|
||||
* Huffman table setup routines
|
||||
* Reset standard Huffman tables
|
||||
*/
|
||||
|
||||
LOCAL(void)
|
||||
add_huff_table (j_compress_ptr cinfo,
|
||||
JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)
|
||||
/* Define a Huffman table */
|
||||
{
|
||||
int nsymbols, len;
|
||||
|
||||
if (*htblptr == NULL)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
|
||||
/* Copy the number-of-symbols-of-each-code-length counts */
|
||||
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
|
||||
|
||||
/* Validate the counts. We do this here mainly so we can copy the right
|
||||
* number of symbols from the val[] array, without risking marching off
|
||||
* the end of memory. jchuff.c will do a more thorough test later.
|
||||
*/
|
||||
nsymbols = 0;
|
||||
for (len = 1; len <= 16; len++)
|
||||
nsymbols += bits[len];
|
||||
if (nsymbols < 1 || nsymbols > 256)
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8));
|
||||
|
||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||
(*htblptr)->sent_table = FALSE;
|
||||
}
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
std_huff_tables (j_compress_ptr cinfo)
|
||||
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
|
||||
/* IMPORTANT: these are only valid for 8-bit data precision! */
|
||||
{
|
||||
static const UINT8 bits_dc_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_luminance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
|
||||
static const UINT8 bits_dc_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
|
||||
static const UINT8 val_dc_chrominance[] =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
|
||||
static const UINT8 bits_ac_luminance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
|
||||
static const UINT8 val_ac_luminance[] =
|
||||
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
|
||||
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
|
||||
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
|
||||
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
|
||||
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
|
||||
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
|
||||
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
||||
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
||||
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
||||
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
|
||||
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
|
||||
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
|
||||
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
|
||||
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
|
||||
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
|
||||
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
|
||||
static const UINT8 bits_ac_chrominance[17] =
|
||||
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
|
||||
static const UINT8 val_ac_chrominance[] =
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
|
||||
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
|
||||
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
|
||||
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
|
||||
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
|
||||
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
|
||||
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
|
||||
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
|
||||
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
|
||||
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
|
||||
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
|
||||
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
|
||||
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
|
||||
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
|
||||
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
|
||||
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
|
||||
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
|
||||
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
|
||||
0xf9, 0xfa };
|
||||
|
||||
add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0],
|
||||
bits_dc_luminance, val_dc_luminance);
|
||||
add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0],
|
||||
bits_ac_luminance, val_ac_luminance);
|
||||
add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1],
|
||||
bits_dc_chrominance, val_dc_chrominance);
|
||||
add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1],
|
||||
bits_ac_chrominance, val_ac_chrominance);
|
||||
if (cinfo->dc_huff_tbl_ptrs[0] != NULL)
|
||||
(void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 0);
|
||||
|
||||
if (cinfo->ac_huff_tbl_ptrs[0] != NULL)
|
||||
(void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 0);
|
||||
|
||||
if (cinfo->dc_huff_tbl_ptrs[1] != NULL)
|
||||
(void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 1);
|
||||
|
||||
if (cinfo->ac_huff_tbl_ptrs[1] != NULL)
|
||||
(void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +217,7 @@ jpeg_set_defaults (j_compress_ptr cinfo)
|
||||
cinfo->data_precision = BITS_IN_JSAMPLE;
|
||||
/* Set up two quantization tables using default quality of 75 */
|
||||
jpeg_set_quality(cinfo, 75, TRUE);
|
||||
/* Set up two Huffman tables */
|
||||
/* Reset standard Huffman tables */
|
||||
std_huff_tables(cinfo);
|
||||
|
||||
/* Initialize default arithmetic coding conditioning */
|
||||
|
||||
Vendored
+14
-14
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jdarith.c
|
||||
*
|
||||
* Developed 1997-2015 by Guido Vollbeding.
|
||||
* Developed 1997-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -280,7 +280,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if ((m = arith_decode(cinfo, st)) != 0) {
|
||||
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
|
||||
while (arith_decode(cinfo, st)) {
|
||||
if ((m <<= 1) == 0x8000) {
|
||||
if ((m <<= 1) == (int) 0x8000U) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* magnitude overflow */
|
||||
return TRUE;
|
||||
@@ -370,7 +370,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
st = entropy->ac_stats[tbl] +
|
||||
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
|
||||
while (arith_decode(cinfo, st)) {
|
||||
if ((m <<= 1) == 0x8000) {
|
||||
if ((m <<= 1) == (int) 0x8000U) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* magnitude overflow */
|
||||
return TRUE;
|
||||
@@ -404,7 +404,8 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||
unsigned char *st;
|
||||
int p1, blkn;
|
||||
JCOEF p1;
|
||||
int blkn;
|
||||
|
||||
/* Process restart marker if needed */
|
||||
if (cinfo->restart_interval) {
|
||||
@@ -440,7 +441,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
JCOEFPTR thiscoef;
|
||||
unsigned char *st;
|
||||
int tbl, k, kex;
|
||||
int p1, m1;
|
||||
JCOEF p1, m1;
|
||||
const int * natural_order;
|
||||
|
||||
/* Process restart marker if needed */
|
||||
@@ -459,7 +460,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
|
||||
|
||||
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
m1 = -p1; /* -1 in the bit position being coded */
|
||||
|
||||
/* Establish EOBx (previous stage end-of-block) index */
|
||||
kex = cinfo->Se;
|
||||
@@ -555,7 +556,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if ((m = arith_decode(cinfo, st)) != 0) {
|
||||
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
|
||||
while (arith_decode(cinfo, st)) {
|
||||
if ((m <<= 1) == 0x8000) {
|
||||
if ((m <<= 1) == (int) 0x8000U) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* magnitude overflow */
|
||||
return TRUE;
|
||||
@@ -612,7 +613,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
st = entropy->ac_stats[tbl] +
|
||||
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
|
||||
while (arith_decode(cinfo, st)) {
|
||||
if ((m <<= 1) == 0x8000) {
|
||||
if ((m <<= 1) == (int) 0x8000U) {
|
||||
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
|
||||
entropy->ct = -1; /* magnitude overflow */
|
||||
return TRUE;
|
||||
@@ -766,9 +767,8 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
arith_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (arith_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(arith_entropy_decoder));
|
||||
entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_decoder));
|
||||
cinfo->entropy = &entropy->pub;
|
||||
entropy->pub.start_pass = start_pass;
|
||||
entropy->pub.finish_pass = finish_pass;
|
||||
@@ -785,9 +785,9 @@ jinit_arith_decoder (j_decompress_ptr cinfo)
|
||||
if (cinfo->progressive_mode) {
|
||||
/* Create progression status table */
|
||||
int *coef_bit_ptr, ci;
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*SIZEOF(int));
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * DCTSIZE2 * SIZEOF(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
|
||||
Vendored
+10
-13
@@ -2,7 +2,7 @@
|
||||
* jdatadst.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2009-2017 by Guido Vollbeding.
|
||||
* Modified 2009-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -46,7 +46,7 @@ typedef struct {
|
||||
struct jpeg_destination_mgr pub; /* public fields */
|
||||
|
||||
unsigned char ** outbuffer; /* target buffer */
|
||||
unsigned long * outsize;
|
||||
size_t * outsize;
|
||||
unsigned char * newbuffer; /* newly allocated buffer */
|
||||
JOCTET * buffer; /* start of buffer */
|
||||
size_t bufsize;
|
||||
@@ -66,9 +66,8 @@ init_destination (j_compress_ptr cinfo)
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
|
||||
/* Allocate the output buffer --- it will be released when done with image */
|
||||
dest->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
dest->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||
@@ -131,7 +130,7 @@ empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||
nextbuffer = (JOCTET *) malloc(nextsize);
|
||||
|
||||
if (nextbuffer == NULL)
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 11);
|
||||
|
||||
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
|
||||
|
||||
@@ -204,9 +203,8 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
|
||||
* sizes may be different. Caveat programmer.
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_destination_mgr));
|
||||
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_destination_mgr));
|
||||
}
|
||||
|
||||
dest = (my_dest_ptr) cinfo->dest;
|
||||
@@ -233,7 +231,7 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
unsigned char ** outbuffer, unsigned long * outsize)
|
||||
unsigned char ** outbuffer, size_t * outsize)
|
||||
{
|
||||
my_mem_dest_ptr dest;
|
||||
|
||||
@@ -244,9 +242,8 @@ jpeg_mem_dest (j_compress_ptr cinfo,
|
||||
* can be written to the same buffer without re-executing jpeg_mem_dest.
|
||||
*/
|
||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_mem_destination_mgr));
|
||||
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_mem_destination_mgr));
|
||||
}
|
||||
|
||||
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||
|
||||
Vendored
+15
-16
@@ -2,7 +2,7 @@
|
||||
* jdatasrc.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2009-2015 by Guido Vollbeding.
|
||||
* Modified 2009-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -156,21 +156,23 @@ METHODDEF(void)
|
||||
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
||||
{
|
||||
struct jpeg_source_mgr * src = cinfo->src;
|
||||
size_t nbytes;
|
||||
|
||||
/* Just a dumb implementation for now. Could use fseek() except
|
||||
* it doesn't work on pipes. Not clear that being smart is worth
|
||||
* any trouble anyway --- large skips are infrequent.
|
||||
*/
|
||||
if (num_bytes > 0) {
|
||||
while (num_bytes > (long) src->bytes_in_buffer) {
|
||||
num_bytes -= (long) src->bytes_in_buffer;
|
||||
nbytes = (size_t) num_bytes;
|
||||
while (nbytes > src->bytes_in_buffer) {
|
||||
nbytes -= src->bytes_in_buffer;
|
||||
(void) (*src->fill_input_buffer) (cinfo);
|
||||
/* note we assume that fill_input_buffer will never return FALSE,
|
||||
* so suspension need not be handled.
|
||||
*/
|
||||
}
|
||||
src->next_input_byte += (size_t) num_bytes;
|
||||
src->bytes_in_buffer -= (size_t) num_bytes;
|
||||
src->next_input_byte += nbytes;
|
||||
src->bytes_in_buffer -= nbytes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,13 +221,11 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
|
||||
* manager serially with the same JPEG object. Caveat programmer.
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_source_mgr));
|
||||
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_source_mgr));
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
src->buffer = (JOCTET *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
INPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
src->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET));
|
||||
}
|
||||
|
||||
src = (my_src_ptr) cinfo->src;
|
||||
@@ -247,7 +247,7 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
|
||||
|
||||
GLOBAL(void)
|
||||
jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
const unsigned char * inbuffer, unsigned long insize)
|
||||
const unsigned char * inbuffer, size_t insize)
|
||||
{
|
||||
struct jpeg_source_mgr * src;
|
||||
|
||||
@@ -259,9 +259,8 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
* the first one.
|
||||
*/
|
||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||
cinfo->src = (struct jpeg_source_mgr *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(struct jpeg_source_mgr));
|
||||
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(struct jpeg_source_mgr));
|
||||
}
|
||||
|
||||
src = cinfo->src;
|
||||
@@ -270,6 +269,6 @@ jpeg_mem_src (j_decompress_ptr cinfo,
|
||||
src->skip_input_data = skip_input_data;
|
||||
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
|
||||
src->term_source = term_source;
|
||||
src->bytes_in_buffer = (size_t) insize;
|
||||
src->bytes_in_buffer = insize;
|
||||
src->next_input_byte = (const JOCTET *) inbuffer;
|
||||
}
|
||||
|
||||
Vendored
+59
-71
@@ -2,7 +2,7 @@
|
||||
* jdcolor.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2011-2017 by Guido Vollbeding.
|
||||
* Modified 2011-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -124,28 +124,22 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
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));
|
||||
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 1.402 * x */
|
||||
cconvert->Cr_r_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.402) * x + ONE_HALF, SCALEBITS);
|
||||
cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
|
||||
/* Cb=>B value is nearest int to 1.772 * x */
|
||||
cconvert->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.772) * x + ONE_HALF, SCALEBITS);
|
||||
cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.714136286 * x */
|
||||
cconvert->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
|
||||
/* Cb=>G value is scaled-up -0.344136286 * x */
|
||||
@@ -164,28 +158,22 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
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));
|
||||
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);
|
||||
cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, 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);
|
||||
cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, 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 */
|
||||
@@ -201,6 +189,7 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
* Note that we change from noninterleaved, one-plane-per-component format
|
||||
* to interleaved-pixel format. The output buffer is therefore three times
|
||||
* as wide as the input buffer.
|
||||
*
|
||||
* A starting row offset is provided only for the input buffer. The caller
|
||||
* can easily adjust the passed output_buf value to accommodate any row
|
||||
* offset required on that side.
|
||||
@@ -264,9 +253,8 @@ build_rgb_y_table (j_decompress_ptr cinfo)
|
||||
INT32 i;
|
||||
|
||||
/* Allocate and fill in the conversion tables. */
|
||||
cconvert->rgb_y_tab = rgb_y_tab = (INT32 *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(TABLE_SIZE * SIZEOF(INT32)));
|
||||
cconvert->rgb_y_tab = rgb_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, TABLE_SIZE * SIZEOF(INT32));
|
||||
|
||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||
rgb_y_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
||||
@@ -286,8 +274,8 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
register INT32 * ctab = cconvert->rgb_y_tab;
|
||||
register int r, g, b;
|
||||
register INT32 * ctab = cconvert->rgb_y_tab;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
@@ -313,6 +301,7 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
/*
|
||||
* Convert some rows of samples to the output colorspace.
|
||||
* [R-G,G,B-G] to [R,G,B] conversion with modulo calculation
|
||||
* (inverse color transform).
|
||||
* This can be seen as an adaption of the general YCbCr->RGB
|
||||
@@ -364,8 +353,8 @@ rgb1_gray_convert (j_decompress_ptr cinfo,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||
register INT32 * ctab = cconvert->rgb_y_tab;
|
||||
register int r, g, b;
|
||||
register INT32 * ctab = cconvert->rgb_y_tab;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
register JDIMENSION col;
|
||||
@@ -396,6 +385,7 @@ rgb1_gray_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
/*
|
||||
* Convert some rows of samples to the output colorspace.
|
||||
* No colorspace change, but conversion from separate-planes
|
||||
* to interleaved representation.
|
||||
*/
|
||||
@@ -430,6 +420,7 @@ rgb_convert (j_decompress_ptr cinfo,
|
||||
/*
|
||||
* Color conversion for no colorspace change: just copy the data,
|
||||
* converting from separate-planes to interleaved representation.
|
||||
* We assume out_color_components == num_components.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
@@ -437,20 +428,21 @@ null_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
int ci;
|
||||
register int nc = cinfo->num_components;
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr;
|
||||
register JDIMENSION col;
|
||||
register JDIMENSION count;
|
||||
register int num_comps = cinfo->num_components;
|
||||
JDIMENSION num_cols = cinfo->output_width;
|
||||
int ci;
|
||||
|
||||
while (--num_rows >= 0) {
|
||||
for (ci = 0; ci < nc; ci++) {
|
||||
/* It seems fastest to make a separate pass for each component. */
|
||||
for (ci = 0; ci < num_comps; ci++) {
|
||||
inptr = input_buf[ci][input_row];
|
||||
outptr = output_buf[0] + ci;
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
*outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */
|
||||
outptr += nc;
|
||||
for (count = num_cols; count > 0; count--) {
|
||||
*outptr = *inptr++; /* don't need GETJSAMPLE() here */
|
||||
outptr += num_comps;
|
||||
}
|
||||
}
|
||||
input_row++;
|
||||
@@ -504,9 +496,10 @@ gray_rgb_convert (j_decompress_ptr cinfo,
|
||||
|
||||
|
||||
/*
|
||||
* Adobe-style YCCK->CMYK conversion.
|
||||
* We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same
|
||||
* conversion as above, while passing K (black) unchanged.
|
||||
* Convert some rows of samples to the output colorspace.
|
||||
* This version handles Adobe-style YCCK->CMYK conversion,
|
||||
* where we convert YCbCr to R=1-C, G=1-M, and B=1-Y using the
|
||||
* same conversion as above, while passing K (black) unchanged.
|
||||
* We assume build_ycc_rgb_table has been called.
|
||||
*/
|
||||
|
||||
@@ -577,9 +570,8 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
my_cconvert_ptr cconvert;
|
||||
int ci;
|
||||
|
||||
cconvert = (my_cconvert_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_color_deconverter));
|
||||
cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_deconverter));
|
||||
cinfo->cconvert = &cconvert->pub;
|
||||
cconvert->pub.start_pass = start_pass_dcolor;
|
||||
|
||||
@@ -607,7 +599,6 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
default: /* JCS_UNKNOWN can be anything */
|
||||
if (cinfo->num_components < 1)
|
||||
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Support color transform only for RGB colorspaces */
|
||||
@@ -684,19 +675,18 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
|
||||
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
|
||||
if (cinfo->jpeg_color_space != JCS_BG_RGB)
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_CMYK:
|
||||
@@ -714,14 +704,12 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Permit null conversion to same output space */
|
||||
if (cinfo->out_color_space == cinfo->jpeg_color_space) {
|
||||
cinfo->out_color_components = cinfo->num_components;
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
} else /* unsupported non-null conversion */
|
||||
default: /* permit null conversion to same output space */
|
||||
if (cinfo->out_color_space != cinfo->jpeg_color_space)
|
||||
/* unsupported non-null conversion */
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
break;
|
||||
cinfo->out_color_components = cinfo->num_components;
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
}
|
||||
|
||||
if (cinfo->quantize_colors)
|
||||
|
||||
Vendored
+1
-8
@@ -2,7 +2,7 @@
|
||||
* jdct.h
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2002-2017 by Guido Vollbeding.
|
||||
* Modified 2002-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -358,13 +358,6 @@ EXTERN(void) jpeg_idct_1x2
|
||||
|
||||
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
|
||||
|
||||
/* Descale and correctly round an INT32 value that's scaled by N bits.
|
||||
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
|
||||
* the fudge factor is correct for either sign of X.
|
||||
*/
|
||||
|
||||
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
|
||||
|
||||
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
|
||||
* This macro is used only when the two inputs will actually be no more than
|
||||
* 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a
|
||||
|
||||
Vendored
+56
-50
@@ -2,7 +2,7 @@
|
||||
* jdhuff.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2006-2016 by Guido Vollbeding.
|
||||
* Modified 2006-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -341,13 +341,12 @@ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
|
||||
htbl =
|
||||
isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
|
||||
if (htbl == NULL)
|
||||
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
|
||||
htbl = jpeg_std_huff_table((j_common_ptr) cinfo, isDC, tblno);
|
||||
|
||||
/* Allocate a workspace if we haven't already done so. */
|
||||
if (*pdtbl == NULL)
|
||||
*pdtbl = (d_derived_tbl *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(d_derived_tbl));
|
||||
*pdtbl = (d_derived_tbl *) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(d_derived_tbl));
|
||||
dtbl = *pdtbl;
|
||||
dtbl->pub = htbl; /* fill in back link */
|
||||
|
||||
@@ -706,7 +705,7 @@ process_restart (j_decompress_ptr cinfo)
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
int Al = cinfo->Al;
|
||||
register int s, r;
|
||||
@@ -730,7 +729,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (! entropy->insufficient_data) {
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
@@ -759,12 +758,13 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
entropy->restarts_to_go--;
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -777,7 +777,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
register int s, k, r;
|
||||
unsigned int EOBRUN;
|
||||
@@ -809,7 +809,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (EOBRUN) /* if it's a band of zeroes... */
|
||||
EOBRUN--; /* ...process it now (we do nothing) */
|
||||
else {
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
Se = cinfo->Se;
|
||||
Al = cinfo->Al;
|
||||
natural_order = cinfo->natural_order;
|
||||
@@ -842,15 +842,16 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
}
|
||||
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
entropy->restarts_to_go--;
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -864,9 +865,10 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
int p1, blkn;
|
||||
JCOEF p1;
|
||||
int blkn;
|
||||
BITREAD_STATE_VARS;
|
||||
|
||||
/* Process restart marker if needed; may have to suspend */
|
||||
@@ -881,7 +883,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
*/
|
||||
|
||||
/* 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 */
|
||||
|
||||
@@ -896,10 +898,11 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
entropy->restarts_to_go--;
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -911,11 +914,12 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
METHODDEF(boolean)
|
||||
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
{
|
||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||
register int s, k, r;
|
||||
unsigned int EOBRUN;
|
||||
int Se, p1, m1;
|
||||
int Se;
|
||||
JCOEF p1, m1;
|
||||
const int * natural_order;
|
||||
JBLOCKROW block;
|
||||
JCOEFPTR thiscoef;
|
||||
@@ -937,11 +941,11 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
Se = cinfo->Se;
|
||||
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
|
||||
m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
|
||||
m1 = -p1; /* -1 in the bit position being coded */
|
||||
natural_order = cinfo->natural_order;
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
|
||||
|
||||
/* There is always only one block per MCU */
|
||||
@@ -1043,12 +1047,13 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
entropy->restarts_to_go--;
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -1091,7 +1096,7 @@ decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
Se = cinfo->lim_Se;
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
@@ -1178,12 +1183,13 @@ decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
entropy->restarts_to_go--;
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1215,7 +1221,7 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
if (! entropy->insufficient_data) {
|
||||
|
||||
/* Load up working state */
|
||||
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_LOAD_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(state, entropy->saved);
|
||||
|
||||
/* Outer loop handles each block in the MCU */
|
||||
@@ -1302,12 +1308,13 @@ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Completed MCU, so update state */
|
||||
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
|
||||
BITREAD_SAVE_STATE(cinfo, entropy->bitstate);
|
||||
ASSIGN_STATE(entropy->saved, state);
|
||||
}
|
||||
|
||||
/* Account for restart interval (no-op if not using restarts) */
|
||||
entropy->restarts_to_go--;
|
||||
/* Account for restart interval if using restarts */
|
||||
if (cinfo->restart_interval)
|
||||
entropy->restarts_to_go--;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1343,11 +1350,11 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
goto bad;
|
||||
}
|
||||
if (cinfo->Al > 13) { /* need not check for < 0 */
|
||||
/* Arguably the maximum Al value should be less than 13 for 8-bit precision,
|
||||
* but the spec doesn't say so, and we try to be liberal about what we
|
||||
* accept. Note: large Al values could result in out-of-range DC
|
||||
* coefficients during early scans, leading to bizarre displays due to
|
||||
* overflows in the IDCT math. But we won't crash.
|
||||
/* Arguably the maximum Al value should be less than 13 for 8-bit
|
||||
* precision, but the spec doesn't say so, and we try to be liberal
|
||||
* about what we accept. Note: large Al values could result in
|
||||
* out-of-range DC coefficients during early scans, leading to bizarre
|
||||
* displays due to overflows in the IDCT math. But we won't crash.
|
||||
*/
|
||||
bad:
|
||||
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
|
||||
@@ -1451,7 +1458,8 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
compptr = cinfo->cur_comp_info[ci];
|
||||
/* Precalculate which table to use for each block */
|
||||
entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
|
||||
entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
|
||||
entropy->ac_cur_tbls[blkn] = /* AC needs no table when not present */
|
||||
cinfo->lim_Se ? entropy->ac_derived_tbls[compptr->ac_tbl_no] : NULL;
|
||||
/* Decide whether we really care about the coefficient values */
|
||||
if (compptr->component_needed) {
|
||||
ci = compptr->DCT_v_scaled_size;
|
||||
@@ -1494,7 +1502,6 @@ start_pass_huff_decoder (j_decompress_ptr cinfo)
|
||||
if (ci <= 0 || ci > 8) ci = 8;
|
||||
if (i <= 0 || i > 8) i = 8;
|
||||
entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order[ci - 1][i - 1];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
entropy->coef_limit[blkn] = 0;
|
||||
@@ -1522,9 +1529,8 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
huff_entropy_ptr entropy;
|
||||
int i;
|
||||
|
||||
entropy = (huff_entropy_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(huff_entropy_decoder));
|
||||
entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_decoder));
|
||||
cinfo->entropy = &entropy->pub;
|
||||
entropy->pub.start_pass = start_pass_huff_decoder;
|
||||
entropy->pub.finish_pass = finish_pass_huff;
|
||||
@@ -1532,9 +1538,9 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
if (cinfo->progressive_mode) {
|
||||
/* Create progression status table */
|
||||
int *coef_bit_ptr, ci;
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2])
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components*DCTSIZE2*SIZEOF(int));
|
||||
cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
cinfo->num_components * DCTSIZE2 * SIZEOF(int));
|
||||
coef_bit_ptr = & cinfo->coef_bits[0][0];
|
||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||
for (i = 0; i < DCTSIZE2; i++)
|
||||
@@ -1545,7 +1551,7 @@ jinit_huff_decoder (j_decompress_ptr cinfo)
|
||||
entropy->derived_tbls[i] = NULL;
|
||||
}
|
||||
} else {
|
||||
/* Mark tables unallocated */
|
||||
/* Mark derived tables unallocated */
|
||||
for (i = 0; i < NUM_HUFF_TBLS; i++) {
|
||||
entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
|
||||
}
|
||||
|
||||
Vendored
+7
-13
@@ -2,7 +2,7 @@
|
||||
* jdmarker.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2009-2013 by Guido Vollbeding.
|
||||
* Modified 2009-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -496,8 +496,6 @@ get_dht (j_decompress_ptr cinfo)
|
||||
if (count > 256 || ((INT32) count) > length)
|
||||
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
|
||||
|
||||
MEMZERO(huffval, SIZEOF(huffval)); /* pre-zero array for later copy */
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
INPUT_BYTE(cinfo, huffval[i], return FALSE);
|
||||
|
||||
@@ -517,7 +515,8 @@ get_dht (j_decompress_ptr cinfo)
|
||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||
|
||||
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
|
||||
MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));
|
||||
if (count > 0)
|
||||
MEMCOPY((*htblptr)->huffval, huffval, count * SIZEOF(UINT8));
|
||||
}
|
||||
|
||||
if (length != 0)
|
||||
@@ -577,14 +576,14 @@ get_dqt (j_decompress_ptr cinfo)
|
||||
count = DCTSIZE2;
|
||||
}
|
||||
|
||||
switch (count) {
|
||||
switch ((int) count) {
|
||||
case (2*2): natural_order = jpeg_natural_order2; break;
|
||||
case (3*3): natural_order = jpeg_natural_order3; break;
|
||||
case (4*4): natural_order = jpeg_natural_order4; break;
|
||||
case (5*5): natural_order = jpeg_natural_order5; break;
|
||||
case (6*6): natural_order = jpeg_natural_order6; break;
|
||||
case (7*7): natural_order = jpeg_natural_order7; break;
|
||||
default: natural_order = jpeg_natural_order; break;
|
||||
default: natural_order = jpeg_natural_order;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -784,7 +783,6 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
|
||||
default:
|
||||
TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
|
||||
GETJOCTET(data[5]), (int) totallen);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Start of APP0 does not match "JFIF" or "JFXX", or too short */
|
||||
@@ -858,7 +856,6 @@ get_interesting_appn (j_decompress_ptr cinfo)
|
||||
default:
|
||||
/* can't get here unless jpeg_save_markers chooses wrong processor */
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
|
||||
break;
|
||||
}
|
||||
|
||||
/* skip any remaining data -- could be lots */
|
||||
@@ -964,7 +961,6 @@ save_marker (j_decompress_ptr cinfo)
|
||||
default:
|
||||
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
|
||||
(int) (data_length + length));
|
||||
break;
|
||||
}
|
||||
|
||||
/* skip any remaining data -- could be lots */
|
||||
@@ -1240,7 +1236,6 @@ read_markers (j_decompress_ptr cinfo)
|
||||
* ought to change!
|
||||
*/
|
||||
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
|
||||
break;
|
||||
}
|
||||
/* Successfully processed marker, so reset state variable */
|
||||
cinfo->unread_marker = 0;
|
||||
@@ -1416,9 +1411,8 @@ jinit_marker_reader (j_decompress_ptr cinfo)
|
||||
int i;
|
||||
|
||||
/* Create subobject in permanent pool */
|
||||
marker = (my_marker_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||
SIZEOF(my_marker_reader));
|
||||
marker = (my_marker_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_marker_reader));
|
||||
cinfo->marker = &marker->pub;
|
||||
/* Initialize public method pointers */
|
||||
marker->pub.reset_marker_reader = reset_marker_reader;
|
||||
|
||||
Vendored
+24
-23
@@ -2,7 +2,7 @@
|
||||
* jdmaster.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2002-2017 by Guido Vollbeding.
|
||||
* Modified 2002-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -104,7 +104,7 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
*/
|
||||
{
|
||||
#ifdef IDCT_SCALING_SUPPORTED
|
||||
int ci;
|
||||
int ci, ssize;
|
||||
jpeg_component_info *compptr;
|
||||
#endif
|
||||
|
||||
@@ -124,19 +124,23 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
*/
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
int ssize = 1;
|
||||
while (cinfo->min_DCT_h_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
ssize = 1;
|
||||
if (! cinfo->raw_data_out)
|
||||
while (cinfo->min_DCT_h_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) ==
|
||||
0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
|
||||
ssize = 1;
|
||||
while (cinfo->min_DCT_v_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
if (! cinfo->raw_data_out)
|
||||
while (cinfo->min_DCT_v_scaled_size * ssize <=
|
||||
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) ==
|
||||
0) {
|
||||
ssize = ssize * 2;
|
||||
}
|
||||
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
|
||||
|
||||
/* We don't support IDCT ratios larger than 2. */
|
||||
@@ -144,13 +148,10 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
|
||||
else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
|
||||
compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
|
||||
}
|
||||
|
||||
/* Recompute downsampled dimensions of components;
|
||||
* application needs to know these if using raw downsampled data.
|
||||
*/
|
||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||
ci++, compptr++) {
|
||||
/* Recompute downsampled dimensions of components;
|
||||
* application needs to know these if using raw downsampled data.
|
||||
*/
|
||||
/* Size in samples, after IDCT scaling */
|
||||
compptr->downsampled_width = (JDIMENSION)
|
||||
jdiv_round_up((long) cinfo->image_width *
|
||||
@@ -172,8 +173,10 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
break;
|
||||
case JCS_RGB:
|
||||
case JCS_BG_RGB:
|
||||
#if RGB_PIXELSIZE != 3
|
||||
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||
break;
|
||||
#endif /* else share code with YCbCr */
|
||||
case JCS_YCbCr:
|
||||
case JCS_BG_YCC:
|
||||
cinfo->out_color_components = 3;
|
||||
@@ -184,7 +187,6 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
||||
break;
|
||||
default: /* else must be same colorspace as in file */
|
||||
cinfo->out_color_components = cinfo->num_components;
|
||||
break;
|
||||
}
|
||||
cinfo->output_components = (cinfo->quantize_colors ? 1 :
|
||||
cinfo->out_color_components);
|
||||
@@ -525,9 +527,8 @@ jinit_master_decompress (j_decompress_ptr cinfo)
|
||||
{
|
||||
my_master_ptr master;
|
||||
|
||||
master = (my_master_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_decomp_master));
|
||||
master = (my_master_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_decomp_master));
|
||||
cinfo->master = &master->pub;
|
||||
master->pub.prepare_for_output_pass = prepare_for_output_pass;
|
||||
master->pub.finish_output_pass = finish_output_pass;
|
||||
|
||||
Vendored
+26
-39
@@ -2,7 +2,7 @@
|
||||
* jdmerge.c
|
||||
*
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Modified 2013-2017 by Guido Vollbeding.
|
||||
* Modified 2013-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -95,28 +95,22 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
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));
|
||||
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 1.402 * x */
|
||||
upsample->Cr_r_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.402) * x + ONE_HALF, SCALEBITS);
|
||||
upsample->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
|
||||
/* Cb=>B value is nearest int to 1.772 * x */
|
||||
upsample->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.772) * x + ONE_HALF, SCALEBITS);
|
||||
upsample->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.714136286 * x */
|
||||
upsample->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
|
||||
/* Cb=>G value is scaled-up -0.344136286 * x */
|
||||
@@ -135,28 +129,22 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
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));
|
||||
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);
|
||||
upsample->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, 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);
|
||||
upsample->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, 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 */
|
||||
@@ -419,9 +407,8 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
SIZEOF(my_upsampler));
|
||||
upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler));
|
||||
cinfo->upsample = &upsample->pub;
|
||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||
upsample->pub.need_context_rows = FALSE;
|
||||
@@ -432,9 +419,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
upsample->pub.upsample = merged_2v_upsample;
|
||||
upsample->upmethod = h2v2_merged_upsample;
|
||||
/* Allocate a spare row buffer */
|
||||
upsample->spare_row = (JSAMPROW)
|
||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) (upsample->out_row_width * SIZEOF(JSAMPLE)));
|
||||
upsample->spare_row = (JSAMPROW) (*cinfo->mem->alloc_large)
|
||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(size_t) upsample->out_row_width * SIZEOF(JSAMPLE));
|
||||
} else {
|
||||
upsample->pub.upsample = merged_1v_upsample;
|
||||
upsample->upmethod = h2v1_merged_upsample;
|
||||
|
||||
Vendored
+2
-2
@@ -2,7 +2,7 @@
|
||||
* jerror.h
|
||||
*
|
||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||
* Modified 1997-2012 by Guido Vollbeding.
|
||||
* Modified 1997-2018 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -84,7 +84,7 @@ JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
|
||||
JMESSAGE(JERR_FILE_READ, "Input file read error")
|
||||
JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
|
||||
JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
|
||||
JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
|
||||
JMESSAGE(JERR_HUFF_CLEN_OUTOFBOUNDS, "Huffman code size table out of bounds")
|
||||
JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
|
||||
JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
|
||||
JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
|
||||
|
||||
Vendored
+61
-55
@@ -2,7 +2,7 @@
|
||||
* jfdctint.c
|
||||
*
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* Modification developed 2003-2015 by Guido Vollbeding.
|
||||
* Modification developed 2003-2018 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -3261,78 +3261,84 @@ jpeg_fdct_6x3 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
|
||||
GLOBAL(void)
|
||||
jpeg_fdct_4x2 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
|
||||
{
|
||||
INT32 tmp0, tmp1;
|
||||
INT32 tmp10, tmp11;
|
||||
DCTELEM *dataptr;
|
||||
DCTELEM tmp0, tmp2, tmp10, tmp12, tmp4, tmp5;
|
||||
INT32 tmp1, tmp3, tmp11, tmp13;
|
||||
INT32 z1, z2, z3;
|
||||
JSAMPROW elemptr;
|
||||
int ctr;
|
||||
SHIFT_TEMPS
|
||||
|
||||
/* Pre-zero output coefficient block. */
|
||||
MEMZERO(data, SIZEOF(DCTELEM) * DCTSIZE2);
|
||||
|
||||
/* Pass 1: process rows.
|
||||
* Note results are scaled up by sqrt(8) compared to a true DCT;
|
||||
* furthermore, we scale the results by 2**PASS1_BITS.
|
||||
* We must also scale the output by (8/4)*(8/2) = 2**3, which we add here.
|
||||
* Note results are scaled up by sqrt(8) compared to a true DCT.
|
||||
* 4-point FDCT kernel,
|
||||
* cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
|
||||
*/
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = 0; ctr < 2; ctr++) {
|
||||
elemptr = sample_data[ctr] + start_col;
|
||||
/* Row 0 */
|
||||
elemptr = sample_data[0] + start_col;
|
||||
|
||||
/* Even part */
|
||||
/* Even part */
|
||||
|
||||
tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
|
||||
tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
|
||||
tmp4 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
|
||||
tmp5 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
|
||||
|
||||
tmp10 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
|
||||
tmp11 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
|
||||
tmp0 = tmp4 + tmp5;
|
||||
tmp2 = tmp4 - tmp5;
|
||||
|
||||
/* Apply unsigned->signed conversion. */
|
||||
dataptr[0] = (DCTELEM)
|
||||
((tmp0 + tmp1 - 4 * CENTERJSAMPLE) << (PASS1_BITS+3));
|
||||
dataptr[2] = (DCTELEM) ((tmp0 - tmp1) << (PASS1_BITS+3));
|
||||
/* Odd part */
|
||||
|
||||
/* Odd part */
|
||||
z2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
|
||||
z3 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
|
||||
|
||||
tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 += ONE << (CONST_BITS-PASS1_BITS-4);
|
||||
z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */
|
||||
/* Add fudge factor here for final descale. */
|
||||
z1 += ONE << (CONST_BITS-3-1);
|
||||
tmp1 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
|
||||
tmp3 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
|
||||
|
||||
dataptr[1] = (DCTELEM)
|
||||
RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
|
||||
CONST_BITS-PASS1_BITS-3);
|
||||
dataptr[3] = (DCTELEM)
|
||||
RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
|
||||
CONST_BITS-PASS1_BITS-3);
|
||||
/* Row 1 */
|
||||
elemptr = sample_data[1] + start_col;
|
||||
|
||||
dataptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
/* Even part */
|
||||
|
||||
tmp4 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[3]);
|
||||
tmp5 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[2]);
|
||||
|
||||
tmp10 = tmp4 + tmp5;
|
||||
tmp12 = tmp4 - tmp5;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
z2 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[3]);
|
||||
z3 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[2]);
|
||||
|
||||
z1 = MULTIPLY(z2 + z3, FIX_0_541196100); /* c6 */
|
||||
tmp11 = z1 + MULTIPLY(z2, FIX_0_765366865); /* c2-c6 */
|
||||
tmp13 = z1 - MULTIPLY(z3, FIX_1_847759065); /* c2+c6 */
|
||||
|
||||
/* Pass 2: process columns.
|
||||
* We remove the PASS1_BITS scaling, but leave the results scaled up
|
||||
* by an overall factor of 8.
|
||||
* We leave the results scaled up by an overall factor of 8.
|
||||
* We must also scale the output by (8/4)*(8/2) = 2**3.
|
||||
*/
|
||||
|
||||
dataptr = data;
|
||||
for (ctr = 0; ctr < 4; ctr++) {
|
||||
/* Even part */
|
||||
/* Column 0 */
|
||||
/* Apply unsigned->signed conversion. */
|
||||
data[DCTSIZE*0] = (tmp0 + tmp10 - 8 * CENTERJSAMPLE) << 3;
|
||||
data[DCTSIZE*1] = (tmp0 - tmp10) << 3;
|
||||
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 = dataptr[DCTSIZE*0] + (ONE << (PASS1_BITS-1));
|
||||
tmp1 = dataptr[DCTSIZE*1];
|
||||
/* Column 1 */
|
||||
data[DCTSIZE*0+1] = (DCTELEM) RIGHT_SHIFT(tmp1 + tmp11, CONST_BITS-3);
|
||||
data[DCTSIZE*1+1] = (DCTELEM) RIGHT_SHIFT(tmp1 - tmp11, CONST_BITS-3);
|
||||
|
||||
dataptr[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp0 + tmp1, PASS1_BITS);
|
||||
/* Column 2 */
|
||||
data[DCTSIZE*0+2] = (tmp2 + tmp12) << 3;
|
||||
data[DCTSIZE*1+2] = (tmp2 - tmp12) << 3;
|
||||
|
||||
/* Odd part */
|
||||
|
||||
dataptr[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0 - tmp1, PASS1_BITS);
|
||||
|
||||
dataptr++; /* advance pointer to next column */
|
||||
}
|
||||
/* Column 3 */
|
||||
data[DCTSIZE*0+3] = (DCTELEM) RIGHT_SHIFT(tmp3 + tmp13, CONST_BITS-3);
|
||||
data[DCTSIZE*1+3] = (DCTELEM) RIGHT_SHIFT(tmp3 - tmp13, CONST_BITS-3);
|
||||
}
|
||||
|
||||
|
||||
@@ -4312,7 +4318,6 @@ jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
|
||||
|
||||
/* Pass 1: process rows.
|
||||
* Note results are scaled up by sqrt(8) compared to a true DCT.
|
||||
* We must also scale the output by (8/2)*(8/4) = 2**3, which we add here.
|
||||
*/
|
||||
|
||||
dataptr = data;
|
||||
@@ -4325,17 +4330,18 @@ jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
|
||||
tmp1 = GETJSAMPLE(elemptr[1]);
|
||||
|
||||
/* Apply unsigned->signed conversion. */
|
||||
dataptr[0] = (DCTELEM) ((tmp0 + tmp1 - 2 * CENTERJSAMPLE) << 3);
|
||||
dataptr[0] = (DCTELEM) (tmp0 + tmp1 - 2 * CENTERJSAMPLE);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
dataptr[1] = (DCTELEM) ((tmp0 - tmp1) << 3);
|
||||
dataptr[1] = (DCTELEM) (tmp0 - tmp1);
|
||||
|
||||
dataptr += DCTSIZE; /* advance pointer to next row */
|
||||
}
|
||||
|
||||
/* Pass 2: process columns.
|
||||
* We leave the results scaled up by an overall factor of 8.
|
||||
* We must also scale the output by (8/2)*(8/4) = 2**3.
|
||||
* 4-point FDCT kernel,
|
||||
* cK represents sqrt(2) * cos(K*pi/16) [refers to 8-point FDCT].
|
||||
*/
|
||||
@@ -4350,21 +4356,21 @@ jpeg_fdct_2x4 (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
|
||||
tmp10 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*3];
|
||||
tmp11 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*2];
|
||||
|
||||
dataptr[DCTSIZE*0] = (DCTELEM) (tmp0 + tmp1);
|
||||
dataptr[DCTSIZE*2] = (DCTELEM) (tmp0 - tmp1);
|
||||
dataptr[DCTSIZE*0] = (DCTELEM) ((tmp0 + tmp1) << 3);
|
||||
dataptr[DCTSIZE*2] = (DCTELEM) ((tmp0 - tmp1) << 3);
|
||||
|
||||
/* Odd part */
|
||||
|
||||
tmp0 = MULTIPLY(tmp10 + tmp11, FIX_0_541196100); /* c6 */
|
||||
/* Add fudge factor here for final descale. */
|
||||
tmp0 += ONE << (CONST_BITS-1);
|
||||
tmp0 += ONE << (CONST_BITS-3-1);
|
||||
|
||||
dataptr[DCTSIZE*1] = (DCTELEM)
|
||||
RIGHT_SHIFT(tmp0 + MULTIPLY(tmp10, FIX_0_765366865), /* c2-c6 */
|
||||
CONST_BITS);
|
||||
CONST_BITS-3);
|
||||
dataptr[DCTSIZE*3] = (DCTELEM)
|
||||
RIGHT_SHIFT(tmp0 - MULTIPLY(tmp11, FIX_1_847759065), /* c2+c6 */
|
||||
CONST_BITS);
|
||||
CONST_BITS-3);
|
||||
|
||||
dataptr++; /* advance pointer to next column */
|
||||
}
|
||||
|
||||
Vendored
+6
-6
@@ -2,7 +2,7 @@
|
||||
* jidctint.c
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modification developed 2002-2016 by Guido Vollbeding.
|
||||
* Modification developed 2002-2018 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -1474,7 +1474,7 @@ jpeg_idct_10x10 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/*
|
||||
* Perform dequantization and inverse DCT on one block of coefficients,
|
||||
* producing a 11x11 output block.
|
||||
* producing an 11x11 output block.
|
||||
*
|
||||
* Optimized algorithm with 24 multiplications in the 1-D kernel.
|
||||
* cK represents sqrt(2) * cos(K*pi/22).
|
||||
@@ -3675,7 +3675,7 @@ jpeg_idct_10x5 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/*
|
||||
* Perform dequantization and inverse DCT on one block of coefficients,
|
||||
* producing a 8x4 output block.
|
||||
* producing an 8x4 output block.
|
||||
*
|
||||
* 4-point IDCT in pass 1 (columns), 8-point in pass 2 (rows).
|
||||
*/
|
||||
@@ -3835,7 +3835,7 @@ jpeg_idct_8x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/*
|
||||
* Perform dequantization and inverse DCT on one block of coefficients,
|
||||
* producing a reduced-size 6x3 output block.
|
||||
* producing a 6x3 output block.
|
||||
*
|
||||
* 3-point IDCT in pass 1 (columns), 6-point in pass 2 (rows).
|
||||
*/
|
||||
@@ -4082,7 +4082,7 @@ jpeg_idct_2x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/*
|
||||
* Perform dequantization and inverse DCT on one block of coefficients,
|
||||
* producing a 8x16 output block.
|
||||
* producing an 8x16 output block.
|
||||
*
|
||||
* 16-point IDCT in pass 1 (columns), 8-point in pass 2 (rows).
|
||||
*/
|
||||
@@ -5004,7 +5004,7 @@ jpeg_idct_4x8 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
|
||||
/*
|
||||
* Perform dequantization and inverse DCT on one block of coefficients,
|
||||
* producing a reduced-size 3x6 output block.
|
||||
* producing a 3x6 output block.
|
||||
*
|
||||
* 6-point IDCT in pass 1 (columns), 3-point in pass 2 (rows).
|
||||
*/
|
||||
|
||||
Vendored
+28
-32
@@ -2,7 +2,7 @@
|
||||
* jmemmgr.c
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2011-2012 by Guido Vollbeding.
|
||||
* Modified 2011-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -130,7 +130,7 @@ typedef struct {
|
||||
jvirt_barray_ptr virt_barray_list;
|
||||
|
||||
/* This counts total space obtained from jpeg_get_small/large */
|
||||
long total_space_allocated;
|
||||
size_t total_space_allocated;
|
||||
|
||||
/* alloc_sarray and alloc_barray set this value for use by virtual
|
||||
* array routines.
|
||||
@@ -195,7 +195,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
|
||||
* This is helpful because message parm array can't handle longs.
|
||||
*/
|
||||
fprintf(stderr, "Freeing pool %d, total space = %ld\n",
|
||||
pool_id, mem->total_space_allocated);
|
||||
pool_id, (long) mem->total_space_allocated);
|
||||
|
||||
for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;
|
||||
lhdr_ptr = lhdr_ptr->hdr.next) {
|
||||
@@ -260,11 +260,11 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
small_pool_ptr hdr_ptr, prev_hdr_ptr;
|
||||
char * data_ptr;
|
||||
size_t odd_bytes, min_request, slop;
|
||||
char * data_ptr;
|
||||
|
||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||
if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr)))
|
||||
if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(small_pool_hdr))
|
||||
out_of_memory(cinfo, 1); /* request exceeds malloc's ability */
|
||||
|
||||
/* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */
|
||||
@@ -293,8 +293,8 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
else
|
||||
slop = extra_pool_slop[pool_id];
|
||||
/* Don't ask for more than MAX_ALLOC_CHUNK */
|
||||
if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request))
|
||||
slop = (size_t) (MAX_ALLOC_CHUNK-min_request);
|
||||
if (slop > (size_t) MAX_ALLOC_CHUNK - min_request)
|
||||
slop = (size_t) MAX_ALLOC_CHUNK - min_request;
|
||||
/* Try to get space, if fail reduce slop and try again */
|
||||
for (;;) {
|
||||
hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);
|
||||
@@ -348,7 +348,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
|
||||
size_t odd_bytes;
|
||||
|
||||
/* Check for unsatisfiable request (do now to ensure no overflow below) */
|
||||
if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)))
|
||||
if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr))
|
||||
out_of_memory(cinfo, 3); /* request exceeds malloc's ability */
|
||||
|
||||
/* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */
|
||||
@@ -404,7 +404,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
long ltemp;
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
|
||||
ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) /
|
||||
((long) samplesperrow * SIZEOF(JSAMPLE));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
@@ -416,15 +416,14 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * SIZEOF(JSAMPROW)));
|
||||
(size_t) numrows * SIZEOF(JSAMPROW));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow
|
||||
* SIZEOF(JSAMPLE)));
|
||||
(size_t) rowsperchunk * (size_t) samplesperrow * SIZEOF(JSAMPLE));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += samplesperrow;
|
||||
@@ -452,7 +451,7 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
long ltemp;
|
||||
|
||||
/* Calculate max # of rows allowed in one allocation chunk */
|
||||
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) /
|
||||
ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) /
|
||||
((long) blocksperrow * SIZEOF(JBLOCK));
|
||||
if (ltemp <= 0)
|
||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||
@@ -464,15 +463,14 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
|
||||
|
||||
/* Get space for row pointers (small object) */
|
||||
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
|
||||
(size_t) (numrows * SIZEOF(JBLOCKROW)));
|
||||
(size_t) numrows * SIZEOF(JBLOCKROW));
|
||||
|
||||
/* Get the rows themselves (large objects) */
|
||||
currow = 0;
|
||||
while (currow < numrows) {
|
||||
rowsperchunk = MIN(rowsperchunk, numrows - currow);
|
||||
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
|
||||
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow
|
||||
* SIZEOF(JBLOCK)));
|
||||
(size_t) rowsperchunk * (size_t) blocksperrow * SIZEOF(JBLOCK));
|
||||
for (i = rowsperchunk; i > 0; i--) {
|
||||
result[currow++] = workspace;
|
||||
workspace += blocksperrow;
|
||||
@@ -585,8 +583,8 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
/* Allocate the in-memory buffers for any unrealized virtual arrays */
|
||||
{
|
||||
my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
|
||||
long space_per_minheight, maximum_space, avail_mem;
|
||||
long minheights, max_minheights;
|
||||
long bytesperrow, space_per_minheight, maximum_space;
|
||||
long avail_mem, minheights, max_minheights;
|
||||
jvirt_sarray_ptr sptr;
|
||||
jvirt_barray_ptr bptr;
|
||||
|
||||
@@ -598,18 +596,16 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
maximum_space = 0;
|
||||
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
|
||||
if (sptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
space_per_minheight += (long) sptr->maxaccess *
|
||||
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
maximum_space += (long) sptr->rows_in_array *
|
||||
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
bytesperrow = (long) sptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
space_per_minheight += (long) sptr->maxaccess * bytesperrow;
|
||||
maximum_space += (long) sptr->rows_in_array * bytesperrow;
|
||||
}
|
||||
}
|
||||
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
|
||||
if (bptr->mem_buffer == NULL) { /* if not realized yet */
|
||||
space_per_minheight += (long) bptr->maxaccess *
|
||||
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
maximum_space += (long) bptr->rows_in_array *
|
||||
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
bytesperrow = (long) bptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
space_per_minheight += (long) bptr->maxaccess * bytesperrow;
|
||||
maximum_space += (long) bptr->rows_in_array * bytesperrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,7 +614,7 @@ realize_virt_arrays (j_common_ptr cinfo)
|
||||
|
||||
/* Determine amount of memory to actually use; this is system-dependent. */
|
||||
avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,
|
||||
mem->total_space_allocated);
|
||||
(long) mem->total_space_allocated);
|
||||
|
||||
/* If the maximum space needed is available, make all the buffers full
|
||||
* height; otherwise parcel it out with the same number of minheights
|
||||
@@ -694,7 +690,7 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
file_offset = (long) ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
@@ -727,7 +723,7 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
|
||||
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
|
||||
|
||||
bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK);
|
||||
file_offset = ptr->cur_start_row * bytesperrow;
|
||||
file_offset = (long) ptr->cur_start_row * bytesperrow;
|
||||
/* Loop to read or write each allocation chunk in mem_buffer */
|
||||
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
|
||||
/* One chunk, but check for short chunk at end of buffer */
|
||||
@@ -771,7 +767,7 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
|
||||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
@@ -856,7 +852,7 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
|
||||
|
||||
/* Make the desired part of the virtual array accessible */
|
||||
if (start_row < ptr->cur_start_row ||
|
||||
end_row > ptr->cur_start_row+ptr->rows_in_mem) {
|
||||
end_row > ptr->cur_start_row + ptr->rows_in_mem) {
|
||||
if (! ptr->b_s_open)
|
||||
ERREXIT(cinfo, JERR_VIRTUAL_BUG);
|
||||
/* Flush old buffer contents if necessary */
|
||||
@@ -1093,7 +1089,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
|
||||
mem->total_space_allocated = SIZEOF(my_memory_mgr);
|
||||
|
||||
/* Declare ourselves open for business */
|
||||
cinfo->mem = & mem->pub;
|
||||
cinfo->mem = &mem->pub;
|
||||
|
||||
/* Check for an environment variable JPEGMEM; if found, override the
|
||||
* default max_memory setting from jpeg_mem_init. Note that the
|
||||
|
||||
Vendored
+6
-2
@@ -2,6 +2,7 @@
|
||||
* jmemnobs.c
|
||||
*
|
||||
* Copyright (C) 1992-1996, Thomas G. Lane.
|
||||
* Modified 2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -12,7 +13,7 @@
|
||||
* This is very portable in the sense that it'll compile on almost anything,
|
||||
* but you'd better have lots of main memory (or virtual memory) if you want
|
||||
* to process big images.
|
||||
* Note that the max_memory_to_use option is ignored by this implementation.
|
||||
* Note that the max_memory_to_use option is respected by this implementation.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
@@ -66,13 +67,16 @@ jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
|
||||
|
||||
/*
|
||||
* This routine computes the total memory space available for allocation.
|
||||
* Here we always say, "we got all you want bud!"
|
||||
*/
|
||||
|
||||
GLOBAL(long)
|
||||
jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
|
||||
long max_bytes_needed, long already_allocated)
|
||||
{
|
||||
if (cinfo->mem->max_memory_to_use)
|
||||
return cinfo->mem->max_memory_to_use - already_allocated;
|
||||
|
||||
/* Here we say, "we got all you want bud!" */
|
||||
return max_bytes_needed;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+8
-1
@@ -2,7 +2,7 @@
|
||||
* jpegint.h
|
||||
*
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2017 by Guido Vollbeding.
|
||||
* Modified 1997-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -302,6 +302,13 @@ struct jpeg_color_quantizer {
|
||||
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||
#endif
|
||||
|
||||
/* Descale and correctly round an INT32 value that's scaled by N bits.
|
||||
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
|
||||
* the fudge factor is correct for either sign of X.
|
||||
*/
|
||||
|
||||
#define DESCALE(x,n) RIGHT_SHIFT((x) + ((INT32) 1 << ((n)-1)), n)
|
||||
|
||||
|
||||
/* Short forms of external names for systems with brain-damaged linkers. */
|
||||
|
||||
|
||||
Vendored
+7
-4
@@ -2,7 +2,7 @@
|
||||
* jpeglib.h
|
||||
*
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2002-2017 by Guido Vollbeding.
|
||||
* Modified 2002-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -39,7 +39,7 @@ extern "C" {
|
||||
|
||||
#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
|
||||
#define JPEG_LIB_VERSION_MAJOR 9
|
||||
#define JPEG_LIB_VERSION_MINOR 3
|
||||
#define JPEG_LIB_VERSION_MINOR 4
|
||||
|
||||
|
||||
/* Various constants determining the sizes of things.
|
||||
@@ -909,6 +909,7 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
|
||||
#define jpeg_suppress_tables jSuppressTables
|
||||
#define jpeg_alloc_quant_table jAlcQTable
|
||||
#define jpeg_alloc_huff_table jAlcHTable
|
||||
#define jpeg_std_huff_table jStdHTable
|
||||
#define jpeg_start_compress jStrtCompress
|
||||
#define jpeg_write_scanlines jWrtScanlines
|
||||
#define jpeg_finish_compress jFinCompress
|
||||
@@ -977,10 +978,10 @@ EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
|
||||
/* Data source and destination managers: memory buffers. */
|
||||
EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
|
||||
unsigned char ** outbuffer,
|
||||
unsigned long * outsize));
|
||||
size_t * outsize));
|
||||
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
|
||||
const unsigned char * inbuffer,
|
||||
unsigned long insize));
|
||||
size_t insize));
|
||||
|
||||
/* Default parameter setup for compression */
|
||||
EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
|
||||
@@ -1005,6 +1006,8 @@ EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,
|
||||
boolean suppress));
|
||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo));
|
||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo));
|
||||
EXTERN(JHUFF_TBL *) jpeg_std_huff_table JPP((j_common_ptr cinfo,
|
||||
boolean isDC, int tblno));
|
||||
|
||||
/* Main entry points for compression */
|
||||
EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo,
|
||||
|
||||
Vendored
+3
-3
@@ -2,7 +2,7 @@
|
||||
* jutils.c
|
||||
*
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* Modified 2009-2011 by Guido Vollbeding.
|
||||
* Modified 2009-2019 by Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -185,7 +185,7 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
#ifdef FMEMCOPY
|
||||
register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE));
|
||||
register size_t count = (size_t) num_cols * SIZEOF(JSAMPLE);
|
||||
#else
|
||||
register JDIMENSION count;
|
||||
#endif
|
||||
@@ -213,7 +213,7 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||
/* Copy a row of coefficient blocks from one place to another. */
|
||||
{
|
||||
#ifdef FMEMCOPY
|
||||
FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));
|
||||
FMEMCOPY(output_row, input_row, (size_t) num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));
|
||||
#else
|
||||
register JCOEFPTR inptr, outptr;
|
||||
register long count;
|
||||
|
||||
Vendored
+3
-3
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jversion.h
|
||||
*
|
||||
* Copyright (C) 1991-2018, Thomas G. Lane, Guido Vollbeding.
|
||||
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -9,6 +9,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#define JVERSION "9c 14-Jan-2018"
|
||||
#define JVERSION "9d 12-Jan-2020"
|
||||
|
||||
#define JCOPYRIGHT "Copyright (C) 2018, Thomas G. Lane, Guido Vollbeding"
|
||||
#define JCOPYRIGHT "Copyright (C) 2020, Thomas G. Lane, Guido Vollbeding"
|
||||
|
||||
Vendored
+2
-2
@@ -74,7 +74,7 @@ if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif(MSVC)
|
||||
|
||||
add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
add_library(${PNG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
|
||||
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES})
|
||||
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wundef -Wcast-align -Wimplicit-fallthrough -Wunused-parameter -Wsign-compare)
|
||||
@@ -92,7 +92,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${PNG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${PNG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(libpng LICENSE README)
|
||||
|
||||
Vendored
+3
-5
@@ -22,7 +22,7 @@
|
||||
# sqfu@openailab.com
|
||||
#
|
||||
|
||||
SET(TENGINE_COMMIT_VERSION "2f3cd86217f3530c8e4a82f3ed5af14c7a4e3943")
|
||||
SET(TENGINE_COMMIT_VERSION "8a4c58e0e05cd850f4bb0936a330edc86dc0e28c")
|
||||
SET(OCV_TENGINE_DIR "${OpenCV_BINARY_DIR}/3rdparty/libtengine")
|
||||
SET(OCV_TENGINE_SOURCE_PATH "${OCV_TENGINE_DIR}/Tengine-${TENGINE_COMMIT_VERSION}")
|
||||
|
||||
@@ -34,7 +34,7 @@ IF(EXISTS "${OCV_TENGINE_SOURCE_PATH}")
|
||||
ELSE()
|
||||
SET(OCV_TENGINE_FILENAME "${TENGINE_COMMIT_VERSION}.zip")#name2
|
||||
SET(OCV_TENGINE_URL "https://github.com/OAID/Tengine/archive/") #url2
|
||||
SET(tengine_md5sum 9124324b6e2b350012e46ae1db4bad7d) #md5sum2
|
||||
SET(tengine_md5sum f51ca8f3963faeeff3f019a6f6edc206) #md5sum2
|
||||
|
||||
#MESSAGE(STATUS "**** TENGINE DOWNLOAD BEGIN ****")
|
||||
ocv_download(FILENAME ${OCV_TENGINE_FILENAME}
|
||||
@@ -69,7 +69,6 @@ if(BUILD_TENGINE)
|
||||
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
|
||||
SET(CONFIG_ARCH_ARM64 ON)
|
||||
endif()
|
||||
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
|
||||
else()
|
||||
# linux system
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
|
||||
@@ -77,7 +76,6 @@ if(BUILD_TENGINE)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) ## AARCH64
|
||||
SET(CONFIG_ARCH_ARM64 ON)
|
||||
endif()
|
||||
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
SET(BUILT_IN_OPENCV ON) ## set for tengine compile discern .
|
||||
@@ -86,6 +84,6 @@ if(BUILD_TENGINE)
|
||||
add_subdirectory("${OCV_TENGINE_SOURCE_PATH}" "${OCV_TENGINE_DIR}/build")
|
||||
else()
|
||||
message(WARNING "TENGINE: Missing 'CMakeLists.txt' in source code package: ${OCV_TENGINE_SOURCE_PATH}")
|
||||
SET(HAVE_TENGINE 1)
|
||||
endif()
|
||||
SET(Tengine_LIB "tengine" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
Vendored
+5
-2
@@ -239,6 +239,9 @@ if(HOST_BIG_ENDIAN)
|
||||
else()
|
||||
set(HOST_BIG_ENDIAN 0)
|
||||
endif()
|
||||
if(HOST_BIG_ENDIAN)
|
||||
add_definitions(-DWORDS_BIGENDIAN)
|
||||
endif()
|
||||
|
||||
# IEEE floating point
|
||||
set(HAVE_IEEEFP 1 CACHE STRING "IEEE floating point is available")
|
||||
@@ -462,7 +465,7 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4456 /wd4457 /wd4312) # vs2015
|
||||
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS /wd4267 /wd4244 /wd4018 /wd4311 /wd4312)
|
||||
|
||||
add_library(${TIFF_LIBRARY} STATIC ${lib_srcs})
|
||||
add_library(${TIFF_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs})
|
||||
target_link_libraries(${TIFF_LIBRARY} ${ZLIB_LIBRARIES})
|
||||
|
||||
set_target_properties(${TIFF_LIBRARY}
|
||||
@@ -479,7 +482,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${TIFF_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${TIFF_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(libtiff COPYRIGHT)
|
||||
|
||||
Vendored
+2326
File diff suppressed because it is too large
Load Diff
Vendored
+8
-4
@@ -24,6 +24,10 @@
|
||||
#ifndef _LIBPORT_
|
||||
#define _LIBPORT_
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
# include <tif_config.h>
|
||||
#endif
|
||||
|
||||
int getopt(int argc, char * const argv[], const char *optstring);
|
||||
extern char *optarg;
|
||||
extern int opterr;
|
||||
@@ -36,16 +40,16 @@ int strcasecmp(const char *s1, const char *s2);
|
||||
# define HAVE_GETOPT 1
|
||||
#endif
|
||||
|
||||
#if HAVE_STRTOL
|
||||
#if !defined(HAVE_STRTOL)
|
||||
long strtol(const char *nptr, char **endptr, int base);
|
||||
#endif
|
||||
#if HAVE_STRTOLL
|
||||
#if !defined(HAVE_STRTOLL)
|
||||
long long strtoll(const char *nptr, char **endptr, int base);
|
||||
#endif
|
||||
#if HAVE_STRTOUL
|
||||
#if !defined(HAVE_STRTOUL)
|
||||
unsigned long strtoul(const char *nptr, char **endptr, int base);
|
||||
#endif
|
||||
#if HAVE_STRTOULL
|
||||
#if !defined(HAVE_STRTOULL)
|
||||
unsigned long long strtoull(const char *nptr, char **endptr, int base);
|
||||
#endif
|
||||
|
||||
|
||||
Vendored
+62
-27
@@ -35,27 +35,61 @@
|
||||
uint32
|
||||
_TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where)
|
||||
{
|
||||
uint32 bytes = first * second;
|
||||
|
||||
if (second && bytes / second != first) {
|
||||
if (second && first > TIFF_UINT32_MAX / second) {
|
||||
TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
|
||||
bytes = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
return first * second;
|
||||
}
|
||||
|
||||
uint64
|
||||
_TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where)
|
||||
{
|
||||
uint64 bytes = first * second;
|
||||
|
||||
if (second && bytes / second != first) {
|
||||
if (second && first > TIFF_UINT64_MAX / second) {
|
||||
TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
|
||||
bytes = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
return first * second;
|
||||
}
|
||||
|
||||
tmsize_t
|
||||
_TIFFMultiplySSize(TIFF* tif, tmsize_t first, tmsize_t second, const char* where)
|
||||
{
|
||||
if( first <= 0 || second <= 0 )
|
||||
{
|
||||
if( tif != NULL && where != NULL )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, where,
|
||||
"Invalid argument to _TIFFMultiplySSize() in %s", where);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( first > TIFF_TMSIZE_T_MAX / second )
|
||||
{
|
||||
if( tif != NULL && where != NULL )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, where,
|
||||
"Integer overflow in %s", where);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return first * second;
|
||||
}
|
||||
|
||||
tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64 val, const char* module)
|
||||
{
|
||||
if( val > (uint64)TIFF_TMSIZE_T_MAX )
|
||||
{
|
||||
if( tif != NULL && module != NULL )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return (tmsize_t)val;
|
||||
}
|
||||
|
||||
void*
|
||||
@@ -63,13 +97,14 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer,
|
||||
tmsize_t nmemb, tmsize_t elem_size, const char* what)
|
||||
{
|
||||
void* cp = NULL;
|
||||
tmsize_t bytes = nmemb * elem_size;
|
||||
|
||||
tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL);
|
||||
/*
|
||||
* XXX: Check for integer overflow.
|
||||
* Check for integer overflow.
|
||||
*/
|
||||
if (nmemb && elem_size && bytes / elem_size == nmemb)
|
||||
cp = _TIFFrealloc(buffer, bytes);
|
||||
if (count != 0)
|
||||
{
|
||||
cp = _TIFFrealloc(buffer, count);
|
||||
}
|
||||
|
||||
if (cp == NULL) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
@@ -235,7 +270,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
return (1);
|
||||
case TIFFTAG_EXTRASAMPLES:
|
||||
*va_arg(ap, uint16 *) = td->td_extrasamples;
|
||||
*va_arg(ap, uint16 **) = td->td_sampleinfo;
|
||||
*va_arg(ap, const uint16 **) = td->td_sampleinfo;
|
||||
return (1);
|
||||
case TIFFTAG_MATTEING:
|
||||
*va_arg(ap, uint16 *) =
|
||||
@@ -257,8 +292,8 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
case TIFFTAG_YCBCRCOEFFICIENTS:
|
||||
{
|
||||
/* defaults are from CCIR Recommendation 601-1 */
|
||||
static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
|
||||
*va_arg(ap, float **) = ycbcrcoeffs;
|
||||
static const float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
|
||||
*va_arg(ap, const float **) = ycbcrcoeffs;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_YCBCRSUBSAMPLING:
|
||||
@@ -270,14 +305,14 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
return (1);
|
||||
case TIFFTAG_WHITEPOINT:
|
||||
{
|
||||
static float whitepoint[2];
|
||||
|
||||
/* TIFF 6.0 specification tells that it is no default
|
||||
value for the WhitePoint, but AdobePhotoshop TIFF
|
||||
Technical Note tells that it should be CIE D50. */
|
||||
whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
|
||||
whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
|
||||
*va_arg(ap, float **) = whitepoint;
|
||||
static const float whitepoint[] = {
|
||||
D50_X0 / (D50_X0 + D50_Y0 + D50_Z0),
|
||||
D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)
|
||||
};
|
||||
*va_arg(ap, const float **) = whitepoint;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_TRANSFERFUNCTION:
|
||||
@@ -286,16 +321,16 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag");
|
||||
return (0);
|
||||
}
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[0];
|
||||
*va_arg(ap, const uint16 **) = td->td_transferfunction[0];
|
||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[1];
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[2];
|
||||
*va_arg(ap, const uint16 **) = td->td_transferfunction[1];
|
||||
*va_arg(ap, const uint16 **) = td->td_transferfunction[2];
|
||||
}
|
||||
return (1);
|
||||
case TIFFTAG_REFERENCEBLACKWHITE:
|
||||
if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td))
|
||||
return (0);
|
||||
*va_arg(ap, float **) = td->td_refblackwhite;
|
||||
*va_arg(ap, const float **) = td->td_refblackwhite;
|
||||
return (1);
|
||||
}
|
||||
return 0;
|
||||
|
||||
Vendored
+1
-1
@@ -264,7 +264,7 @@ TIFFGetConfiguredCODECs()
|
||||
return NULL;
|
||||
}
|
||||
codecs = new_codecs;
|
||||
_TIFFmemcpy(codecs + i - 1, cd, sizeof(TIFFCodec));
|
||||
_TIFFmemcpy(codecs + i - 1, cd->info, sizeof(TIFFCodec));
|
||||
i++;
|
||||
}
|
||||
for (c = _TIFFBuiltinCODECS; c->name; c++) {
|
||||
|
||||
Vendored
+79
-28
@@ -29,6 +29,7 @@
|
||||
* (and also some miscellaneous stuff)
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include <float.h> /*--: for Rational2Double */
|
||||
|
||||
/*
|
||||
* These are used in the backwards compatibility code...
|
||||
@@ -46,8 +47,8 @@ setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size)
|
||||
*vpp = 0;
|
||||
}
|
||||
if (vp) {
|
||||
tmsize_t bytes = (tmsize_t)(nmemb * elem_size);
|
||||
if (elem_size && bytes / elem_size == nmemb)
|
||||
tmsize_t bytes = _TIFFMultiplySSize(NULL, nmemb, elem_size, NULL);
|
||||
if (bytes)
|
||||
*vpp = (void*) _TIFFmalloc(bytes);
|
||||
if (*vpp)
|
||||
_TIFFmemcpy(*vpp, vp, bytes);
|
||||
@@ -123,7 +124,7 @@ setExtraSamples(TIFF* tif, va_list ap, uint32* v)
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata,module,
|
||||
"ExtraSamples tag value is changing, "
|
||||
"but TransferFunction was read with a different value. Cancelling it");
|
||||
"but TransferFunction was read with a different value. Canceling it");
|
||||
TIFFClrFieldBit(tif,FIELD_TRANSFERFUNCTION);
|
||||
_TIFFfree(td->td_transferfunction[0]);
|
||||
td->td_transferfunction[0] = NULL;
|
||||
@@ -205,7 +206,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
/*
|
||||
* If the data require post-decoding processing to byte-swap
|
||||
* samples, set it up here. Note that since tags are required
|
||||
* to be ordered, compression code can override this behaviour
|
||||
* to be ordered, compression code can override this behavior
|
||||
* in the setup method if it wants to roll the post decoding
|
||||
* work in with its normal work.
|
||||
*/
|
||||
@@ -275,7 +276,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata,module,
|
||||
"SamplesPerPixel tag value is changing, "
|
||||
"but SMinSampleValue tag was read with a different value. Cancelling it");
|
||||
"but SMinSampleValue tag was read with a different value. Canceling it");
|
||||
TIFFClrFieldBit(tif,FIELD_SMINSAMPLEVALUE);
|
||||
_TIFFfree(td->td_sminsamplevalue);
|
||||
td->td_sminsamplevalue = NULL;
|
||||
@@ -284,7 +285,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata,module,
|
||||
"SamplesPerPixel tag value is changing, "
|
||||
"but SMaxSampleValue tag was read with a different value. Cancelling it");
|
||||
"but SMaxSampleValue tag was read with a different value. Canceling it");
|
||||
TIFFClrFieldBit(tif,FIELD_SMAXSAMPLEVALUE);
|
||||
_TIFFfree(td->td_smaxsamplevalue);
|
||||
td->td_smaxsamplevalue = NULL;
|
||||
@@ -296,7 +297,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata,module,
|
||||
"SamplesPerPixel tag value is changing, "
|
||||
"but TransferFunction was read with a different value. Cancelling it");
|
||||
"but TransferFunction was read with a different value. Canceling it");
|
||||
TIFFClrFieldBit(tif,FIELD_TRANSFERFUNCTION);
|
||||
_TIFFfree(td->td_transferfunction[0]);
|
||||
td->td_transferfunction[0] = NULL;
|
||||
@@ -393,7 +394,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
if (tif->tif_mode != O_RDONLY)
|
||||
goto badvalue32;
|
||||
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Nonstandard tile width %d, convert file", v32);
|
||||
"Nonstandard tile width %u, convert file", v32);
|
||||
}
|
||||
td->td_tilewidth = v32;
|
||||
tif->tif_flags |= TIFF_ISTILED;
|
||||
@@ -404,7 +405,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
if (tif->tif_mode != O_RDONLY)
|
||||
goto badvalue32;
|
||||
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Nonstandard tile length %d, convert file", v32);
|
||||
"Nonstandard tile length %u, convert file", v32);
|
||||
}
|
||||
td->td_tilelength = v32;
|
||||
tif->tif_flags |= TIFF_ISTILED;
|
||||
@@ -559,6 +560,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
* Set custom value ... save a copy of the custom tag value.
|
||||
*/
|
||||
tv_size = _TIFFDataSize(fip->field_type);
|
||||
/*--: Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size. */
|
||||
if (fip->field_type == TIFF_RATIONAL || fip->field_type == TIFF_SRATIONAL) {
|
||||
tv_size = _TIFFSetGetFieldSize(fip->set_field_type);
|
||||
}
|
||||
if (tv_size == 0) {
|
||||
status = 0;
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
@@ -638,6 +643,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
|| fip->field_writecount == TIFF_VARIABLE2
|
||||
|| fip->field_writecount == TIFF_SPP
|
||||
|| tv->count > 1) {
|
||||
/*--: Rational2Double: For Rationals tv_size is set above to 4 or 8 according to fip->set_field_type! */
|
||||
_TIFFmemcpy(tv->value, va_arg(ap, void *),
|
||||
tv->count * tv_size);
|
||||
} else {
|
||||
@@ -698,6 +704,22 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
/*-- Rational2Double: For Rationals tv_size is set above to 4 or 8 according to fip->set_field_type! */
|
||||
{
|
||||
if (tv_size == 8) {
|
||||
double v2 = va_arg(ap, double);
|
||||
_TIFFmemcpy(val, &v2, tv_size);
|
||||
} else {
|
||||
/*-- default should be tv_size == 4 */
|
||||
float v3 = (float)va_arg(ap, double);
|
||||
_TIFFmemcpy(val, &v3, tv_size);
|
||||
/*-- ToDo: After Testing, this should be removed and tv_size==4 should be set as default. */
|
||||
if (tv_size != 4) {
|
||||
TIFFErrorExt(0,"TIFFLib: _TIFFVSetField()", "Rational2Double: .set_field_type in not 4 but %d", tv_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIFF_FLOAT:
|
||||
{
|
||||
float v2 = _TIFFClampDoubleToFloat(va_arg(ap, double));
|
||||
@@ -1011,19 +1033,19 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
*va_arg(ap, uint16*) = td->td_halftonehints[1];
|
||||
break;
|
||||
case TIFFTAG_COLORMAP:
|
||||
*va_arg(ap, uint16**) = td->td_colormap[0];
|
||||
*va_arg(ap, uint16**) = td->td_colormap[1];
|
||||
*va_arg(ap, uint16**) = td->td_colormap[2];
|
||||
*va_arg(ap, const uint16**) = td->td_colormap[0];
|
||||
*va_arg(ap, const uint16**) = td->td_colormap[1];
|
||||
*va_arg(ap, const uint16**) = td->td_colormap[2];
|
||||
break;
|
||||
case TIFFTAG_STRIPOFFSETS:
|
||||
case TIFFTAG_TILEOFFSETS:
|
||||
_TIFFFillStriles( tif );
|
||||
*va_arg(ap, uint64**) = td->td_stripoffset;
|
||||
*va_arg(ap, const uint64**) = td->td_stripoffset_p;
|
||||
break;
|
||||
case TIFFTAG_STRIPBYTECOUNTS:
|
||||
case TIFFTAG_TILEBYTECOUNTS:
|
||||
_TIFFFillStriles( tif );
|
||||
*va_arg(ap, uint64**) = td->td_stripbytecount;
|
||||
*va_arg(ap, const uint64**) = td->td_stripbytecount_p;
|
||||
break;
|
||||
case TIFFTAG_MATTEING:
|
||||
*va_arg(ap, uint16*) =
|
||||
@@ -1032,7 +1054,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
case TIFFTAG_EXTRASAMPLES:
|
||||
*va_arg(ap, uint16*) = td->td_extrasamples;
|
||||
*va_arg(ap, uint16**) = td->td_sampleinfo;
|
||||
*va_arg(ap, const uint16**) = td->td_sampleinfo;
|
||||
break;
|
||||
case TIFFTAG_TILEWIDTH:
|
||||
*va_arg(ap, uint32*) = td->td_tilewidth;
|
||||
@@ -1067,7 +1089,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
case TIFFTAG_SUBIFD:
|
||||
*va_arg(ap, uint16*) = td->td_nsubifd;
|
||||
*va_arg(ap, uint64**) = td->td_subifd;
|
||||
*va_arg(ap, const uint64**) = td->td_subifd;
|
||||
break;
|
||||
case TIFFTAG_YCBCRPOSITIONING:
|
||||
*va_arg(ap, uint16*) = td->td_ycbcrpositioning;
|
||||
@@ -1077,20 +1099,20 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
*va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1];
|
||||
break;
|
||||
case TIFFTAG_TRANSFERFUNCTION:
|
||||
*va_arg(ap, uint16**) = td->td_transferfunction[0];
|
||||
*va_arg(ap, const uint16**) = td->td_transferfunction[0];
|
||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||
*va_arg(ap, uint16**) = td->td_transferfunction[1];
|
||||
*va_arg(ap, uint16**) = td->td_transferfunction[2];
|
||||
*va_arg(ap, const uint16**) = td->td_transferfunction[1];
|
||||
*va_arg(ap, const uint16**) = td->td_transferfunction[2];
|
||||
} else {
|
||||
*va_arg(ap, uint16**) = NULL;
|
||||
*va_arg(ap, uint16**) = NULL;
|
||||
*va_arg(ap, const uint16**) = NULL;
|
||||
*va_arg(ap, const uint16**) = NULL;
|
||||
}
|
||||
break;
|
||||
case TIFFTAG_REFERENCEBLACKWHITE:
|
||||
*va_arg(ap, float**) = td->td_refblackwhite;
|
||||
*va_arg(ap, const float**) = td->td_refblackwhite;
|
||||
break;
|
||||
case TIFFTAG_INKNAMES:
|
||||
*va_arg(ap, char**) = td->td_inknames;
|
||||
*va_arg(ap, const char**) = td->td_inknames;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
@@ -1132,7 +1154,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
*va_arg(ap, uint32*) = (uint32)tv->count;
|
||||
else /* Assume TIFF_VARIABLE */
|
||||
*va_arg(ap, uint16*) = (uint16)tv->count;
|
||||
*va_arg(ap, void **) = tv->value;
|
||||
*va_arg(ap, const void **) = tv->value;
|
||||
ret_val = 1;
|
||||
} else if (fip->field_tag == TIFFTAG_DOTRANGE
|
||||
&& strcmp(fip->field_name,"DotRange") == 0) {
|
||||
@@ -1200,6 +1222,23 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
{
|
||||
/*-- Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size and return value size. */
|
||||
int tv_size = _TIFFSetGetFieldSize(fip->set_field_type);
|
||||
if (tv_size == 8) {
|
||||
*va_arg(ap, double*) = *(double *)val;
|
||||
ret_val = 1;
|
||||
} else {
|
||||
/*-- default should be tv_size == 4 */
|
||||
*va_arg(ap, float*) = *(float *)val;
|
||||
ret_val = 1;
|
||||
/*-- ToDo: After Testing, this should be removed and tv_size==4 should be set as default. */
|
||||
if (tv_size != 4) {
|
||||
TIFFErrorExt(0,"TIFFLib: _TIFFVGetField()", "Rational2Double: .set_field_type in not 4 but %d", tv_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIFF_FLOAT:
|
||||
*va_arg(ap, float*) =
|
||||
*(float *)val;
|
||||
@@ -1282,8 +1321,9 @@ TIFFFreeDirectory(TIFF* tif)
|
||||
CleanupField(td_transferfunction[0]);
|
||||
CleanupField(td_transferfunction[1]);
|
||||
CleanupField(td_transferfunction[2]);
|
||||
CleanupField(td_stripoffset);
|
||||
CleanupField(td_stripbytecount);
|
||||
CleanupField(td_stripoffset_p);
|
||||
CleanupField(td_stripbytecount_p);
|
||||
td->td_stripoffsetbyteallocsize = 0;
|
||||
TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING);
|
||||
TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING);
|
||||
|
||||
@@ -1296,10 +1336,8 @@ TIFFFreeDirectory(TIFF* tif)
|
||||
td->td_customValueCount = 0;
|
||||
CleanupField(td_customValues);
|
||||
|
||||
#if defined(DEFER_STRILE_LOAD)
|
||||
_TIFFmemset( &(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
|
||||
_TIFFmemset( &(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
|
||||
#endif
|
||||
}
|
||||
#undef CleanupField
|
||||
|
||||
@@ -1365,6 +1403,17 @@ TIFFCreateEXIFDirectory(TIFF* tif)
|
||||
return TIFFCreateCustomDirectory(tif, exifFieldArray);
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the EXIF GPS custom directory
|
||||
*/
|
||||
int
|
||||
TIFFCreateGPSDirectory(TIFF* tif)
|
||||
{
|
||||
const TIFFFieldArray* gpsFieldArray;
|
||||
gpsFieldArray = _TIFFGetGpsFields();
|
||||
return TIFFCreateCustomDirectory(tif, gpsFieldArray);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup a default directory structure.
|
||||
*/
|
||||
@@ -1387,7 +1436,9 @@ TIFFDefaultDirectory(TIFF* tif)
|
||||
td->td_tilewidth = 0;
|
||||
td->td_tilelength = 0;
|
||||
td->td_tiledepth = 1;
|
||||
#ifdef STRIPBYTECOUNTSORTED_UNUSED
|
||||
td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
|
||||
#endif
|
||||
td->td_resolutionunit = RESUNIT_INCH;
|
||||
td->td_sampleformat = SAMPLEFORMAT_UINT;
|
||||
td->td_imagedepth = 1;
|
||||
|
||||
Vendored
+10
-4
@@ -58,6 +58,7 @@ typedef struct {
|
||||
uint32 toff_long;
|
||||
uint64 toff_long8;
|
||||
} tdir_offset; /* either offset or the data itself if fits */
|
||||
uint8 tdir_ignore; /* flag status to ignore tag when parsing tags in tif_dirread.c */
|
||||
} TIFFDirEntry;
|
||||
|
||||
/*
|
||||
@@ -97,13 +98,14 @@ typedef struct {
|
||||
* number of striles */
|
||||
uint32 td_stripsperimage;
|
||||
uint32 td_nstrips; /* size of offset & bytecount arrays */
|
||||
uint64* td_stripoffset;
|
||||
uint64* td_stripbytecount;
|
||||
uint64* td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */
|
||||
uint64* td_stripbytecount_p; /* should be accessed with TIFFGetStrileByteCount */
|
||||
uint32 td_stripoffsetbyteallocsize; /* number of elements currently allocated for td_stripoffset/td_stripbytecount. Only used if TIFF_LAZYSTRILELOAD is set */
|
||||
#ifdef STRIPBYTECOUNTSORTED_UNUSED
|
||||
int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
|
||||
#if defined(DEFER_STRILE_LOAD)
|
||||
#endif
|
||||
TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
|
||||
TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
|
||||
#endif
|
||||
uint16 td_nsubifd;
|
||||
uint64* td_subifd;
|
||||
/* YCbCr parameters */
|
||||
@@ -118,6 +120,8 @@ typedef struct {
|
||||
|
||||
int td_customValueCount;
|
||||
TIFFTagValue *td_customValues;
|
||||
|
||||
unsigned char td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */
|
||||
} TIFFDirectory;
|
||||
|
||||
/*
|
||||
@@ -257,6 +261,7 @@ extern "C" {
|
||||
|
||||
extern const TIFFFieldArray* _TIFFGetFields(void);
|
||||
extern const TIFFFieldArray* _TIFFGetExifFields(void);
|
||||
extern const TIFFFieldArray* _TIFFGetGpsFields(void);
|
||||
extern void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* infoarray);
|
||||
extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
|
||||
|
||||
@@ -265,6 +270,7 @@ extern int _TIFFFillStriles(TIFF*);
|
||||
typedef enum {
|
||||
tfiatImage,
|
||||
tfiatExif,
|
||||
tfiatGps, /* EXIF-GPS fields array type */
|
||||
tfiatOther
|
||||
} TIFFFieldArrayType;
|
||||
|
||||
|
||||
Vendored
+207
-37
@@ -47,9 +47,19 @@
|
||||
#endif
|
||||
static const TIFFFieldArray tiffFieldArray;
|
||||
static const TIFFFieldArray exifFieldArray;
|
||||
static const TIFFFieldArray gpsFieldArray;
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
/*--: Rational2Double: --
|
||||
* The Rational2Double upgraded libtiff functionality allows the definition and achievement of true double-precision accuracy
|
||||
* for TIFF tags of RATIONAL type and field_bit=FIELD_CUSTOM using the set_field_type = TIFF_SETGET_DOUBLE.
|
||||
* Unfortunately, that changes the old implemented interface for TIFFGetField().
|
||||
* In order to keep the old TIFFGetField() interface behavior those tags have to be redefined with set_field_type = TIFF_SETGET_FLOAT!
|
||||
*
|
||||
* Rational custom arrays are already defined as _Cxx_FLOAT, thus can stay.
|
||||
*
|
||||
*/
|
||||
|
||||
static const TIFFField
|
||||
tiffFields[] = {
|
||||
@@ -75,12 +85,12 @@ tiffFields[] = {
|
||||
{ TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL },
|
||||
{ TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL },
|
||||
{ TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL },
|
||||
{ TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL },
|
||||
{ TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL },
|
||||
{ TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL },
|
||||
{ TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL },
|
||||
{ TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL },
|
||||
{ TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PageName", NULL },
|
||||
{ TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL },
|
||||
{ TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL },
|
||||
{ TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL },
|
||||
{ TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL },
|
||||
{ TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL },
|
||||
{ TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL },
|
||||
{ TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL },
|
||||
@@ -135,14 +145,18 @@ tiffFields[] = {
|
||||
{ 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_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_CFAPATTERN, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CFAPattern" , NULL},
|
||||
{ TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL },
|
||||
/* end Pixar tags */
|
||||
{ TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL },
|
||||
{ TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, 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_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "EXIFIFDOffset", (TIFFFieldArray*) &exifFieldArray },
|
||||
/*--: EXIFIFD and GPSIFD specified as TIFF_LONG by Aware-Systems and not TIFF_IFD8 as in original LibTiff.
|
||||
* However, for IFD-like tags, libtiff uses the data type TIFF_IFD8 in tiffFields[]-tag definition combined with
|
||||
* a special handling procedure in order to write either a 32-bit value and the TIFF_IFD type-id into ClassicTIFF files
|
||||
* or a 64-bit value and the TIFF_IFD8 type-id into BigTIFF files. */
|
||||
{ TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EXIFIFDOffset", (TIFFFieldArray*) &exifFieldArray },
|
||||
{ TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 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, 1, 0, "GPSIFDOffset", (TIFFFieldArray*) &gpsFieldArray },
|
||||
{ TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL },
|
||||
{ TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL },
|
||||
{ TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL },
|
||||
@@ -163,7 +177,7 @@ tiffFields[] = {
|
||||
{ TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaV", NULL },
|
||||
{ TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "WhiteLevel", NULL },
|
||||
{ TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultScale", NULL },
|
||||
{ TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BestQualityScale", NULL },
|
||||
{ TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BestQualityScale", NULL },
|
||||
{ TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropOrigin", NULL },
|
||||
{ TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropSize", NULL },
|
||||
{ TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix1", NULL },
|
||||
@@ -175,16 +189,16 @@ tiffFields[] = {
|
||||
{ TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AnalogBalance", NULL },
|
||||
{ TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotNeutral", NULL },
|
||||
{ TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AsShotWhiteXY", NULL },
|
||||
{ TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineExposure", NULL },
|
||||
{ TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineNoise", NULL },
|
||||
{ TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineSharpness", NULL },
|
||||
{ TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineExposure", NULL },
|
||||
{ TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineNoise", NULL },
|
||||
{ TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineSharpness", NULL },
|
||||
{ TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BayerGreenSplit", NULL },
|
||||
{ TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LinearResponseLimit", NULL },
|
||||
{ TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LinearResponseLimit", NULL },
|
||||
{ TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL },
|
||||
{ TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LensInfo", NULL },
|
||||
{ TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ChromaBlurRadius", NULL },
|
||||
{ TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AntiAliasStrength", NULL },
|
||||
{ TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ShadowScale", NULL },
|
||||
{ TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ChromaBlurRadius", NULL },
|
||||
{ TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AntiAliasStrength", NULL },
|
||||
{ TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ShadowScale", NULL },
|
||||
{ TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "DNGPrivateData", NULL },
|
||||
{ TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "MakerNoteSafety", NULL },
|
||||
{ TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant1", NULL },
|
||||
@@ -217,47 +231,68 @@ tiffFields[] = {
|
||||
/* begin pseudo tags */
|
||||
};
|
||||
|
||||
/*
|
||||
* EXIF tags (Version 2.31, July 2016 plus version 2.32 May 2019)
|
||||
*/
|
||||
static const TIFFField
|
||||
exifFields[] = {
|
||||
{ EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_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_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL },
|
||||
{ EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL },
|
||||
{ EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL },
|
||||
{ EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpectralSensitivity", NULL },
|
||||
{ EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL },
|
||||
{ EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL },
|
||||
{ EXIFTAG_SENSITIVITYTYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensitivityType", NULL },
|
||||
{ EXIFTAG_STANDARDOUTPUTSENSITIVITY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "StandardOutputSensitivity", NULL },
|
||||
{ EXIFTAG_RECOMMENDEDEXPOSUREINDEX, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RecommendedExposureIndex", NULL },
|
||||
{ EXIFTAG_ISOSPEED, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeed", NULL },
|
||||
{ EXIFTAG_ISOSPEEDLATITUDEYYY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudeyyy", NULL },
|
||||
{ EXIFTAG_ISOSPEEDLATITUDEZZZ, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudezzz", NULL },
|
||||
{ EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL },
|
||||
{ EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL },
|
||||
{ EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL },
|
||||
{ EXIFTAG_OFFSETTIME, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTime", NULL },
|
||||
{ EXIFTAG_OFFSETTIMEORIGINAL, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeOriginal", NULL },
|
||||
{ EXIFTAG_OFFSETTIMEDIGITIZED, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeDigitized", NULL },
|
||||
{ EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL },
|
||||
{ EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL },
|
||||
{ EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL },
|
||||
{ EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL },
|
||||
{ EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL },
|
||||
{ EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL },
|
||||
{ EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL },
|
||||
{ EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL },
|
||||
{ EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL },
|
||||
{ EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL },
|
||||
{ EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL },
|
||||
{ EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL },
|
||||
{ EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL },
|
||||
{ EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL },
|
||||
/*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance!
|
||||
* However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values,
|
||||
* which are not treated within LibTiff!! */
|
||||
{ EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL },
|
||||
{ EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL },
|
||||
{ EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LightSource", NULL },
|
||||
{ EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Flash", NULL },
|
||||
{ EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL },
|
||||
{ EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL },
|
||||
{ EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL },
|
||||
{ EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MakerNote", NULL },
|
||||
{ EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "UserComment", NULL },
|
||||
{ EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL },
|
||||
{ EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL },
|
||||
{ EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL },
|
||||
{ EXIFTAG_TEMPERATURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Temperature", NULL },
|
||||
{ EXIFTAG_HUMIDITY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Humidity", NULL },
|
||||
{ EXIFTAG_PRESSURE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Pressure", NULL },
|
||||
{ EXIFTAG_WATERDEPTH, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WaterDepth", NULL },
|
||||
{ EXIFTAG_ACCELERATION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Acceleration", NULL },
|
||||
{ EXIFTAG_CAMERAELEVATIONANGLE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraElevationAngle", NULL },
|
||||
{ EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL },
|
||||
{ EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL },
|
||||
{ EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL },
|
||||
{ EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL },
|
||||
{ EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL },
|
||||
{ EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL },
|
||||
{ EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL },
|
||||
{ EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SpatialFrequencyResponse", NULL },
|
||||
{ EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL },
|
||||
{ EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL },
|
||||
{ EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL },
|
||||
{ EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL },
|
||||
{ EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL },
|
||||
{ EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL },
|
||||
{ EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL },
|
||||
{ EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL },
|
||||
{ EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL },
|
||||
{ EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FileSource", NULL },
|
||||
{ EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneType", NULL },
|
||||
@@ -265,22 +300,79 @@ exifFields[] = {
|
||||
{ EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL },
|
||||
{ EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL },
|
||||
{ EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL },
|
||||
{ EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL },
|
||||
{ EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL },
|
||||
{ EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL },
|
||||
{ EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL },
|
||||
{ EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL },
|
||||
{ EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL },
|
||||
{ EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Contrast", NULL },
|
||||
{ EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Saturation", NULL },
|
||||
{ EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Sharpness", NULL },
|
||||
{ EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DeviceSettingDescription", NULL },
|
||||
{ EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL },
|
||||
{ EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL }
|
||||
{ EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL },
|
||||
{ EXIFTAG_CAMERAOWNERNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraOwnerName", NULL },
|
||||
{ EXIFTAG_BODYSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BodySerialNumber", NULL },
|
||||
{ EXIFTAG_LENSSPECIFICATION, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSpecification", NULL },
|
||||
{ EXIFTAG_LENSMAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensMake", NULL },
|
||||
{ EXIFTAG_LENSMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensModel", NULL },
|
||||
{ EXIFTAG_LENSSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSerialNumber", NULL },
|
||||
{ EXIFTAG_GAMMA, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Gamma", NULL },
|
||||
{ EXIFTAG_COMPOSITEIMAGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompositeImage", NULL },
|
||||
{ EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SourceImageNumberOfCompositeImage", NULL },
|
||||
{ EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SourceExposureTimesOfCompositeImage", NULL }
|
||||
};
|
||||
/*
|
||||
* EXIF-GPS tags (Version 2.31, July 2016; nothing changed for version 2.32 May 2019)
|
||||
*/
|
||||
|
||||
static TIFFField
|
||||
gpsFields[] = {
|
||||
/* For the GPS tag definitions in gpsFields[] the standard definition for Rationals is TIFF_SETGET_DOUBLE and TIFF_SETGET_C0_FLOAT.
|
||||
*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values can now be written and also read in double precision!
|
||||
* In order to achieve double precision for GPS tags:
|
||||
* Standard definitions for GPSTAG is kept to TIFF_SETGET_DOUBLE
|
||||
* and TIFF_SETGET_C0_FLOAT is changed to TIFF_SETGET_C0_DOUBLE.
|
||||
*/
|
||||
{ GPSTAG_VERSIONID , 4, 4, TIFF_BYTE , 0, TIFF_SETGET_C0_UINT8 , TIFF_SETGET_UINT8 , FIELD_CUSTOM , 1, 0, "VersionID", NULL },
|
||||
{ GPSTAG_LATITUDEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "LatitudeRef", NULL },
|
||||
{ GPSTAG_LATITUDE , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Latitude", NULL },
|
||||
{ GPSTAG_LONGITUDEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "LongitudeRef", NULL },
|
||||
{ GPSTAG_LONGITUDE , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Longitude", NULL },
|
||||
{ GPSTAG_ALTITUDEREF , 1, 1, TIFF_BYTE , 0, TIFF_SETGET_UINT8 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "AltitudeRef", NULL },
|
||||
{ GPSTAG_ALTITUDE , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Altitude", NULL },
|
||||
{ GPSTAG_TIMESTAMP , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "TimeStamp", NULL },
|
||||
{ GPSTAG_SATELLITES , -1, -1, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Satellites", NULL },
|
||||
{ GPSTAG_STATUS , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Status", NULL },
|
||||
{ GPSTAG_MEASUREMODE , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "MeasureMode", NULL },
|
||||
{ GPSTAG_DOP , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DOP", NULL },
|
||||
{ GPSTAG_SPEEDREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "SpeedRef", NULL },
|
||||
{ GPSTAG_SPEED , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Speed", NULL },
|
||||
{ GPSTAG_TRACKREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "TrackRef", NULL },
|
||||
{ GPSTAG_TRACK , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Track", NULL },
|
||||
{ GPSTAG_IMGDIRECTIONREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "ImgDirectionRef", NULL },
|
||||
{ GPSTAG_IMGDIRECTION , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "ImgDirection", NULL },
|
||||
{ GPSTAG_MAPDATUM , -1, -1, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "MapDatum", NULL },
|
||||
{ GPSTAG_DESTLATITUDEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestLatitudeRef", NULL },
|
||||
{ GPSTAG_DESTLATITUDE , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestLatitude", NULL },
|
||||
{ GPSTAG_DESTLONGITUDEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestLongitudeRef", NULL },
|
||||
{ GPSTAG_DESTLONGITUDE , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestLongitude", NULL },
|
||||
{ GPSTAG_DESTBEARINGREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestBearingRef", NULL },
|
||||
{ GPSTAG_DESTBEARING , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestBearing", NULL },
|
||||
{ GPSTAG_DESTDISTANCEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestDistanceRef", NULL },
|
||||
{ GPSTAG_DESTDISTANCE , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestDistance", NULL },
|
||||
{ GPSTAG_PROCESSINGMETHOD , -1, -1, TIFF_UNDEFINED , 0, TIFF_SETGET_C16_UINT8 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 1, "ProcessingMethod", NULL },
|
||||
{ GPSTAG_AREAINFORMATION , -1, -1, TIFF_UNDEFINED , 0, TIFF_SETGET_C16_UINT8 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 1, "AreaInformation", NULL },
|
||||
{ GPSTAG_DATESTAMP , 11, 11, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DateStamp", NULL },
|
||||
{ GPSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, TIFF_SETGET_UINT16 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Differential", NULL },
|
||||
{ GPSTAG_GPSHPOSITIONINGERROR , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "HorizontalPositioningError", NULL }
|
||||
};
|
||||
|
||||
static const TIFFFieldArray
|
||||
tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), (TIFFField*) tiffFields };
|
||||
static const TIFFFieldArray
|
||||
exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), (TIFFField*) exifFields };
|
||||
static const TIFFFieldArray
|
||||
gpsFieldArray = { tfiatGps, 0, TIFFArrayCount(gpsFields), (TIFFField*) gpsFields };
|
||||
|
||||
/*
|
||||
* We have our own local lfind() equivalent to avoid subtle differences
|
||||
@@ -313,6 +405,12 @@ _TIFFGetExifFields(void)
|
||||
return(&exifFieldArray);
|
||||
}
|
||||
|
||||
const TIFFFieldArray*
|
||||
_TIFFGetGpsFields(void)
|
||||
{
|
||||
return(&gpsFieldArray);
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFSetupFields(TIFF* tif, const TIFFFieldArray* fieldarray)
|
||||
{
|
||||
@@ -502,6 +600,82 @@ _TIFFDataSize(TIFFDataType type)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Rational2Double:
|
||||
* Return size of TIFFSetGetFieldType in bytes.
|
||||
*
|
||||
* XXX: TIFF_RATIONAL values for FIELD_CUSTOM are stored internally as 4-byte float.
|
||||
* However, some of them should be stored internally as 8-byte double.
|
||||
* This is now managed by the SetGetField of the tag-definition!
|
||||
*/
|
||||
int
|
||||
_TIFFSetGetFieldSize(TIFFSetGetFieldType setgettype)
|
||||
{
|
||||
switch (setgettype)
|
||||
{
|
||||
case TIFF_SETGET_UNDEFINED:
|
||||
case TIFF_SETGET_ASCII:
|
||||
case TIFF_SETGET_C0_ASCII:
|
||||
case TIFF_SETGET_C16_ASCII:
|
||||
case TIFF_SETGET_C32_ASCII:
|
||||
case TIFF_SETGET_OTHER:
|
||||
return 0;
|
||||
case TIFF_SETGET_UINT8:
|
||||
case TIFF_SETGET_SINT8:
|
||||
case TIFF_SETGET_C0_UINT8:
|
||||
case TIFF_SETGET_C0_SINT8:
|
||||
case TIFF_SETGET_C16_UINT8:
|
||||
case TIFF_SETGET_C16_SINT8:
|
||||
case TIFF_SETGET_C32_UINT8:
|
||||
case TIFF_SETGET_C32_SINT8:
|
||||
return 1;
|
||||
case TIFF_SETGET_UINT16:
|
||||
case TIFF_SETGET_SINT16:
|
||||
case TIFF_SETGET_C0_UINT16:
|
||||
case TIFF_SETGET_C0_SINT16:
|
||||
case TIFF_SETGET_C16_UINT16:
|
||||
case TIFF_SETGET_C16_SINT16:
|
||||
case TIFF_SETGET_C32_UINT16:
|
||||
case TIFF_SETGET_C32_SINT16:
|
||||
return 2;
|
||||
case TIFF_SETGET_INT:
|
||||
case TIFF_SETGET_UINT32:
|
||||
case TIFF_SETGET_SINT32:
|
||||
case TIFF_SETGET_FLOAT:
|
||||
case TIFF_SETGET_UINT16_PAIR:
|
||||
case TIFF_SETGET_C0_UINT32:
|
||||
case TIFF_SETGET_C0_SINT32:
|
||||
case TIFF_SETGET_C0_FLOAT:
|
||||
case TIFF_SETGET_C16_UINT32:
|
||||
case TIFF_SETGET_C16_SINT32:
|
||||
case TIFF_SETGET_C16_FLOAT:
|
||||
case TIFF_SETGET_C32_UINT32:
|
||||
case TIFF_SETGET_C32_SINT32:
|
||||
case TIFF_SETGET_C32_FLOAT:
|
||||
return 4;
|
||||
case TIFF_SETGET_UINT64:
|
||||
case TIFF_SETGET_SINT64:
|
||||
case TIFF_SETGET_DOUBLE:
|
||||
case TIFF_SETGET_IFD8:
|
||||
case TIFF_SETGET_C0_UINT64:
|
||||
case TIFF_SETGET_C0_SINT64:
|
||||
case TIFF_SETGET_C0_DOUBLE:
|
||||
case TIFF_SETGET_C0_IFD8:
|
||||
case TIFF_SETGET_C16_UINT64:
|
||||
case TIFF_SETGET_C16_SINT64:
|
||||
case TIFF_SETGET_C16_DOUBLE:
|
||||
case TIFF_SETGET_C16_IFD8:
|
||||
case TIFF_SETGET_C32_UINT64:
|
||||
case TIFF_SETGET_C32_SINT64:
|
||||
case TIFF_SETGET_C32_DOUBLE:
|
||||
case TIFF_SETGET_C32_IFD8:
|
||||
return 8;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
} /*-- _TIFFSetGetFieldSize --- */
|
||||
|
||||
|
||||
const TIFFField*
|
||||
TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt)
|
||||
{
|
||||
@@ -1062,10 +1236,6 @@ _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag)
|
||||
if (tag == TIFFTAG_LERC_PARAMETERS)
|
||||
return 1;
|
||||
break;
|
||||
case COMPRESSION_WEBP:
|
||||
if (tag == TIFFTAG_PREDICTOR)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Vendored
+852
-359
File diff suppressed because it is too large
Load Diff
Vendored
+786
-55
File diff suppressed because it is too large
Load Diff
Vendored
+86
-28
@@ -73,6 +73,7 @@ typedef struct {
|
||||
int EOLcnt; /* count of EOL codes recognized */
|
||||
TIFFFaxFillFunc fill; /* fill routine */
|
||||
uint32* runs; /* b&w runs for current/previous row */
|
||||
uint32 nruns; /* size of the refruns / curruns arrays */
|
||||
uint32* refruns; /* runs for reference line */
|
||||
uint32* curruns; /* runs for current line */
|
||||
|
||||
@@ -160,7 +161,9 @@ Fax3PreDecode(TIFF* tif, uint16 s)
|
||||
*/
|
||||
sp->bitmap =
|
||||
TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB);
|
||||
sp->curruns = sp->runs;
|
||||
if (sp->refruns) { /* init reference line to white */
|
||||
sp->refruns = sp->runs + sp->nruns;
|
||||
sp->refruns[0] = (uint32) sp->b.rowpixels;
|
||||
sp->refruns[1] = 0;
|
||||
}
|
||||
@@ -218,8 +221,12 @@ Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0)
|
||||
|
||||
#define Nop
|
||||
|
||||
/*
|
||||
/**
|
||||
* Decode the requested amount of G3 1D-encoded data.
|
||||
* @param buf destination buffer
|
||||
* @param occ available bytes in destination buffer
|
||||
* @param s number of planes (ignored)
|
||||
* @returns 1 for success, -1 in case of error
|
||||
*/
|
||||
static int
|
||||
Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
||||
@@ -300,7 +307,9 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
||||
else
|
||||
EXPAND2D(EOF2Da);
|
||||
(*sp->fill)(buf, thisrun, pa, lastx);
|
||||
SETVALUE(0); /* imaginary change for reference */
|
||||
if (pa < thisrun + sp->nruns) {
|
||||
SETVALUE(0); /* imaginary change for reference */
|
||||
}
|
||||
SWAP(uint32*, sp->curruns, sp->refruns);
|
||||
buf += sp->b.rowbytes;
|
||||
occ -= sp->b.rowbytes;
|
||||
@@ -506,7 +515,7 @@ Fax3SetupState(TIFF* tif)
|
||||
int needsRefLine;
|
||||
Fax3CodecState* dsp = (Fax3CodecState*) Fax3State(tif);
|
||||
tmsize_t rowbytes;
|
||||
uint32 rowpixels, nruns;
|
||||
uint32 rowpixels;
|
||||
|
||||
if (td->td_bitspersample != 1) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
@@ -523,6 +532,13 @@ Fax3SetupState(TIFF* tif)
|
||||
rowbytes = TIFFScanlineSize(tif);
|
||||
rowpixels = td->td_imagewidth;
|
||||
}
|
||||
if ((uint64)rowbytes < ((uint64)rowpixels + 7) / 8)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Inconsistent number of bytes per row : rowbytes=%lu rowpixels=%lu",
|
||||
(unsigned long)(rowbytes), (unsigned long)(rowpixels));
|
||||
return (0);
|
||||
}
|
||||
sp->rowbytes = rowbytes;
|
||||
sp->rowpixels = rowpixels;
|
||||
/*
|
||||
@@ -539,26 +555,26 @@ Fax3SetupState(TIFF* tif)
|
||||
TIFFroundup and TIFFSafeMultiply return zero on integer overflow
|
||||
*/
|
||||
dsp->runs=(uint32*) NULL;
|
||||
nruns = TIFFroundup_32(rowpixels,32);
|
||||
dsp->nruns = TIFFroundup_32(rowpixels,32);
|
||||
if (needsRefLine) {
|
||||
nruns = TIFFSafeMultiply(uint32,nruns,2);
|
||||
dsp->nruns = TIFFSafeMultiply(uint32,dsp->nruns,2);
|
||||
}
|
||||
if ((nruns == 0) || (TIFFSafeMultiply(uint32,nruns,2) == 0)) {
|
||||
if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32,dsp->nruns,2) == 0)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Row pixels integer overflow (rowpixels %u)",
|
||||
rowpixels);
|
||||
return (0);
|
||||
}
|
||||
dsp->runs = (uint32*) _TIFFCheckMalloc(tif,
|
||||
TIFFSafeMultiply(uint32,nruns,2),
|
||||
TIFFSafeMultiply(uint32,dsp->nruns,2),
|
||||
sizeof (uint32),
|
||||
"for Group 3/4 run arrays");
|
||||
if (dsp->runs == NULL)
|
||||
return (0);
|
||||
memset( dsp->runs, 0, TIFFSafeMultiply(uint32,nruns,2)*sizeof(uint32));
|
||||
memset( dsp->runs, 0, TIFFSafeMultiply(uint32,dsp->nruns,2)*sizeof(uint32));
|
||||
dsp->curruns = dsp->runs;
|
||||
if (needsRefLine)
|
||||
dsp->refruns = dsp->runs + nruns;
|
||||
dsp->refruns = dsp->runs + dsp->nruns;
|
||||
else
|
||||
dsp->refruns = NULL;
|
||||
if (td->td_compression == COMPRESSION_CCITTFAX3
|
||||
@@ -594,15 +610,19 @@ Fax3SetupState(TIFF* tif)
|
||||
*/
|
||||
|
||||
#define Fax3FlushBits(tif, sp) { \
|
||||
if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \
|
||||
(void) TIFFFlushData1(tif); \
|
||||
if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) { \
|
||||
if( !TIFFFlushData1(tif) ) \
|
||||
return 0; \
|
||||
} \
|
||||
*(tif)->tif_rawcp++ = (uint8) (sp)->data; \
|
||||
(tif)->tif_rawcc++; \
|
||||
(sp)->data = 0, (sp)->bit = 8; \
|
||||
}
|
||||
#define _FlushBits(tif) { \
|
||||
if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \
|
||||
(void) TIFFFlushData1(tif); \
|
||||
if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) { \
|
||||
if( !TIFFFlushData1(tif) ) \
|
||||
return 0; \
|
||||
} \
|
||||
*(tif)->tif_rawcp++ = (uint8) data; \
|
||||
(tif)->tif_rawcc++; \
|
||||
data = 0, bit = 8; \
|
||||
@@ -627,7 +647,7 @@ static const int _msbmask[9] =
|
||||
* the output stream. Values are
|
||||
* assumed to be at most 16 bits.
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length)
|
||||
{
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
@@ -638,6 +658,7 @@ Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length)
|
||||
|
||||
sp->data = data;
|
||||
sp->bit = bit;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -662,7 +683,7 @@ Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length)
|
||||
* appropriate table that holds the make-up and
|
||||
* terminating codes is supplied.
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
putspan(TIFF* tif, int32 span, const tableentry* tab)
|
||||
{
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
@@ -700,6 +721,8 @@ putspan(TIFF* tif, int32 span, const tableentry* tab)
|
||||
|
||||
sp->data = data;
|
||||
sp->bit = bit;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -708,7 +731,7 @@ putspan(TIFF* tif, int32 span, const tableentry* tab)
|
||||
* here. We also handle writing the tag bit for the next
|
||||
* scanline when doing 2d encoding.
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
Fax3PutEOL(TIFF* tif)
|
||||
{
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
@@ -742,6 +765,8 @@ Fax3PutEOL(TIFF* tif)
|
||||
|
||||
sp->data = data;
|
||||
sp->bit = bit;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -991,12 +1016,14 @@ Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32 bits)
|
||||
|
||||
for (;;) {
|
||||
span = find0span(bp, bs, bits); /* white span */
|
||||
putspan(tif, span, TIFFFaxWhiteCodes);
|
||||
if( !putspan(tif, span, TIFFFaxWhiteCodes) )
|
||||
return 0;
|
||||
bs += span;
|
||||
if (bs >= bits)
|
||||
break;
|
||||
span = find1span(bp, bs, bits); /* black span */
|
||||
putspan(tif, span, TIFFFaxBlackCodes);
|
||||
if( !putspan(tif, span, TIFFFaxBlackCodes) )
|
||||
return 0;
|
||||
bs += span;
|
||||
if (bs >= bits)
|
||||
break;
|
||||
@@ -1048,21 +1075,28 @@ Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits)
|
||||
(b1 < a1 && a1 - b1 <= 3U) ? -(int32)(a1 - b1) : 0x7FFFFFFF;
|
||||
if (!(-3 <= d && d <= 3)) { /* horizontal mode */
|
||||
a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1));
|
||||
putcode(tif, &horizcode);
|
||||
if( !putcode(tif, &horizcode) )
|
||||
return 0;
|
||||
if (a0+a1 == 0 || PIXEL(bp, a0) == 0) {
|
||||
putspan(tif, a1-a0, TIFFFaxWhiteCodes);
|
||||
putspan(tif, a2-a1, TIFFFaxBlackCodes);
|
||||
if( !putspan(tif, a1-a0, TIFFFaxWhiteCodes) )
|
||||
return 0;
|
||||
if( !putspan(tif, a2-a1, TIFFFaxBlackCodes) )
|
||||
return 0;
|
||||
} else {
|
||||
putspan(tif, a1-a0, TIFFFaxBlackCodes);
|
||||
putspan(tif, a2-a1, TIFFFaxWhiteCodes);
|
||||
if( !putspan(tif, a1-a0, TIFFFaxBlackCodes) )
|
||||
return 0;
|
||||
if( !putspan(tif, a2-a1, TIFFFaxWhiteCodes) )
|
||||
return 0;
|
||||
}
|
||||
a0 = a2;
|
||||
} else { /* vertical mode */
|
||||
putcode(tif, &vcodes[d+3]);
|
||||
if( !putcode(tif, &vcodes[d+3]) )
|
||||
return 0;
|
||||
a0 = a1;
|
||||
}
|
||||
} else { /* pass mode */
|
||||
putcode(tif, &passcode);
|
||||
if( !putcode(tif, &passcode) )
|
||||
return 0;
|
||||
a0 = b2;
|
||||
}
|
||||
if (a0 >= bits)
|
||||
@@ -1091,7 +1125,10 @@ Fax3Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
}
|
||||
while (cc > 0) {
|
||||
if ((sp->b.mode & FAXMODE_NOEOL) == 0)
|
||||
Fax3PutEOL(tif);
|
||||
{
|
||||
if( !Fax3PutEOL(tif) )
|
||||
return 0;
|
||||
}
|
||||
if (is2DEncoding(sp)) {
|
||||
if (sp->tag == G3_1D) {
|
||||
if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels))
|
||||
@@ -1128,8 +1165,8 @@ Fax3PostEncode(TIFF* tif)
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
Fax3Close(TIFF* tif)
|
||||
static int
|
||||
_Fax3Close(TIFF* tif)
|
||||
{
|
||||
if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0 && tif->tif_rawcp) {
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
@@ -1145,6 +1182,13 @@ Fax3Close(TIFF* tif)
|
||||
Fax3PutBits(tif, code, length);
|
||||
Fax3FlushBits(tif, sp);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
Fax3Close(TIFF* tif)
|
||||
{
|
||||
_Fax3Close(tif);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1453,6 +1497,13 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
||||
EXPAND2D(EOFG4);
|
||||
if (EOLcnt)
|
||||
goto EOFG4;
|
||||
if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Buffer overrun detected : %d bytes available, %d bits needed",
|
||||
(int)occ, lastx);
|
||||
return -1;
|
||||
}
|
||||
(*sp->fill)(buf, thisrun, pa, lastx);
|
||||
SETVALUE(0); /* imaginary change for reference */
|
||||
SWAP(uint32*, sp->curruns, sp->refruns);
|
||||
@@ -1468,6 +1519,13 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
||||
fputs( "Bad EOFB\n", stderr );
|
||||
#endif
|
||||
ClrBits( 13 );
|
||||
if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Buffer overrun detected : %d bytes available, %d bits needed",
|
||||
(int)occ, lastx);
|
||||
return -1;
|
||||
}
|
||||
(*sp->fill)(buf, thisrun, pa, lastx);
|
||||
UNCACHE_STATE(tif, sp);
|
||||
return ( sp->line ? 1 : -1); /* don't error on badly-terminated strips */
|
||||
|
||||
Vendored
+34
-5
@@ -240,6 +240,11 @@ static const char* StateNames[] = {
|
||||
* current row and reset decoding state.
|
||||
*/
|
||||
#define SETVALUE(x) do { \
|
||||
if (pa >= thisrun + sp->nruns) { \
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \
|
||||
sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \
|
||||
return (-1); \
|
||||
} \
|
||||
*pa++ = RunLength + (x); \
|
||||
a0 += (x); \
|
||||
RunLength = 0; \
|
||||
@@ -377,6 +382,11 @@ done1d: \
|
||||
*/
|
||||
#define CHECK_b1 do { \
|
||||
if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \
|
||||
if( pb + 1 >= sp->refruns + sp->nruns) { \
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \
|
||||
sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \
|
||||
return (-1); \
|
||||
} \
|
||||
b1 += pb[0] + pb[1]; \
|
||||
pb += 2; \
|
||||
} \
|
||||
@@ -387,10 +397,20 @@ done1d: \
|
||||
*/
|
||||
#define EXPAND2D(eoflab) do { \
|
||||
while (a0 < lastx) { \
|
||||
if (pa >= thisrun + sp->nruns) { \
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \
|
||||
sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \
|
||||
return (-1); \
|
||||
} \
|
||||
LOOKUP8(7, TIFFFaxMainTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_Pass: \
|
||||
CHECK_b1; \
|
||||
if( pb + 1 >= sp->refruns + sp->nruns) { \
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \
|
||||
sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \
|
||||
return (-1); \
|
||||
} \
|
||||
b1 += *pb++; \
|
||||
RunLength += b1 - a0; \
|
||||
a0 = b1; \
|
||||
@@ -469,20 +489,28 @@ done1d: \
|
||||
case S_V0: \
|
||||
CHECK_b1; \
|
||||
SETVALUE(b1 - a0); \
|
||||
if( pb >= sp->refruns + sp->nruns) { \
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \
|
||||
sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \
|
||||
return (-1); \
|
||||
} \
|
||||
b1 += *pb++; \
|
||||
break; \
|
||||
case S_VR: \
|
||||
CHECK_b1; \
|
||||
SETVALUE(b1 - a0 + TabEnt->Param); \
|
||||
if( pb >= sp->refruns + sp->nruns) { \
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \
|
||||
sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \
|
||||
return (-1); \
|
||||
} \
|
||||
b1 += *pb++; \
|
||||
break; \
|
||||
case S_VL: \
|
||||
CHECK_b1; \
|
||||
if (b1 <= (int) (a0 + TabEnt->Param)) { \
|
||||
if (b1 < (int) (a0 + TabEnt->Param) || pa != thisrun) { \
|
||||
unexpected("VL", a0); \
|
||||
goto eol2d; \
|
||||
} \
|
||||
if (b1 < (int) (a0 + TabEnt->Param)) { \
|
||||
unexpected("VL", a0); \
|
||||
goto eol2d; \
|
||||
} \
|
||||
SETVALUE(b1 - a0 - TabEnt->Param); \
|
||||
b1 -= *--pb; \
|
||||
@@ -529,6 +557,7 @@ eol2d: \
|
||||
CLEANUP_RUNS(); \
|
||||
} while (0)
|
||||
#endif /* _FAX3_ */
|
||||
/* vim: set ts=8 sts=4 sw=4 noet: */
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
|
||||
Vendored
+1
@@ -1,5 +1,6 @@
|
||||
/* WARNING, this file was automatically generated by the
|
||||
mkg3states program */
|
||||
#include <stdint.h>
|
||||
#include "tiff.h"
|
||||
#include "tif_fax3.h"
|
||||
const TIFFFaxTabEnt TIFFFaxMainTable[128] = {
|
||||
|
||||
Vendored
+88
-30
@@ -45,36 +45,8 @@ TIFFFlush(TIFF* tif)
|
||||
&& !(tif->tif_flags & TIFF_DIRTYDIRECT)
|
||||
&& tif->tif_mode == O_RDWR )
|
||||
{
|
||||
uint64 *offsets=NULL, *sizes=NULL;
|
||||
|
||||
if( TIFFIsTiled(tif) )
|
||||
{
|
||||
if( TIFFGetField( tif, TIFFTAG_TILEOFFSETS, &offsets )
|
||||
&& TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &sizes )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_TILEOFFSETS, TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips, offsets )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_TILEBYTECOUNTS, TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips, sizes ) )
|
||||
{
|
||||
tif->tif_flags &= ~TIFF_DIRTYSTRIP;
|
||||
tif->tif_flags &= ~TIFF_BEENWRITING;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &offsets )
|
||||
&& TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &sizes )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips, offsets )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips, sizes ) )
|
||||
{
|
||||
tif->tif_flags &= ~TIFF_DIRTYSTRIP;
|
||||
tif->tif_flags &= ~TIFF_BEENWRITING;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if( TIFFForceStrileArrayWriting(tif) )
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP))
|
||||
@@ -84,6 +56,92 @@ TIFFFlush(TIFF* tif)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is an advanced writing function that must be used in a particular
|
||||
* sequence, and together with TIFFDeferStrileArrayWriting(),
|
||||
* to make its intended effect. Its aim is to force the writing of
|
||||
* the [Strip/Tile][Offsets/ByteCounts] arrays at the end of the file, when
|
||||
* they have not yet been rewritten.
|
||||
*
|
||||
* The typical sequence of calls is:
|
||||
* TIFFOpen()
|
||||
* [ TIFFCreateDirectory(tif) ]
|
||||
* Set fields with calls to TIFFSetField(tif, ...)
|
||||
* TIFFDeferStrileArrayWriting(tif)
|
||||
* TIFFWriteCheck(tif, ...)
|
||||
* TIFFWriteDirectory(tif)
|
||||
* ... potentially create other directories and come back to the above directory
|
||||
* TIFFForceStrileArrayWriting(tif)
|
||||
*
|
||||
* Returns 1 in case of success, 0 otherwise.
|
||||
*/
|
||||
int TIFFForceStrileArrayWriting(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFForceStrileArrayWriting";
|
||||
const int isTiled = TIFFIsTiled(tif);
|
||||
|
||||
if (tif->tif_mode == O_RDONLY)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"File opened in read-only mode");
|
||||
return 0;
|
||||
}
|
||||
if( tif->tif_diroff == 0 )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Directory has not yet been written");
|
||||
return 0;
|
||||
}
|
||||
if( (tif->tif_flags & TIFF_DIRTYDIRECT) != 0 )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Directory has changes other than the strile arrays. "
|
||||
"TIFFRewriteDirectory() should be called instead");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !(tif->tif_flags & TIFF_DIRTYSTRIP) )
|
||||
{
|
||||
if( !(tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
|
||||
tif->tif_dir.td_stripoffset_entry.tdir_count == 0 &&
|
||||
tif->tif_dir.td_stripoffset_entry.tdir_type == 0 &&
|
||||
tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 &&
|
||||
tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 &&
|
||||
tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 &&
|
||||
tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 &&
|
||||
tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0) )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Function not called together with "
|
||||
"TIFFDeferStrileArrayWriting()");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tif->tif_dir.td_stripoffset_p == NULL && !TIFFSetupStrips(tif))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( _TIFFRewriteField( tif,
|
||||
isTiled ? TIFFTAG_TILEOFFSETS :
|
||||
TIFFTAG_STRIPOFFSETS,
|
||||
TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips,
|
||||
tif->tif_dir.td_stripoffset_p )
|
||||
&& _TIFFRewriteField( tif,
|
||||
isTiled ? TIFFTAG_TILEBYTECOUNTS :
|
||||
TIFFTAG_STRIPBYTECOUNTS,
|
||||
TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips,
|
||||
tif->tif_dir.td_stripbytecount_p ) )
|
||||
{
|
||||
tif->tif_flags &= ~TIFF_DIRTYSTRIP;
|
||||
tif->tif_flags &= ~TIFF_BEENWRITING;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush buffered data to the file.
|
||||
*
|
||||
|
||||
Vendored
+52
-15
@@ -29,6 +29,7 @@
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32);
|
||||
static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32);
|
||||
@@ -645,12 +646,20 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
|
||||
flip = setorientation(img);
|
||||
if (flip & FLIP_VERTICALLY) {
|
||||
y = h - 1;
|
||||
toskew = -(int32)(tw + w);
|
||||
if ((tw + w) > INT_MAX) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)");
|
||||
return (0);
|
||||
}
|
||||
y = h - 1;
|
||||
toskew = -(int32)(tw + w);
|
||||
}
|
||||
else {
|
||||
y = 0;
|
||||
toskew = -(int32)(tw - w);
|
||||
if (tw > (INT_MAX + w)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)");
|
||||
return (0);
|
||||
}
|
||||
y = 0;
|
||||
toskew = -(int32)(tw - w);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -755,9 +764,8 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
uint32 leftmost_tw;
|
||||
|
||||
tilesize = TIFFTileSize(tif);
|
||||
bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,tilesize);
|
||||
bufsize = _TIFFMultiplySSize(tif, alpha?4:3,tilesize, "gtTileSeparate");
|
||||
if (bufsize == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtTileSeparate");
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -766,10 +774,18 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
|
||||
flip = setorientation(img);
|
||||
if (flip & FLIP_VERTICALLY) {
|
||||
if ((tw + w) > INT_MAX) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)");
|
||||
return (0);
|
||||
}
|
||||
y = h - 1;
|
||||
toskew = -(int32)(tw + w);
|
||||
}
|
||||
else {
|
||||
if (tw > (INT_MAX + w)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)");
|
||||
return (0);
|
||||
}
|
||||
y = 0;
|
||||
toskew = -(int32)(tw - w);
|
||||
}
|
||||
@@ -937,6 +953,10 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
|
||||
flip = setorientation(img);
|
||||
if (flip & FLIP_VERTICALLY) {
|
||||
if ( w > INT_MAX ) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Width overflow");
|
||||
return (0);
|
||||
}
|
||||
y = h - 1;
|
||||
toskew = -(int32)(w + w);
|
||||
} else {
|
||||
@@ -950,16 +970,23 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0);
|
||||
for (row = 0; row < h; row += nrow)
|
||||
{
|
||||
uint32 temp;
|
||||
rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;
|
||||
nrow = (row + rowstoread > h ? h - row : rowstoread);
|
||||
nrowsub = nrow;
|
||||
if ((nrowsub%subsamplingver)!=0)
|
||||
nrowsub+=subsamplingver-nrowsub%subsamplingver;
|
||||
temp = (row + img->row_offset)%rowsperstrip + nrowsub;
|
||||
if( scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline) )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in gtStripContig");
|
||||
return 0;
|
||||
}
|
||||
if (_TIFFReadEncodedStripAndAllocBuffer(tif,
|
||||
TIFFComputeStrip(tif,row+img->row_offset, 0),
|
||||
(void**)(&buf),
|
||||
maxstripsize,
|
||||
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline)==(tmsize_t)(-1)
|
||||
temp * scanline)==(tmsize_t)(-1)
|
||||
&& (buf == NULL || img->stoponerr))
|
||||
{
|
||||
ret = 0;
|
||||
@@ -1019,14 +1046,17 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
uint16 colorchannels;
|
||||
|
||||
stripsize = TIFFStripSize(tif);
|
||||
bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,stripsize);
|
||||
bufsize = _TIFFMultiplySSize(tif,alpha?4:3,stripsize, "gtStripSeparate");
|
||||
if (bufsize == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtStripSeparate");
|
||||
return (0);
|
||||
}
|
||||
|
||||
flip = setorientation(img);
|
||||
if (flip & FLIP_VERTICALLY) {
|
||||
if ( w > INT_MAX ) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Width overflow");
|
||||
return (0);
|
||||
}
|
||||
y = h - 1;
|
||||
toskew = -(int32)(w + w);
|
||||
}
|
||||
@@ -1053,15 +1083,22 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0);
|
||||
for (row = 0; row < h; row += nrow)
|
||||
{
|
||||
uint32 temp;
|
||||
rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;
|
||||
nrow = (row + rowstoread > h ? h - row : rowstoread);
|
||||
offset_row = row + img->row_offset;
|
||||
temp = (row + img->row_offset)%rowsperstrip + nrow;
|
||||
if( scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline) )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in gtStripSeparate");
|
||||
return 0;
|
||||
}
|
||||
if( buf == NULL )
|
||||
{
|
||||
if (_TIFFReadEncodedStripAndAllocBuffer(
|
||||
tif, TIFFComputeStrip(tif, offset_row, 0),
|
||||
(void**) &buf, bufsize,
|
||||
((row + img->row_offset)%rowsperstrip + nrow) * scanline)==(tmsize_t)(-1)
|
||||
temp * scanline)==(tmsize_t)(-1)
|
||||
&& (buf == NULL || img->stoponerr))
|
||||
{
|
||||
ret = 0;
|
||||
@@ -1081,7 +1118,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
}
|
||||
}
|
||||
else if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0),
|
||||
p0, ((row + img->row_offset)%rowsperstrip + nrow) * scanline)==(tmsize_t)(-1)
|
||||
p0, temp * scanline)==(tmsize_t)(-1)
|
||||
&& img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
@@ -1089,7 +1126,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
}
|
||||
if (colorchannels > 1
|
||||
&& TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1),
|
||||
p1, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) == (tmsize_t)(-1)
|
||||
p1, temp * scanline) == (tmsize_t)(-1)
|
||||
&& img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
@@ -1097,7 +1134,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
}
|
||||
if (colorchannels > 1
|
||||
&& TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2),
|
||||
p2, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) == (tmsize_t)(-1)
|
||||
p2, temp * scanline) == (tmsize_t)(-1)
|
||||
&& img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
@@ -1106,7 +1143,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
if (alpha)
|
||||
{
|
||||
if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, colorchannels),
|
||||
pa, ((row + img->row_offset)%rowsperstrip + nrow) * scanline)==(tmsize_t)(-1)
|
||||
pa, temp * scanline)==(tmsize_t)(-1)
|
||||
&& img->stoponerr)
|
||||
{
|
||||
ret = 0;
|
||||
@@ -2957,7 +2994,7 @@ TIFFReadRGBATileExt(TIFF* tif, uint32 col, uint32 row, uint32 * raster, int stop
|
||||
if( !TIFFIsTiled( tif ) )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif),
|
||||
"Can't use TIFFReadRGBATile() with stripped file.");
|
||||
"Can't use TIFFReadRGBATile() with striped file.");
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
@@ -199,6 +199,7 @@ static int JBIGEncode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)
|
||||
|
||||
int TIFFInitJBIG(TIFF* tif, int scheme)
|
||||
{
|
||||
(void)scheme;
|
||||
assert(scheme == COMPRESSION_JBIG);
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+42
-38
@@ -466,7 +466,8 @@ std_empty_output_buffer(j_compress_ptr cinfo)
|
||||
}
|
||||
#endif
|
||||
|
||||
TIFFFlushData1(tif);
|
||||
if( !TIFFFlushData1(tif) )
|
||||
return FALSE;
|
||||
sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata;
|
||||
sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize;
|
||||
|
||||
@@ -780,12 +781,9 @@ JPEGFixupTagsSubsampling(TIFF* tif)
|
||||
*/
|
||||
static const char module[] = "JPEGFixupTagsSubsampling";
|
||||
struct JPEGFixupTagsSubsamplingData m;
|
||||
uint64 fileoffset = TIFFGetStrileOffset(tif, 0);
|
||||
|
||||
_TIFFFillStriles( tif );
|
||||
|
||||
if( tif->tif_dir.td_stripbytecount == NULL
|
||||
|| tif->tif_dir.td_stripoffset == NULL
|
||||
|| tif->tif_dir.td_stripbytecount[0] == 0 )
|
||||
if( fileoffset == 0 )
|
||||
{
|
||||
/* Do not even try to check if the first strip/tile does not
|
||||
yet exist, as occurs when GDAL has created a new NULL file
|
||||
@@ -804,9 +802,9 @@ JPEGFixupTagsSubsampling(TIFF* tif)
|
||||
}
|
||||
m.buffercurrentbyte=NULL;
|
||||
m.bufferbytesleft=0;
|
||||
m.fileoffset=tif->tif_dir.td_stripoffset[0];
|
||||
m.fileoffset=fileoffset;
|
||||
m.filepositioned=0;
|
||||
m.filebytesleft=tif->tif_dir.td_stripbytecount[0];
|
||||
m.filebytesleft=TIFFGetStrileByteCount(tif, 0);
|
||||
if (!JPEGFixupTagsSubsamplingSec(&m))
|
||||
TIFFWarningExt(tif->tif_clientdata,module,
|
||||
"Unable to auto-correct subsampling values, likely corrupt JPEG compressed data in first strip/tile; auto-correcting skipped");
|
||||
@@ -940,7 +938,10 @@ JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint
|
||||
return(0);
|
||||
if (!data->filepositioned)
|
||||
{
|
||||
TIFFSeekFile(data->tif,data->fileoffset,SEEK_SET);
|
||||
if (TIFFSeekFile(data->tif,data->fileoffset,SEEK_SET) == (toff_t)-1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
data->filepositioned=1;
|
||||
}
|
||||
m=data->buffersize;
|
||||
@@ -1209,35 +1210,37 @@ JPEGPreDecode(TIFF* tif, uint16 s)
|
||||
/* store for all coefficients */
|
||||
/* See call to jinit_d_coef_controller() from master_selection() */
|
||||
/* in libjpeg */
|
||||
toff_t nRequiredMemory = (toff_t)sp->cinfo.d.image_width *
|
||||
sp->cinfo.d.image_height *
|
||||
sp->cinfo.d.num_components *
|
||||
((td->td_bitspersample+7)/8);
|
||||
/* BLOCK_SMOOTHING_SUPPORTED is generally defined, so we need */
|
||||
/* to replicate the logic of jinit_d_coef_controller() */
|
||||
if( sp->cinfo.d.progressive_mode )
|
||||
nRequiredMemory *= 3;
|
||||
|
||||
#ifndef TIFF_LIBJPEG_LARGEST_MEM_ALLOC
|
||||
#define TIFF_LIBJPEG_LARGEST_MEM_ALLOC (100 * 1024 * 1024)
|
||||
#endif
|
||||
/* 1 MB for regular libjpeg usage */
|
||||
toff_t nRequiredMemory = 1024 * 1024;
|
||||
|
||||
if( nRequiredMemory > TIFF_LIBJPEG_LARGEST_MEM_ALLOC &&
|
||||
for (ci = 0; ci < sp->cinfo.d.num_components; ci++) {
|
||||
const jpeg_component_info *compptr = &(sp->cinfo.d.comp_info[ci]);
|
||||
if( compptr->h_samp_factor > 0 && compptr->v_samp_factor > 0 )
|
||||
{
|
||||
nRequiredMemory += (toff_t)(
|
||||
((compptr->width_in_blocks + compptr->h_samp_factor - 1) / compptr->h_samp_factor)) *
|
||||
((compptr->height_in_blocks + compptr->v_samp_factor - 1) / compptr->v_samp_factor) *
|
||||
sizeof(JBLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
if( sp->cinfo.d.mem->max_memory_to_use > 0 &&
|
||||
nRequiredMemory > (toff_t)(sp->cinfo.d.mem->max_memory_to_use) &&
|
||||
getenv("LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC") == NULL )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Reading this strip would require libjpeg to allocate "
|
||||
"at least %u bytes. "
|
||||
"This is disabled since above the %u threshold. "
|
||||
"You may override this restriction by defining the "
|
||||
"LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, "
|
||||
"or recompile libtiff by defining the "
|
||||
"TIFF_LIBJPEG_LARGEST_MEM_ALLOC macro to a value greater "
|
||||
"than %u",
|
||||
(unsigned)nRequiredMemory,
|
||||
(unsigned)TIFF_LIBJPEG_LARGEST_MEM_ALLOC,
|
||||
(unsigned)TIFF_LIBJPEG_LARGEST_MEM_ALLOC);
|
||||
return (0);
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Reading this image would require libjpeg to allocate "
|
||||
"at least %u bytes. "
|
||||
"This is disabled since above the %u threshold. "
|
||||
"You may override this restriction by defining the "
|
||||
"LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, "
|
||||
"or setting the JPEGMEM environment variable to a value greater "
|
||||
"or equal to '%uM'",
|
||||
(unsigned)(nRequiredMemory),
|
||||
(unsigned)(sp->cinfo.d.mem->max_memory_to_use),
|
||||
(unsigned)((nRequiredMemory + 1000000 - 1) / 1000000));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1566,7 +1569,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset;
|
||||
#else
|
||||
JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset;
|
||||
if (cc < (tmsize_t) (clumpoffset + samples_per_clump*(clumps_per_line-1) + hsamp)) {
|
||||
if (cc < (tmsize_t)(clumpoffset + (tmsize_t)samples_per_clump*(clumps_per_line-1) + hsamp)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
|
||||
"application buffer not large enough for all data, possible subsampling issue");
|
||||
return 0;
|
||||
@@ -2126,8 +2129,8 @@ JPEGEncodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
/* data is expected to be supplied in multiples of a clumpline */
|
||||
/* a clumpline is equivalent to v_sampling desubsampled scanlines */
|
||||
/* TODO: the following calculation of bytesperclumpline, should substitute calculation of sp->bytesperline, except that it is per v_sampling lines */
|
||||
bytesperclumpline = (((sp->cinfo.c.image_width+sp->h_sampling-1)/sp->h_sampling)
|
||||
*(sp->h_sampling*sp->v_sampling+2)*sp->cinfo.c.data_precision+7)
|
||||
bytesperclumpline = ((((tmsize_t)sp->cinfo.c.image_width+sp->h_sampling-1)/sp->h_sampling)
|
||||
*((tmsize_t)sp->h_sampling*sp->v_sampling+2)*sp->cinfo.c.data_precision+7)
|
||||
/8;
|
||||
|
||||
nrows = ( cc / bytesperclumpline ) * sp->v_sampling;
|
||||
@@ -2347,7 +2350,7 @@ JPEGVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
switch (tag) {
|
||||
case TIFFTAG_JPEGTABLES:
|
||||
*va_arg(ap, uint32*) = sp->jpegtables_length;
|
||||
*va_arg(ap, void**) = sp->jpegtables;
|
||||
*va_arg(ap, const void**) = sp->jpegtables;
|
||||
break;
|
||||
case TIFFTAG_JPEGQUALITY:
|
||||
*va_arg(ap, int*) = sp->jpegquality;
|
||||
@@ -2482,6 +2485,7 @@ TIFFInitJPEG(TIFF* tif, int scheme)
|
||||
{
|
||||
JPEGState* sp;
|
||||
|
||||
(void)scheme;
|
||||
assert(scheme == COMPRESSION_JPEG);
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+21
-21
@@ -193,6 +193,7 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
|
||||
tmsize_t cc;
|
||||
int rc;
|
||||
|
||||
(void)s;
|
||||
assert(s == 0);
|
||||
assert(sp != NULL);
|
||||
|
||||
@@ -266,6 +267,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
|
||||
unsigned char* bp;
|
||||
uint32* tp;
|
||||
|
||||
(void)s;
|
||||
assert(s == 0);
|
||||
assert(sp != NULL);
|
||||
|
||||
@@ -326,6 +328,7 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
|
||||
tmsize_t cc;
|
||||
int rc;
|
||||
|
||||
(void)s;
|
||||
assert(s == 0);
|
||||
sp = DecoderState(tif);
|
||||
assert(sp != NULL);
|
||||
@@ -447,6 +450,7 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
int rc=0, mask;
|
||||
tmsize_t beg;
|
||||
|
||||
(void)s;
|
||||
assert(s == 0);
|
||||
assert(sp != NULL);
|
||||
npixels = cc / sp->pixel_size;
|
||||
@@ -541,6 +545,7 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
uint8* op;
|
||||
uint32* tp;
|
||||
|
||||
(void)s;
|
||||
assert(s == 0);
|
||||
assert(sp != NULL);
|
||||
npixels = cc / sp->pixel_size;
|
||||
@@ -598,6 +603,7 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
int rc=0, mask;
|
||||
tmsize_t beg;
|
||||
|
||||
(void)s;
|
||||
assert(s == 0);
|
||||
assert(sp != NULL);
|
||||
|
||||
@@ -742,7 +748,7 @@ LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
#undef exp2 /* Conflict with C'99 function */
|
||||
#define exp2(x) exp(M_LN2*(x))
|
||||
|
||||
static int itrunc(double x, int m)
|
||||
static int tiff_itrunc(double x, int m)
|
||||
{
|
||||
if( m == SGILOGENCODE_NODITHER )
|
||||
return (int)x;
|
||||
@@ -777,9 +783,9 @@ LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */
|
||||
if (Y <= -1.8371976e19)
|
||||
return (0xffff);
|
||||
if (Y > 5.4136769e-20)
|
||||
return itrunc(256.*(log2(Y) + 64.), em);
|
||||
return tiff_itrunc(256.*(log2(Y) + 64.), em);
|
||||
if (Y < -5.4136769e-20)
|
||||
return (~0x7fff | itrunc(256.*(log2(-Y) + 64.), em));
|
||||
return (~0x7fff | tiff_itrunc(256.*(log2(-Y) + 64.), em));
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -855,7 +861,7 @@ LogL10fromY(double Y, int em) /* get 10-bit LogL from Y */
|
||||
else if (Y <= .00024283)
|
||||
return (0);
|
||||
else
|
||||
return itrunc(64.*(log2(Y) + 12.), em);
|
||||
return tiff_itrunc(64.*(log2(Y) + 12.), em);
|
||||
}
|
||||
|
||||
#define NANGLES 100
|
||||
@@ -925,12 +931,12 @@ uv_encode(double u, double v, int em) /* encode (u',v') coordinates */
|
||||
|
||||
if (v < UV_VSTART)
|
||||
return oog_encode(u, v);
|
||||
vi = itrunc((v - UV_VSTART)*(1./UV_SQSIZ), em);
|
||||
vi = tiff_itrunc((v - UV_VSTART)*(1./UV_SQSIZ), em);
|
||||
if (vi >= UV_NVS)
|
||||
return oog_encode(u, v);
|
||||
if (u < uv_row[vi].ustart)
|
||||
return oog_encode(u, v);
|
||||
ui = itrunc((u - uv_row[vi].ustart)*(1./UV_SQSIZ), em);
|
||||
ui = tiff_itrunc((u - uv_row[vi].ustart)*(1./UV_SQSIZ), em);
|
||||
if (ui >= uv_row[vi].nus)
|
||||
return oog_encode(u, v);
|
||||
|
||||
@@ -1099,7 +1105,7 @@ Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n)
|
||||
else if (sp->encode_meth == SGILOGENCODE_NODITHER)
|
||||
Le = (luv3[0]-3314) >> 2;
|
||||
else
|
||||
Le = itrunc(.25*(luv3[0]-3314.), sp->encode_meth);
|
||||
Le = tiff_itrunc(.25*(luv3[0]-3314.), sp->encode_meth);
|
||||
|
||||
Ce = uv_encode((luv3[1]+.5)/(1<<15), (luv3[2]+.5)/(1<<15),
|
||||
sp->encode_meth);
|
||||
@@ -1155,10 +1161,10 @@ LogLuv32fromXYZ(float XYZ[3], int em)
|
||||
v = 9.*XYZ[1] / s;
|
||||
}
|
||||
if (u <= 0.) ue = 0;
|
||||
else ue = itrunc(UVSCALE*u, em);
|
||||
else ue = tiff_itrunc(UVSCALE*u, em);
|
||||
if (ue > 255) ue = 255;
|
||||
if (v <= 0.) ve = 0;
|
||||
else ve = itrunc(UVSCALE*v, em);
|
||||
else ve = tiff_itrunc(UVSCALE*v, em);
|
||||
if (ve > 255) ve = 255;
|
||||
/* combine encodings */
|
||||
return (Le << 16 | ue << 8 | ve);
|
||||
@@ -1238,8 +1244,8 @@ Luv32fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n)
|
||||
}
|
||||
while (n-- > 0) {
|
||||
*luv++ = (uint32)luv3[0] << 16 |
|
||||
(itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) |
|
||||
(itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff);
|
||||
(tiff_itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) |
|
||||
(tiff_itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff);
|
||||
luv3 += 3;
|
||||
}
|
||||
}
|
||||
@@ -1269,16 +1275,10 @@ LogL16GuessDataFmt(TIFFDirectory *td)
|
||||
return (SGILOGDATAFMT_UNKNOWN);
|
||||
}
|
||||
|
||||
|
||||
#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
|
||||
#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
|
||||
|
||||
static tmsize_t
|
||||
multiply_ms(tmsize_t m1, tmsize_t m2)
|
||||
{
|
||||
if( m1 == 0 || m2 > TIFF_TMSIZE_T_MAX / m1 )
|
||||
return 0;
|
||||
return m1 * m2;
|
||||
return _TIFFMultiplySSize(NULL, m1, m2, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1512,7 +1512,7 @@ LogLuvSetupEncode(TIFF* tif)
|
||||
switch (td->td_photometric) {
|
||||
case PHOTOMETRIC_LOGLUV:
|
||||
if (!LogLuvInitState(tif))
|
||||
break;
|
||||
return (0);
|
||||
if (td->td_compression == COMPRESSION_SGILOG24) {
|
||||
tif->tif_encoderow = LogLuvEncode24;
|
||||
switch (sp->user_datafmt) {
|
||||
@@ -1545,7 +1545,7 @@ LogLuvSetupEncode(TIFF* tif)
|
||||
break;
|
||||
case PHOTOMETRIC_LOGL:
|
||||
if (!LogL16InitState(tif))
|
||||
break;
|
||||
return (0);
|
||||
tif->tif_encoderow = LogL16Encode;
|
||||
switch (sp->user_datafmt) {
|
||||
case SGILOGDATAFMT_FLOAT:
|
||||
@@ -1561,7 +1561,7 @@ LogLuvSetupEncode(TIFF* tif)
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Inappropriate photometric interpretation %d for SGILog compression; %s",
|
||||
td->td_photometric, "must be either LogLUV or LogL");
|
||||
break;
|
||||
return (0);
|
||||
}
|
||||
sp->encoder_state = 1;
|
||||
return (1);
|
||||
|
||||
Vendored
+5
-2
@@ -300,7 +300,8 @@ LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
}
|
||||
if (sp->stream.avail_out == 0) {
|
||||
tif->tif_rawcc = tif->tif_rawdatasize;
|
||||
TIFFFlushData1(tif);
|
||||
if (!TIFFFlushData1(tif))
|
||||
return 0;
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in LZMAPreEncode */
|
||||
}
|
||||
@@ -328,7 +329,8 @@ LZMAPostEncode(TIFF* tif)
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) {
|
||||
tif->tif_rawcc =
|
||||
tif->tif_rawdatasize - sp->stream.avail_out;
|
||||
TIFFFlushData1(tif);
|
||||
if (!TIFFFlushData1(tif))
|
||||
return 0;
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */
|
||||
}
|
||||
@@ -418,6 +420,7 @@ TIFFInitLZMA(TIFF* tif, int scheme)
|
||||
LZMAState* sp;
|
||||
lzma_stream tmp_stream = LZMA_STREAM_INIT;
|
||||
|
||||
(void)scheme;
|
||||
assert( scheme == COMPRESSION_LZMA );
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+5
-7
@@ -214,19 +214,16 @@ LZWSetupDecode(TIFF* tif)
|
||||
return (0);
|
||||
}
|
||||
|
||||
DecoderState(tif)->dec_codetab = NULL;
|
||||
DecoderState(tif)->dec_decode = NULL;
|
||||
sp = DecoderState(tif);
|
||||
sp->dec_codetab = NULL;
|
||||
sp->dec_decode = NULL;
|
||||
|
||||
/*
|
||||
* Setup predictor setup.
|
||||
*/
|
||||
(void) TIFFPredictorInit(tif);
|
||||
|
||||
sp = DecoderState(tif);
|
||||
}
|
||||
|
||||
assert(sp != NULL);
|
||||
|
||||
if (sp->dec_codetab == NULL) {
|
||||
sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t));
|
||||
if (sp->dec_codetab == NULL) {
|
||||
@@ -1161,6 +1158,7 @@ int
|
||||
TIFFInitLZW(TIFF* tif, int scheme)
|
||||
{
|
||||
static const char module[] = "TIFFInitLZW";
|
||||
(void)scheme;
|
||||
assert(scheme == COMPRESSION_LZW);
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record values.
|
||||
@@ -1218,7 +1216,7 @@ bad:
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
#endif /* LZW_SUPPORT */
|
||||
|
||||
|
||||
Vendored
+69
-25
@@ -74,7 +74,7 @@
|
||||
or errors, up to the point where either these values are read, or it's clear they
|
||||
aren't there. This means that some of the data is read twice, but we feel speed
|
||||
in correcting these values is important enough to warrant this sacrifice. Although
|
||||
there is currently no define or other configuration mechanism to disable this behaviour,
|
||||
there is currently no define or other configuration mechanism to disable this behavior,
|
||||
the actual header scanning is build to robustly respond with error report if it
|
||||
should encounter an uncorrected mismatch of subsampling values. See
|
||||
OJPEGReadHeaderInfoSecStreamSof.
|
||||
@@ -243,6 +243,7 @@ typedef enum {
|
||||
typedef struct {
|
||||
TIFF* tif;
|
||||
int decoder_ok;
|
||||
int error_in_raw_data_decoding;
|
||||
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
||||
JMP_BUF exit_jmpbuf;
|
||||
#endif
|
||||
@@ -420,6 +421,7 @@ TIFFInitOJPEG(TIFF* tif, int scheme)
|
||||
static const char module[]="TIFFInitOJPEG";
|
||||
OJPEGState* sp;
|
||||
|
||||
(void)scheme;
|
||||
assert(scheme==COMPRESSION_OJPEG);
|
||||
|
||||
/*
|
||||
@@ -497,15 +499,15 @@ OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
case TIFFTAG_JPEGQTABLES:
|
||||
*va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count;
|
||||
*va_arg(ap,void**)=(void*)sp->qtable_offset;
|
||||
*va_arg(ap,const void**)=(const void*)sp->qtable_offset;
|
||||
break;
|
||||
case TIFFTAG_JPEGDCTABLES:
|
||||
*va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count;
|
||||
*va_arg(ap,void**)=(void*)sp->dctable_offset;
|
||||
*va_arg(ap,const void**)=(const void*)sp->dctable_offset;
|
||||
break;
|
||||
case TIFFTAG_JPEGACTABLES:
|
||||
*va_arg(ap,uint32*)=(uint32)sp->actable_offset_count;
|
||||
*va_arg(ap,void**)=(void*)sp->actable_offset;
|
||||
*va_arg(ap,const void**)=(const void*)sp->actable_offset;
|
||||
break;
|
||||
case TIFFTAG_JPEGPROC:
|
||||
*va_arg(ap,uint16*)=(uint16)sp->jpeg_proc;
|
||||
@@ -657,7 +659,7 @@ static int
|
||||
OJPEGSetupDecode(TIFF* tif)
|
||||
{
|
||||
static const char module[]="OJPEGSetupDecode";
|
||||
TIFFWarningExt(tif->tif_clientdata,module,"Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software");
|
||||
TIFFWarningExt(tif->tif_clientdata,module,"Deprecated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software");
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -678,7 +680,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s)
|
||||
if (OJPEGReadSecondarySos(tif,s)==0)
|
||||
return(0);
|
||||
}
|
||||
if isTiled(tif)
|
||||
if (isTiled(tif))
|
||||
m=tif->tif_curtile;
|
||||
else
|
||||
m=tif->tif_curstrip;
|
||||
@@ -742,6 +744,7 @@ OJPEGPreDecodeSkipRaw(TIFF* tif)
|
||||
}
|
||||
m-=sp->subsampling_convert_clines-sp->subsampling_convert_state;
|
||||
sp->subsampling_convert_state=0;
|
||||
sp->error_in_raw_data_decoding=0;
|
||||
}
|
||||
while (m>=sp->subsampling_convert_clines)
|
||||
{
|
||||
@@ -792,6 +795,10 @@ OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized");
|
||||
return 0;
|
||||
}
|
||||
if( sp->error_in_raw_data_decoding )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (sp->libjpeg_jpeg_query_style==0)
|
||||
{
|
||||
if (OJPEGDecodeRaw(tif,buf,cc)==0)
|
||||
@@ -832,7 +839,10 @@ OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc)
|
||||
if (sp->subsampling_convert_state==0)
|
||||
{
|
||||
if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0)
|
||||
{
|
||||
sp->error_in_raw_data_decoding = 1;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
oy=sp->subsampling_convert_ybuf+sp->subsampling_convert_state*sp->subsampling_ver*sp->subsampling_convert_ylinelen;
|
||||
ocb=sp->subsampling_convert_cbbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen;
|
||||
@@ -990,7 +1000,6 @@ OJPEGSubsamplingCorrect(TIFF* tif)
|
||||
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
||||
uint8 mh;
|
||||
uint8 mv;
|
||||
_TIFFFillStriles( tif );
|
||||
|
||||
assert(sp->subsamplingcorrect_done==0);
|
||||
if ((tif->tif_dir.td_samplesperpixel!=3) || ((tif->tif_dir.td_photometric!=PHOTOMETRIC_YCBCR) &&
|
||||
@@ -1046,7 +1055,7 @@ OJPEGReadHeaderInfo(TIFF* tif)
|
||||
assert(sp->readheader_done==0);
|
||||
sp->image_width=tif->tif_dir.td_imagewidth;
|
||||
sp->image_length=tif->tif_dir.td_imagelength;
|
||||
if isTiled(tif)
|
||||
if (isTiled(tif))
|
||||
{
|
||||
sp->strile_width=tif->tif_dir.td_tilewidth;
|
||||
sp->strile_length=tif->tif_dir.td_tilelength;
|
||||
@@ -1056,6 +1065,8 @@ OJPEGReadHeaderInfo(TIFF* tif)
|
||||
{
|
||||
sp->strile_width=sp->image_width;
|
||||
sp->strile_length=tif->tif_dir.td_rowsperstrip;
|
||||
if( sp->strile_length == (uint32)-1 )
|
||||
sp->strile_length = sp->image_length;
|
||||
sp->strile_length_total=sp->image_length;
|
||||
}
|
||||
if (tif->tif_dir.td_samplesperpixel==1)
|
||||
@@ -1082,6 +1093,12 @@ OJPEGReadHeaderInfo(TIFF* tif)
|
||||
}
|
||||
if (sp->strile_length<sp->image_length)
|
||||
{
|
||||
if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) ||
|
||||
((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4)))
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Invalid subsampling values");
|
||||
return(0);
|
||||
}
|
||||
if (sp->strile_length%(sp->subsampling_ver*8)!=0)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Incompatible vertical subsampling and image strip/tile length");
|
||||
@@ -1197,7 +1214,13 @@ OJPEGWriteHeaderInfo(TIFF* tif)
|
||||
sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines;
|
||||
sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines;
|
||||
sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuflen;
|
||||
sp->subsampling_convert_ycbcrbuf=_TIFFmalloc(sp->subsampling_convert_ycbcrbuflen);
|
||||
/* The calloc is not normally necessary, except in some edge/broken cases */
|
||||
/* for example for a tiled image of height 1 with a tile height of 1 and subsampling_hor=subsampling_ver=2 */
|
||||
/* In that case, libjpeg will only fill the 8 first lines of the 16 lines */
|
||||
/* See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16844 */
|
||||
/* Even if this case is allowed (?), its handling is broken because OJPEGPreDecode() should also likely */
|
||||
/* reset subsampling_convert_state to 0 when changing tile. */
|
||||
sp->subsampling_convert_ycbcrbuf=_TIFFcalloc(1, sp->subsampling_convert_ycbcrbuflen);
|
||||
if (sp->subsampling_convert_ycbcrbuf==0)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
||||
@@ -1223,10 +1246,11 @@ OJPEGWriteHeaderInfo(TIFF* tif)
|
||||
*m++=sp->subsampling_convert_cbbuf+n*sp->subsampling_convert_clinelen;
|
||||
for (n=0; n<sp->subsampling_convert_clines; n++)
|
||||
*m++=sp->subsampling_convert_crbuf+n*sp->subsampling_convert_clinelen;
|
||||
sp->subsampling_convert_clinelenout=((sp->strile_width+sp->subsampling_hor-1)/sp->subsampling_hor);
|
||||
sp->subsampling_convert_clinelenout=sp->strile_width/sp->subsampling_hor + ((sp->strile_width % sp->subsampling_hor) != 0 ? 1 : 0);
|
||||
sp->subsampling_convert_state=0;
|
||||
sp->error_in_raw_data_decoding=0;
|
||||
sp->bytes_per_line=sp->subsampling_convert_clinelenout*(sp->subsampling_ver*sp->subsampling_hor+2);
|
||||
sp->lines_per_strile=((sp->strile_length+sp->subsampling_ver-1)/sp->subsampling_ver);
|
||||
sp->lines_per_strile=sp->strile_length/sp->subsampling_ver + ((sp->strile_length % sp->subsampling_ver) != 0 ? 1 : 0);
|
||||
sp->subsampling_convert_log=1;
|
||||
}
|
||||
}
|
||||
@@ -1240,6 +1264,26 @@ OJPEGWriteHeaderInfo(TIFF* tif)
|
||||
}
|
||||
if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0)
|
||||
return(0);
|
||||
if(sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width ) {
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"jpeg_start_decompress() returned image_width = %d, "
|
||||
"expected %d",
|
||||
sp->libjpeg_jpeg_decompress_struct.image_width,
|
||||
sp->strile_width);
|
||||
return 0;
|
||||
}
|
||||
if(sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor != sp->subsampling_hor ||
|
||||
sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor != sp->subsampling_ver) {
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"jpeg_start_decompress() returned max_h_samp_factor = %d "
|
||||
"and max_v_samp_factor = %d, expected %d and %d",
|
||||
sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor,
|
||||
sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor,
|
||||
sp->subsampling_hor,
|
||||
sp->subsampling_ver);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sp->writeheader_done=1;
|
||||
return(1);
|
||||
}
|
||||
@@ -1272,7 +1316,9 @@ OJPEGReadHeaderInfoSec(TIFF* tif)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sp->jpeg_interchange_format_length==0) || (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size))
|
||||
if ((sp->jpeg_interchange_format_length==0) ||
|
||||
(sp->jpeg_interchange_format > TIFF_UINT64_MAX - sp->jpeg_interchange_format_length) ||
|
||||
(sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size))
|
||||
sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format;
|
||||
}
|
||||
}
|
||||
@@ -1989,32 +2035,30 @@ OJPEGReadBufferFill(OJPEGState* sp)
|
||||
sp->in_buffer_source=osibsStrile;
|
||||
break;
|
||||
case osibsStrile:
|
||||
if (!_TIFFFillStriles( sp->tif )
|
||||
|| sp->tif->tif_dir.td_stripoffset == NULL
|
||||
|| sp->tif->tif_dir.td_stripbytecount == NULL)
|
||||
return 0;
|
||||
|
||||
if (sp->in_buffer_next_strile==sp->in_buffer_strile_count)
|
||||
sp->in_buffer_source=osibsEof;
|
||||
else
|
||||
{
|
||||
sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile];
|
||||
int err = 0;
|
||||
sp->in_buffer_file_pos=TIFFGetStrileOffsetWithErr(sp->tif, sp->in_buffer_next_strile, &err);
|
||||
if( err )
|
||||
return 0;
|
||||
if (sp->in_buffer_file_pos!=0)
|
||||
{
|
||||
uint64 bytecount = TIFFGetStrileByteCountWithErr(sp->tif, sp->in_buffer_next_strile, &err);
|
||||
if( err )
|
||||
return 0;
|
||||
if (sp->in_buffer_file_pos>=sp->file_size)
|
||||
sp->in_buffer_file_pos=0;
|
||||
else if (sp->tif->tif_dir.td_stripbytecount==NULL)
|
||||
else if (bytecount==0)
|
||||
sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos;
|
||||
else
|
||||
{
|
||||
if (sp->tif->tif_dir.td_stripbytecount == 0) {
|
||||
TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing");
|
||||
return(0);
|
||||
}
|
||||
sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile];
|
||||
sp->in_buffer_file_togo=bytecount;
|
||||
if (sp->in_buffer_file_togo==0)
|
||||
sp->in_buffer_file_pos=0;
|
||||
else if (sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size)
|
||||
else if (sp->in_buffer_file_pos > TIFF_UINT64_MAX - sp->in_buffer_file_togo ||
|
||||
sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size)
|
||||
sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+21
-2
@@ -104,6 +104,7 @@ TIFFClientOpen(
|
||||
} n;
|
||||
n.a8[0]=1;
|
||||
n.a8[1]=0;
|
||||
(void)n;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
assert(n.a16==256);
|
||||
#else
|
||||
@@ -131,6 +132,7 @@ TIFFClientOpen(
|
||||
if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) {
|
||||
TIFFErrorExt(clientdata, module,
|
||||
"One of the client procedures is NULL pointer.");
|
||||
_TIFFfree(tif);
|
||||
goto bad2;
|
||||
}
|
||||
tif->tif_readproc = readproc;
|
||||
@@ -164,7 +166,7 @@ TIFFClientOpen(
|
||||
/*
|
||||
* Process library-specific flags in the open mode string.
|
||||
* The following flags may be used to control intrinsic library
|
||||
* behaviour that may or may not be desirable (usually for
|
||||
* behavior that may or may not be desirable (usually for
|
||||
* compatibility with some application that claims to support
|
||||
* TIFF but only supports some brain dead idea of what the
|
||||
* vendor thinks TIFF is):
|
||||
@@ -181,6 +183,8 @@ TIFFClientOpen(
|
||||
* 'h' read TIFF header only, do not load the first IFD
|
||||
* '4' ClassicTIFF for creating a file (default)
|
||||
* '8' BigTIFF for creating a file
|
||||
* 'D' enable use of deferred strip/tile offset/bytecount array loading.
|
||||
* 'O' on-demand loading of values instead of whole array loading (implies D)
|
||||
*
|
||||
* The use of the 'l' and 'b' flags is strongly discouraged.
|
||||
* These flags are provided solely because numerous vendors,
|
||||
@@ -203,7 +207,7 @@ TIFFClientOpen(
|
||||
* not do right now.
|
||||
*
|
||||
* The 'M' and 'm' flags are provided because some virtual memory
|
||||
* systems exhibit poor behaviour when large images are mapped.
|
||||
* systems exhibit poor behavior when large images are mapped.
|
||||
* These options permit clients to control the use of memory-mapped
|
||||
* files on a per-file basis.
|
||||
*
|
||||
@@ -262,7 +266,22 @@ TIFFClientOpen(
|
||||
if (m&O_CREAT)
|
||||
tif->tif_flags |= TIFF_BIGTIFF;
|
||||
break;
|
||||
case 'D':
|
||||
tif->tif_flags |= TIFF_DEFERSTRILELOAD;
|
||||
break;
|
||||
case 'O':
|
||||
if( m == O_RDONLY )
|
||||
tif->tif_flags |= (TIFF_LAZYSTRILELOAD | TIFF_DEFERSTRILELOAD);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEFER_STRILE_LOAD
|
||||
/* Compatibility with old DEFER_STRILE_LOAD compilation flag */
|
||||
/* Probably unneeded, since to the best of my knowledge (E. Rouault) */
|
||||
/* GDAL was the only user of this, and will now use the new 'D' flag */
|
||||
tif->tif_flags |= TIFF_DEFERSTRILELOAD;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Read in TIFF header.
|
||||
*/
|
||||
|
||||
Vendored
+7
-10
@@ -634,16 +634,10 @@ PixarLogGuessDataFmt(TIFFDirectory *td)
|
||||
return guess;
|
||||
}
|
||||
|
||||
#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
|
||||
#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
|
||||
|
||||
static tmsize_t
|
||||
multiply_ms(tmsize_t m1, tmsize_t m2)
|
||||
{
|
||||
assert(m1 >= 0 && m2 >= 0);
|
||||
if( m1 == 0 || m2 > TIFF_TMSIZE_T_MAX / m1 )
|
||||
return 0;
|
||||
return m1 * m2;
|
||||
return _TIFFMultiplySSize(NULL, m1, m2, NULL);
|
||||
}
|
||||
|
||||
static tmsize_t
|
||||
@@ -1153,7 +1147,7 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
|
||||
llen = sp->stride * td->td_imagewidth;
|
||||
/* Check against the number of elements (of size uint16) of sp->tbuf */
|
||||
if( n > (tmsize_t)(td->td_rowsperstrip * llen) )
|
||||
if( n > ((tmsize_t)td->td_rowsperstrip * llen) )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Too many input bytes provided");
|
||||
@@ -1206,7 +1200,8 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
}
|
||||
if (sp->stream.avail_out == 0) {
|
||||
tif->tif_rawcc = tif->tif_rawdatasize;
|
||||
TIFFFlushData1(tif);
|
||||
if (!TIFFFlushData1(tif))
|
||||
return 0;
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in PixarLogPreEncode */
|
||||
}
|
||||
@@ -1236,7 +1231,8 @@ PixarLogPostEncode(TIFF* tif)
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) {
|
||||
tif->tif_rawcc =
|
||||
tif->tif_rawdatasize - sp->stream.avail_out;
|
||||
TIFFFlushData1(tif);
|
||||
if (!TIFFFlushData1(tif))
|
||||
return 0;
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in PixarLogPreEncode */
|
||||
}
|
||||
@@ -1404,6 +1400,7 @@ TIFFInitPixarLog(TIFF* tif, int scheme)
|
||||
|
||||
PixarLogState* sp;
|
||||
|
||||
(void)scheme;
|
||||
assert(scheme == COMPRESSION_PIXARLOG);
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+3
-3
@@ -116,7 +116,7 @@ PredictorSetupDecode(TIFF* tif)
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
|
||||
/* Note: when PredictorSetup() fails, the effets of setupdecode() */
|
||||
/* will not be "cancelled" so setupdecode() might be robust to */
|
||||
/* will not be "canceled" so setupdecode() might be robust to */
|
||||
/* be called several times. */
|
||||
if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif))
|
||||
return 0;
|
||||
@@ -270,8 +270,8 @@ PredictorSetupEncode(TIFF* tif)
|
||||
}
|
||||
|
||||
/* Remarks related to C standard compliance in all below functions : */
|
||||
/* - to avoid any undefined behaviour, we only operate on unsigned types */
|
||||
/* since the behaviour of "overflows" is defined (wrap over) */
|
||||
/* - to avoid any undefined behavior, we only operate on unsigned types */
|
||||
/* since the behavior of "overflows" is defined (wrap over) */
|
||||
/* - when storing into the byte stream, we explicitly mask with 0xff so */
|
||||
/* as to make icc -check=conversions happy (not necessary by the standard) */
|
||||
|
||||
|
||||
Vendored
+4
-6
@@ -652,8 +652,6 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
if (tif->tif_tagmethods.printdir)
|
||||
(*tif->tif_tagmethods.printdir)(tif, fd, flags);
|
||||
|
||||
_TIFFFillStriles( tif );
|
||||
|
||||
if ((flags & TIFFPRINT_STRIPS) &&
|
||||
TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) {
|
||||
uint32 s;
|
||||
@@ -665,13 +663,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
fprintf(fd, " %3lu: [%8I64u, %8I64u]\n",
|
||||
(unsigned long) s,
|
||||
td->td_stripoffset ? (unsigned __int64) td->td_stripoffset[s] : 0,
|
||||
td->td_stripbytecount ? (unsigned __int64) td->td_stripbytecount[s] : 0);
|
||||
(unsigned __int64) TIFFGetStrileOffset(tif, s),
|
||||
(unsigned __int64) TIFFGetStrileByteCount(tif, s));
|
||||
#else
|
||||
fprintf(fd, " %3lu: [%8llu, %8llu]\n",
|
||||
(unsigned long) s,
|
||||
td->td_stripoffset ? (unsigned long long) td->td_stripoffset[s] : 0,
|
||||
td->td_stripbytecount ? (unsigned long long) td->td_stripbytecount[s] : 0);
|
||||
(unsigned long long) TIFFGetStrileOffset(tif, s),
|
||||
(unsigned long long) TIFFGetStrileByteCount(tif, s));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+167
-95
@@ -29,9 +29,6 @@
|
||||
#include "tiffiop.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
|
||||
#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
|
||||
|
||||
int TIFFFillStrip(TIFF* tif, uint32 strip);
|
||||
int TIFFFillTile(TIFF* tif, uint32 tile);
|
||||
static int TIFFStartStrip(TIFF* tif, uint32 strip);
|
||||
@@ -49,6 +46,8 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m
|
||||
#define THRESHOLD_MULTIPLIER 10
|
||||
#define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD)
|
||||
|
||||
#define TIFF_INT64_MAX ((((int64)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
|
||||
|
||||
/* Read 'size' bytes in tif_rawdata buffer starting at offset 'rawdata_offset'
|
||||
* Returns 1 in case of success, 0 otherwise. */
|
||||
static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size,
|
||||
@@ -61,6 +60,22 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size,
|
||||
#endif
|
||||
tmsize_t already_read = 0;
|
||||
|
||||
|
||||
#if SIZEOF_SIZE_T != 8
|
||||
/* On 32 bit processes, if the request is large enough, check against */
|
||||
/* file size */
|
||||
if( size > 1000 * 1000 * 1000 )
|
||||
{
|
||||
uint64 filesize = TIFFGetFileSize(tif);
|
||||
if( (uint64)size >= filesize )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Chunk size requested is larger than file size.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */
|
||||
/* so as to avoid allocating too much memory in case the file is too */
|
||||
/* short. We could ask for the file size, but this might be */
|
||||
@@ -175,17 +190,14 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
|
||||
tmsize_t to_read;
|
||||
tmsize_t read_ahead_mod;
|
||||
/* tmsize_t bytecountm; */
|
||||
|
||||
if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
|
||||
return 0;
|
||||
|
||||
|
||||
/*
|
||||
* Expand raw data buffer, if needed, to hold data
|
||||
* strip coming from file (perhaps should set upper
|
||||
* bound on the size of a buffer we'll use?).
|
||||
*/
|
||||
|
||||
/* bytecountm=(tmsize_t) td->td_stripbytecount[strip]; */
|
||||
/* bytecountm=(tmsize_t) TIFFGetStrileByteCount(tif, strip); */
|
||||
|
||||
/* Not completely sure where the * 2 comes from, but probably for */
|
||||
/* an exponentional growth strategy of tif_rawdatasize */
|
||||
@@ -229,7 +241,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
|
||||
/*
|
||||
** Seek to the point in the file where more data should be read.
|
||||
*/
|
||||
read_offset = td->td_stripoffset[strip]
|
||||
read_offset = TIFFGetStrileOffset(tif, strip)
|
||||
+ tif->tif_rawdataoff + tif->tif_rawdataloaded;
|
||||
|
||||
if (!SeekOK(tif, read_offset)) {
|
||||
@@ -246,10 +258,10 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
|
||||
to_read = read_ahead_mod - unused_data;
|
||||
else
|
||||
to_read = tif->tif_rawdatasize - unused_data;
|
||||
if( (uint64) to_read > td->td_stripbytecount[strip]
|
||||
if( (uint64) to_read > TIFFGetStrileByteCount(tif, strip)
|
||||
- tif->tif_rawdataoff - tif->tif_rawdataloaded )
|
||||
{
|
||||
to_read = (tmsize_t) td->td_stripbytecount[strip]
|
||||
to_read = (tmsize_t) TIFFGetStrileByteCount(tif, strip)
|
||||
- tif->tif_rawdataoff - tif->tif_rawdataloaded;
|
||||
}
|
||||
|
||||
@@ -288,7 +300,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
|
||||
/* For JPEG, if there are multiple scans (can generally be known */
|
||||
/* with the read_ahead used), we need to read the whole strip */
|
||||
if( tif->tif_dir.td_compression==COMPRESSION_JPEG &&
|
||||
(uint64)tif->tif_rawcc < td->td_stripbytecount[strip] )
|
||||
(uint64)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip) )
|
||||
{
|
||||
if( TIFFJPEGIsFullStripRequired(tif) )
|
||||
{
|
||||
@@ -347,9 +359,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample )
|
||||
* read it a few lines at a time?
|
||||
*/
|
||||
#if defined(CHUNKY_STRIP_READ_SUPPORT)
|
||||
if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
|
||||
return 0;
|
||||
whole_strip = tif->tif_dir.td_stripbytecount[strip] < 10
|
||||
whole_strip = TIFFGetStrileByteCount(tif, strip) < 10
|
||||
|| isMapped(tif);
|
||||
if( td->td_compression == COMPRESSION_LERC ||
|
||||
td->td_compression == COMPRESSION_JBIG )
|
||||
@@ -402,7 +412,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample )
|
||||
else if( !whole_strip )
|
||||
{
|
||||
if( ((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < read_ahead
|
||||
&& (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < td->td_stripbytecount[strip] )
|
||||
&& (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < TIFFGetStrileByteCount(tif, strip) )
|
||||
{
|
||||
if( !TIFFFillStripPartial(tif,strip,read_ahead,0) )
|
||||
return 0;
|
||||
@@ -599,16 +609,11 @@ static tmsize_t
|
||||
TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,
|
||||
const char* module)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
if (!_TIFFFillStriles( tif ))
|
||||
return ((tmsize_t)(-1));
|
||||
|
||||
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
|
||||
if (!isMapped(tif)) {
|
||||
tmsize_t cc;
|
||||
|
||||
if (!SeekOK(tif, td->td_stripoffset[strip])) {
|
||||
if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip))) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Seek error at scanline %lu, strip %lu",
|
||||
(unsigned long) tif->tif_row, (unsigned long) strip);
|
||||
@@ -634,8 +639,8 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,
|
||||
} else {
|
||||
tmsize_t ma = 0;
|
||||
tmsize_t n;
|
||||
if ((td->td_stripoffset[strip] > (uint64)TIFF_TMSIZE_T_MAX)||
|
||||
((ma=(tmsize_t)td->td_stripoffset[strip])>tif->tif_size))
|
||||
if ((TIFFGetStrileOffset(tif, strip) > (uint64)TIFF_TMSIZE_T_MAX)||
|
||||
((ma=(tmsize_t)TIFFGetStrileOffset(tif, strip))>tif->tif_size))
|
||||
{
|
||||
n=0;
|
||||
}
|
||||
@@ -679,12 +684,10 @@ static tmsize_t
|
||||
TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip,
|
||||
tmsize_t size, const char* module)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
assert( !isMapped(tif) );
|
||||
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
|
||||
|
||||
if (!SeekOK(tif, td->td_stripoffset[strip_or_tile])) {
|
||||
if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip_or_tile))) {
|
||||
if( is_strip )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
@@ -720,7 +723,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
|
||||
{
|
||||
static const char module[] = "TIFFReadRawStrip";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint64 bytecount;
|
||||
uint64 bytecount64;
|
||||
tmsize_t bytecountm;
|
||||
|
||||
if (!TIFFCheckRead(tif, 0))
|
||||
@@ -738,31 +741,23 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
|
||||
"Compression scheme does not support access to raw uncompressed data");
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
bytecount = td->td_stripbytecount[strip];
|
||||
if ((int64)bytecount <= 0) {
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%I64u: Invalid strip byte count, strip %lu",
|
||||
(unsigned __int64) bytecount,
|
||||
(unsigned long) strip);
|
||||
#else
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%llu: Invalid strip byte count, strip %lu",
|
||||
(unsigned long long) bytecount,
|
||||
(unsigned long) strip);
|
||||
#endif
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
bytecountm = (tmsize_t)bytecount;
|
||||
if ((uint64)bytecountm!=bytecount) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Integer overflow");
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
if (size != (tmsize_t)(-1) && size < bytecountm)
|
||||
bytecount64 = TIFFGetStrileByteCount(tif, strip);
|
||||
if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64)
|
||||
bytecountm = size;
|
||||
else
|
||||
bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
|
||||
if( bytecountm == 0 ) {
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
return (TIFFReadRawStrip1(tif, strip, buf, bytecountm, module));
|
||||
}
|
||||
|
||||
TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
|
||||
static uint64 NoSanitizeSubUInt64(uint64 a, uint64 b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the specified strip and setup for decoding. The data buffer is
|
||||
* expanded, as necessary, to hold the strip's data.
|
||||
@@ -773,13 +768,10 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
static const char module[] = "TIFFFillStrip";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
|
||||
return 0;
|
||||
|
||||
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
|
||||
{
|
||||
uint64 bytecount = td->td_stripbytecount[strip];
|
||||
if ((int64)bytecount <= 0) {
|
||||
uint64 bytecount = TIFFGetStrileByteCount(tif, strip);
|
||||
if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) {
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Invalid strip byte count %I64u, strip %lu",
|
||||
@@ -806,7 +798,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
(bytecount - 4096) / 10 > (uint64)stripsize )
|
||||
{
|
||||
uint64 newbytecount = (uint64)stripsize * 10 + 4096;
|
||||
if( (int64)newbytecount >= 0 )
|
||||
if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX )
|
||||
{
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
@@ -831,13 +823,13 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
* We must check for overflow, potentially causing
|
||||
* an OOB read. Instead of simple
|
||||
*
|
||||
* td->td_stripoffset[strip]+bytecount > tif->tif_size
|
||||
* TIFFGetStrileOffset(tif, strip)+bytecount > tif->tif_size
|
||||
*
|
||||
* comparison (which can overflow) we do the following
|
||||
* two comparisons:
|
||||
*/
|
||||
if (bytecount > (uint64)tif->tif_size ||
|
||||
td->td_stripoffset[strip] > (uint64)tif->tif_size - bytecount) {
|
||||
TIFFGetStrileOffset(tif, strip) > (uint64)tif->tif_size - bytecount) {
|
||||
/*
|
||||
* This error message might seem strange, but
|
||||
* it's what would happen if a read were done
|
||||
@@ -849,7 +841,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
"Read error on strip %lu; "
|
||||
"got %I64u bytes, expected %I64u",
|
||||
(unsigned long) strip,
|
||||
(unsigned __int64) tif->tif_size - td->td_stripoffset[strip],
|
||||
(unsigned __int64) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)),
|
||||
(unsigned __int64) bytecount);
|
||||
#else
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
@@ -857,7 +849,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
"Read error on strip %lu; "
|
||||
"got %llu bytes, expected %llu",
|
||||
(unsigned long) strip,
|
||||
(unsigned long long) tif->tif_size - td->td_stripoffset[strip],
|
||||
(unsigned long long) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)),
|
||||
(unsigned long long) bytecount);
|
||||
#endif
|
||||
tif->tif_curstrip = NOSTRIP;
|
||||
@@ -886,7 +878,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
}
|
||||
tif->tif_flags &= ~TIFF_MYBUFFER;
|
||||
tif->tif_rawdatasize = (tmsize_t)bytecount;
|
||||
tif->tif_rawdata = tif->tif_base + (tmsize_t)td->td_stripoffset[strip];
|
||||
tif->tif_rawdata = tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, strip);
|
||||
tif->tif_rawdataoff = 0;
|
||||
tif->tif_rawdataloaded = (tmsize_t) bytecount;
|
||||
|
||||
@@ -1101,16 +1093,11 @@ _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile,
|
||||
static tmsize_t
|
||||
TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
if (!_TIFFFillStriles( tif ))
|
||||
return ((tmsize_t)(-1));
|
||||
|
||||
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
|
||||
if (!isMapped(tif)) {
|
||||
tmsize_t cc;
|
||||
|
||||
if (!SeekOK(tif, td->td_stripoffset[tile])) {
|
||||
if (!SeekOK(tif, TIFFGetStrileOffset(tif, tile))) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Seek error at row %lu, col %lu, tile %lu",
|
||||
(unsigned long) tif->tif_row,
|
||||
@@ -1140,9 +1127,9 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m
|
||||
} else {
|
||||
tmsize_t ma,mb;
|
||||
tmsize_t n;
|
||||
ma=(tmsize_t)td->td_stripoffset[tile];
|
||||
ma=(tmsize_t)TIFFGetStrileOffset(tif, tile);
|
||||
mb=ma+size;
|
||||
if ((td->td_stripoffset[tile] > (uint64)TIFF_TMSIZE_T_MAX)||(ma>tif->tif_size))
|
||||
if ((TIFFGetStrileOffset(tif, tile) > (uint64)TIFF_TMSIZE_T_MAX)||(ma>tif->tif_size))
|
||||
n=0;
|
||||
else if ((mb<ma)||(mb<size)||(mb>tif->tif_size))
|
||||
n=tif->tif_size-ma;
|
||||
@@ -1198,13 +1185,12 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
|
||||
"Compression scheme does not support access to raw uncompressed data");
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
bytecount64 = td->td_stripbytecount[tile];
|
||||
if (size != (tmsize_t)(-1) && (uint64)size < bytecount64)
|
||||
bytecount64 = (uint64)size;
|
||||
bytecountm = (tmsize_t)bytecount64;
|
||||
if ((uint64)bytecountm!=bytecount64)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
bytecount64 = TIFFGetStrileByteCount(tif, tile);
|
||||
if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64)
|
||||
bytecountm = size;
|
||||
else
|
||||
bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
|
||||
if( bytecountm == 0 ) {
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module));
|
||||
@@ -1220,13 +1206,10 @@ TIFFFillTile(TIFF* tif, uint32 tile)
|
||||
static const char module[] = "TIFFFillTile";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
|
||||
return 0;
|
||||
|
||||
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
|
||||
{
|
||||
uint64 bytecount = td->td_stripbytecount[tile];
|
||||
if ((int64)bytecount <= 0) {
|
||||
uint64 bytecount = TIFFGetStrileByteCount(tif, tile);
|
||||
if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) {
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%I64u: Invalid tile byte count, tile %lu",
|
||||
@@ -1253,7 +1236,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
|
||||
(bytecount - 4096) / 10 > (uint64)stripsize )
|
||||
{
|
||||
uint64 newbytecount = (uint64)stripsize * 10 + 4096;
|
||||
if( (int64)newbytecount >= 0 )
|
||||
if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX )
|
||||
{
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
@@ -1278,13 +1261,13 @@ TIFFFillTile(TIFF* tif, uint32 tile)
|
||||
* We must check for overflow, potentially causing
|
||||
* an OOB read. Instead of simple
|
||||
*
|
||||
* td->td_stripoffset[tile]+bytecount > tif->tif_size
|
||||
* TIFFGetStrileOffset(tif, tile)+bytecount > tif->tif_size
|
||||
*
|
||||
* comparison (which can overflow) we do the following
|
||||
* two comparisons:
|
||||
*/
|
||||
if (bytecount > (uint64)tif->tif_size ||
|
||||
td->td_stripoffset[tile] > (uint64)tif->tif_size - bytecount) {
|
||||
TIFFGetStrileOffset(tif, tile) > (uint64)tif->tif_size - bytecount) {
|
||||
tif->tif_curtile = NOTILE;
|
||||
return (0);
|
||||
}
|
||||
@@ -1313,7 +1296,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
|
||||
|
||||
tif->tif_rawdatasize = (tmsize_t)bytecount;
|
||||
tif->tif_rawdata =
|
||||
tif->tif_base + (tmsize_t)td->td_stripoffset[tile];
|
||||
tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, tile);
|
||||
tif->tif_rawdataoff = 0;
|
||||
tif->tif_rawdataloaded = (tmsize_t) bytecount;
|
||||
tif->tif_flags |= TIFF_BUFFERMMAP;
|
||||
@@ -1440,9 +1423,6 @@ TIFFStartStrip(TIFF* tif, uint32 strip)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
|
||||
return 0;
|
||||
|
||||
if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
|
||||
if (!(*tif->tif_setupdecode)(tif))
|
||||
return (0);
|
||||
@@ -1463,10 +1443,18 @@ TIFFStartStrip(TIFF* tif, uint32 strip)
|
||||
if( tif->tif_rawdataloaded > 0 )
|
||||
tif->tif_rawcc = tif->tif_rawdataloaded;
|
||||
else
|
||||
tif->tif_rawcc = (tmsize_t)td->td_stripbytecount[strip];
|
||||
tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip);
|
||||
}
|
||||
return ((*tif->tif_predecode)(tif,
|
||||
(uint16)(strip / td->td_stripsperimage)));
|
||||
if ((*tif->tif_predecode)(tif,
|
||||
(uint16)(strip / td->td_stripsperimage)) == 0 ) {
|
||||
/* Needed for example for scanline access, if tif_predecode */
|
||||
/* fails, and we try to read the same strip again. Without invalidating */
|
||||
/* tif_curstrip, we'd call tif_decoderow() on a possibly invalid */
|
||||
/* codec state. */
|
||||
tif->tif_curstrip = NOSTRIP;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1480,9 +1468,6 @@ TIFFStartTile(TIFF* tif, uint32 tile)
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 howmany32;
|
||||
|
||||
if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
|
||||
return 0;
|
||||
|
||||
if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
|
||||
if (!(*tif->tif_setupdecode)(tif))
|
||||
return (0);
|
||||
@@ -1513,7 +1498,7 @@ TIFFStartTile(TIFF* tif, uint32 tile)
|
||||
if( tif->tif_rawdataloaded > 0 )
|
||||
tif->tif_rawcc = tif->tif_rawdataloaded;
|
||||
else
|
||||
tif->tif_rawcc = (tmsize_t)td->td_stripbytecount[tile];
|
||||
tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile);
|
||||
}
|
||||
return ((*tif->tif_predecode)(tif,
|
||||
(uint16)(tile/td->td_stripsperimage)));
|
||||
@@ -1528,13 +1513,100 @@ TIFFCheckRead(TIFF* tif, int tiles)
|
||||
}
|
||||
if (tiles ^ isTiled(tif)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ?
|
||||
"Can not read tiles from a stripped image" :
|
||||
"Can not read tiles from a striped image" :
|
||||
"Can not read scanlines from a tiled image");
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Use the provided input buffer (inbuf, insize) and decompress it into
|
||||
* (outbuf, outsize).
|
||||
* This function replaces the use of TIFFReadEncodedStrip()/TIFFReadEncodedTile()
|
||||
* when the user can provide the buffer for the input data, for example when
|
||||
* he wants to avoid libtiff to read the strile offset/count values from the
|
||||
* [Strip|Tile][Offsets/ByteCounts] array.
|
||||
* inbuf content must be writable (if bit reversal is needed)
|
||||
* Returns 1 in case of success, 0 otherwise.
|
||||
*/
|
||||
int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile,
|
||||
void* inbuf, tmsize_t insize,
|
||||
void* outbuf, tmsize_t outsize)
|
||||
{
|
||||
static const char module[] = "TIFFReadFromUserBuffer";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
int ret = 1;
|
||||
uint32 old_tif_flags = tif->tif_flags;
|
||||
tmsize_t old_rawdatasize = tif->tif_rawdatasize;
|
||||
void* old_rawdata = tif->tif_rawdata;
|
||||
|
||||
if (tif->tif_mode == O_WRONLY) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "File not open for reading");
|
||||
return 0;
|
||||
}
|
||||
if (tif->tif_flags&TIFF_NOREADRAW)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Compression scheme does not support access to raw uncompressed data");
|
||||
return 0;
|
||||
}
|
||||
|
||||
tif->tif_flags &= ~TIFF_MYBUFFER;
|
||||
tif->tif_flags |= TIFF_BUFFERMMAP;
|
||||
tif->tif_rawdatasize = insize;
|
||||
tif->tif_rawdata = inbuf;
|
||||
tif->tif_rawdataoff = 0;
|
||||
tif->tif_rawdataloaded = insize;
|
||||
|
||||
if (!isFillOrder(tif, td->td_fillorder) &&
|
||||
(tif->tif_flags & TIFF_NOBITREV) == 0)
|
||||
{
|
||||
TIFFReverseBits(inbuf, insize);
|
||||
}
|
||||
|
||||
if( TIFFIsTiled(tif) )
|
||||
{
|
||||
if( !TIFFStartTile(tif, strile) ||
|
||||
!(*tif->tif_decodetile)(tif, (uint8*) outbuf, outsize,
|
||||
(uint16)(strile/td->td_stripsperimage)) )
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 rowsperstrip=td->td_rowsperstrip;
|
||||
uint32 stripsperplane;
|
||||
if (rowsperstrip>td->td_imagelength)
|
||||
rowsperstrip=td->td_imagelength;
|
||||
stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
|
||||
if( !TIFFStartStrip(tif, strile) ||
|
||||
!(*tif->tif_decodestrip)(tif, (uint8*) outbuf, outsize,
|
||||
(uint16)(strile/stripsperplane)) )
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
if( ret )
|
||||
{
|
||||
(*tif->tif_postdecode)(tif, (uint8*) outbuf, outsize);
|
||||
}
|
||||
|
||||
if (!isFillOrder(tif, td->td_fillorder) &&
|
||||
(tif->tif_flags & TIFF_NOBITREV) == 0)
|
||||
{
|
||||
TIFFReverseBits(inbuf, insize);
|
||||
}
|
||||
|
||||
tif->tif_flags = old_tif_flags;
|
||||
tif->tif_rawdatasize = old_rawdatasize;
|
||||
tif->tif_rawdata = old_rawdata;
|
||||
tif->tif_rawdataoff = 0;
|
||||
tif->tif_rawdataloaded = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc)
|
||||
{
|
||||
|
||||
Vendored
+5
-33
@@ -129,15 +129,8 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
|
||||
{
|
||||
static const char module[] = "TIFFVStripSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFVStripSize64(tif,nrows);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
return _TIFFCastUInt64ToSSize(tif, m, module);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -147,8 +140,7 @@ uint64
|
||||
TIFFRawStripSize64(TIFF* tif, uint32 strip)
|
||||
{
|
||||
static const char module[] = "TIFFRawStripSize64";
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
uint64 bytecount = td->td_stripbytecount[strip];
|
||||
uint64 bytecount = TIFFGetStrileByteCount(tif, strip);
|
||||
|
||||
if (bytecount == 0)
|
||||
{
|
||||
@@ -211,15 +203,8 @@ TIFFStripSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFStripSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFStripSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
return _TIFFCastUInt64ToSSize(tif, m, module);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -330,14 +315,8 @@ TIFFScanlineSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFScanlineSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFScanlineSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m) {
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
return _TIFFCastUInt64ToSSize(tif, m, module);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -366,15 +345,8 @@ TIFFRasterScanlineSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFRasterScanlineSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFRasterScanlineSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
return _TIFFCastUInt64ToSSize(tif, m, module);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
Vendored
+5
-5
@@ -122,17 +122,17 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels)
|
||||
break;
|
||||
case THUNDER_2BITDELTAS: /* 2-bit deltas */
|
||||
if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta]));
|
||||
if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta]));
|
||||
if ((delta = (n & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta]));
|
||||
break;
|
||||
case THUNDER_3BITDELTAS: /* 3-bit deltas */
|
||||
if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP)
|
||||
SETPIXEL(op, lastpixel + threebitdeltas[delta]);
|
||||
SETPIXEL(op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
|
||||
if ((delta = (n & 7)) != DELTA3_SKIP)
|
||||
SETPIXEL(op, lastpixel + threebitdeltas[delta]);
|
||||
SETPIXEL(op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
|
||||
break;
|
||||
case THUNDER_RAW: /* raw data */
|
||||
SETPIXEL(op, n);
|
||||
|
||||
Vendored
+3
-24
@@ -181,15 +181,8 @@ TIFFTileRowSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFTileRowSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFTileRowSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
return _TIFFCastUInt64ToSSize(tif, m, module);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -248,15 +241,8 @@ TIFFVTileSize(TIFF* tif, uint32 nrows)
|
||||
{
|
||||
static const char module[] = "TIFFVTileSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFVTileSize64(tif,nrows);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
return _TIFFCastUInt64ToSSize(tif, m, module);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -272,15 +258,8 @@ TIFFTileSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFTileSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFTileSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
return _TIFFCastUInt64ToSSize(tif, m, module);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+1
-1
@@ -162,7 +162,7 @@ _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
|
||||
{
|
||||
uint64 size64 = _tiffSizeProc(fd);
|
||||
tmsize_t sizem = (tmsize_t)size64;
|
||||
if ((uint64)sizem==size64) {
|
||||
if (size64 && (uint64)sizem==size64) {
|
||||
fd_as_handle_union_t fdh;
|
||||
fdh.h = fd;
|
||||
*pbase = (void*)
|
||||
|
||||
Vendored
+11
-4
@@ -267,6 +267,12 @@ TWebPPreDecode(TIFF* tif, uint16 s)
|
||||
segment_height = td->td_rowsperstrip;
|
||||
}
|
||||
|
||||
if( segment_width > 16383 || segment_height > 16383 ) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"WEBP maximum image dimensions are 16383 x 16383.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( (sp->state & LSTATE_INIT_DECODE) == 0 )
|
||||
tif->tif_setupdecode(tif);
|
||||
|
||||
@@ -333,7 +339,7 @@ TWebPSetupEncode(TIFF* tif)
|
||||
}
|
||||
|
||||
/* check bits per sample and data type */
|
||||
if ((nBitsPerSample != 8) && (sampleFormat != 1)) {
|
||||
if ((nBitsPerSample != 8) || (sampleFormat != SAMPLEFORMAT_UINT)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"WEBP driver requires 8 bit unsigned data");
|
||||
return 0;
|
||||
@@ -356,7 +362,7 @@ TWebPSetupEncode(TIFF* tif)
|
||||
}
|
||||
|
||||
if (!WebPConfigInitInternal(&sp->sEncoderConfig, WEBP_PRESET_DEFAULT,
|
||||
sp->quality_level,
|
||||
(float)sp->quality_level,
|
||||
WEBP_ENCODER_ABI_VERSION)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Error creating WebP encoder configuration.");
|
||||
@@ -579,7 +585,7 @@ TWebPVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
#if WEBP_ENCODER_ABI_VERSION >= 0x0100
|
||||
sp->lossless = va_arg(ap, int);
|
||||
if (sp->lossless){
|
||||
sp->quality_level = 100.0f;
|
||||
sp->quality_level = 100;
|
||||
}
|
||||
return 1;
|
||||
#else
|
||||
@@ -628,6 +634,7 @@ TIFFInitWebP(TIFF* tif, int scheme)
|
||||
static const char module[] = "TIFFInitWebP";
|
||||
WebPState* sp;
|
||||
|
||||
(void)scheme;
|
||||
assert( scheme == COMPRESSION_WEBP );
|
||||
|
||||
/*
|
||||
@@ -656,7 +663,7 @@ TIFFInitWebP(TIFF* tif, int scheme)
|
||||
tif->tif_tagmethods.vsetfield = TWebPVSetField; /* hook for codec tags */
|
||||
|
||||
/* Default values for codec-specific fields */
|
||||
sp->quality_level = 75.0f; /* default comp. level */
|
||||
sp->quality_level = 75; /* default comp. level */
|
||||
sp->lossless = 0; /* default to false */
|
||||
sp->state = 0;
|
||||
sp->nSamples = 0;
|
||||
|
||||
Vendored
+37
-31
@@ -27,34 +27,38 @@
|
||||
* Scott Wagner (wagner@itek.com), Itek Graphix, Rochester, NY USA
|
||||
*/
|
||||
|
||||
/*
|
||||
CreateFileA/CreateFileW return type 'HANDLE'.
|
||||
|
||||
thandle_t is declared like
|
||||
|
||||
DECLARE_HANDLE(thandle_t);
|
||||
|
||||
in tiffio.h.
|
||||
|
||||
Windows (from winnt.h) DECLARE_HANDLE logic looks like
|
||||
|
||||
#ifdef STRICT
|
||||
typedef void *HANDLE;
|
||||
#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
|
||||
#else
|
||||
typedef PVOID HANDLE;
|
||||
#define DECLARE_HANDLE(name) typedef HANDLE name
|
||||
#endif
|
||||
|
||||
See http://bugzilla.maptools.org/show_bug.cgi?id=1941 for problems in WIN64
|
||||
builds resulting from this. Unfortunately, the proposed patch was lost.
|
||||
|
||||
*/
|
||||
|
||||
#include "tiffiop.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/*
|
||||
CreateFileA/CreateFileW return type 'HANDLE' while TIFFFdOpen() takes 'int',
|
||||
which is formally incompatible and can even seemingly be of different size:
|
||||
HANDLE is 64 bit under Win64, while int is still 32 bits there.
|
||||
|
||||
However, only the lower 32 bits of a HANDLE are significant under Win64 as,
|
||||
for interoperability reasons, they must have the same values in 32- and
|
||||
64-bit programs running on the same system, see
|
||||
|
||||
https://docs.microsoft.com/en-us/windows/win32/winprog64/interprocess-communication
|
||||
|
||||
Because of this, it is safe to define the following trivial functions for
|
||||
casting between ints and HANDLEs, which are only really needed to avoid
|
||||
compiler warnings (and, perhaps, to make the code slightly more clear).
|
||||
Note that using the intermediate cast to "intptr_t" is crucial for warning
|
||||
avoidance, as this integer type has the same size as HANDLE in all builds.
|
||||
*/
|
||||
|
||||
static inline thandle_t thandle_from_int(int ifd)
|
||||
{
|
||||
return (thandle_t)(intptr_t)ifd;
|
||||
}
|
||||
|
||||
static inline int thandle_to_int(thandle_t fd)
|
||||
{
|
||||
return (int)(intptr_t)fd;
|
||||
}
|
||||
|
||||
static tmsize_t
|
||||
_tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
|
||||
{
|
||||
@@ -151,9 +155,11 @@ _tiffCloseProc(thandle_t fd)
|
||||
static uint64
|
||||
_tiffSizeProc(thandle_t fd)
|
||||
{
|
||||
ULARGE_INTEGER m;
|
||||
m.LowPart=GetFileSize(fd,&m.HighPart);
|
||||
return(m.QuadPart);
|
||||
LARGE_INTEGER m;
|
||||
if (GetFileSizeEx(fd,&m))
|
||||
return(m.QuadPart);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -185,7 +191,7 @@ _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
|
||||
|
||||
size = _tiffSizeProc(fd);
|
||||
sizem = (tmsize_t)size;
|
||||
if ((uint64)sizem!=size)
|
||||
if (!size || (uint64)sizem!=size)
|
||||
return (0);
|
||||
|
||||
/* By passing in 0 for the maximum file size, it specifies that we
|
||||
@@ -237,7 +243,7 @@ TIFFFdOpen(int ifd, const char* name, const char* mode)
|
||||
break;
|
||||
}
|
||||
}
|
||||
tif = TIFFClientOpen(name, mode, (thandle_t)ifd, /* FIXME: WIN64 cast to pointer warning */
|
||||
tif = TIFFClientOpen(name, mode, thandle_from_int(ifd),
|
||||
_tiffReadProc, _tiffWriteProc,
|
||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||
fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
|
||||
@@ -282,7 +288,7 @@ TIFFOpen(const char* name, const char* mode)
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen((int)fd, name, mode); /* FIXME: WIN64 cast from pointer to int warning */
|
||||
tif = TIFFFdOpen(thandle_to_int(fd), name, mode);
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
return tif;
|
||||
@@ -337,7 +343,7 @@ TIFFOpenW(const wchar_t* name, const char* mode)
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen((int)fd, /* FIXME: WIN64 cast from pointer to int warning */
|
||||
tif = TIFFFdOpen(thandle_to_int(fd),
|
||||
(mbname != NULL) ? mbname : "<unknown>", mode);
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
|
||||
Vendored
+86
-63
@@ -128,10 +128,10 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample)
|
||||
tif->tif_rawcc = 0;
|
||||
tif->tif_rawcp = tif->tif_rawdata;
|
||||
|
||||
if( td->td_stripbytecount[strip] > 0 )
|
||||
if( td->td_stripbytecount_p[strip] > 0 )
|
||||
{
|
||||
/* if we are writing over existing tiles, zero length */
|
||||
td->td_stripbytecount[strip] = 0;
|
||||
td->td_stripbytecount_p[strip] = 0;
|
||||
|
||||
/* this forces TIFFAppendToStrip() to do a seek */
|
||||
tif->tif_curoff = 0;
|
||||
@@ -176,6 +176,32 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample)
|
||||
return (status);
|
||||
}
|
||||
|
||||
/* Make sure that at the first attempt of rewriting a tile/strip, we will have */
|
||||
/* more bytes available in the output buffer than the previous byte count, */
|
||||
/* so that TIFFAppendToStrip() will detect the overflow when it is called the first */
|
||||
/* time if the new compressed tile is bigger than the older one. (GDAL #4771) */
|
||||
static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32 strip_or_tile)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
if( td->td_stripbytecount_p[strip_or_tile] > 0 )
|
||||
{
|
||||
/* The +1 is to ensure at least one extra bytes */
|
||||
/* The +4 is because the LZW encoder flushes 4 bytes before the limit */
|
||||
uint64 safe_buffer_size = (uint64)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4);
|
||||
if( tif->tif_rawdatasize <= (tmsize_t)safe_buffer_size )
|
||||
{
|
||||
if( !(TIFFWriteBufferSetup(tif, NULL,
|
||||
(tmsize_t)TIFFroundup_64(safe_buffer_size, 1024))) )
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Force TIFFAppendToStrip() to consider placing data at end
|
||||
of file. */
|
||||
tif->tif_curoff = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode the supplied data and write it to the
|
||||
* specified strip.
|
||||
@@ -222,6 +248,13 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)
|
||||
tif->tif_flags |= TIFF_BUF4WRITE;
|
||||
tif->tif_curstrip = strip;
|
||||
|
||||
if( !_TIFFReserveLargeEnoughWriteBuffer(tif, strip) ) {
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
|
||||
tif->tif_rawcc = 0;
|
||||
tif->tif_rawcp = tif->tif_rawdata;
|
||||
|
||||
if (td->td_stripsperimage == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Zero strips per image");
|
||||
return ((tmsize_t) -1);
|
||||
@@ -234,27 +267,6 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)
|
||||
tif->tif_flags |= TIFF_CODERSETUP;
|
||||
}
|
||||
|
||||
if( td->td_stripbytecount[strip] > 0 )
|
||||
{
|
||||
/* Make sure that at the first attempt of rewriting the tile, we will have */
|
||||
/* more bytes available in the output buffer than the previous byte count, */
|
||||
/* so that TIFFAppendToStrip() will detect the overflow when it is called the first */
|
||||
/* time if the new compressed tile is bigger than the older one. (GDAL #4771) */
|
||||
if( tif->tif_rawdatasize <= (tmsize_t)td->td_stripbytecount[strip] )
|
||||
{
|
||||
if( !(TIFFWriteBufferSetup(tif, NULL,
|
||||
(tmsize_t)TIFFroundup_64((uint64)(td->td_stripbytecount[strip] + 1), 1024))) )
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
|
||||
/* Force TIFFAppendToStrip() to consider placing data at end
|
||||
of file. */
|
||||
tif->tif_curoff = 0;
|
||||
}
|
||||
|
||||
tif->tif_rawcc = 0;
|
||||
tif->tif_rawcp = tif->tif_rawdata;
|
||||
|
||||
tif->tif_flags &= ~TIFF_POSTENCODE;
|
||||
|
||||
/* shortcut to avoid an extra memcpy() */
|
||||
@@ -402,22 +414,8 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc)
|
||||
tif->tif_flags |= TIFF_BUF4WRITE;
|
||||
tif->tif_curtile = tile;
|
||||
|
||||
if( td->td_stripbytecount[tile] > 0 )
|
||||
{
|
||||
/* Make sure that at the first attempt of rewriting the tile, we will have */
|
||||
/* more bytes available in the output buffer than the previous byte count, */
|
||||
/* so that TIFFAppendToStrip() will detect the overflow when it is called the first */
|
||||
/* time if the new compressed tile is bigger than the older one. (GDAL #4771) */
|
||||
if( tif->tif_rawdatasize <= (tmsize_t) td->td_stripbytecount[tile] )
|
||||
{
|
||||
if( !(TIFFWriteBufferSetup(tif, NULL,
|
||||
(tmsize_t)TIFFroundup_64((uint64)(td->td_stripbytecount[tile] + 1), 1024))) )
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
|
||||
/* Force TIFFAppendToStrip() to consider placing data at end
|
||||
of file. */
|
||||
tif->tif_curoff = 0;
|
||||
if( !_TIFFReserveLargeEnoughWriteBuffer(tif, tile) ) {
|
||||
return ((tmsize_t)(-1));
|
||||
}
|
||||
|
||||
tif->tif_rawcc = 0;
|
||||
@@ -535,22 +533,29 @@ TIFFSetupStrips(TIFF* tif)
|
||||
isUnspecified(tif, FIELD_ROWSPERSTRIP) ?
|
||||
td->td_samplesperpixel : TIFFNumberOfStrips(tif);
|
||||
td->td_nstrips = td->td_stripsperimage;
|
||||
/* TIFFWriteDirectoryTagData has a limitation to 0x80000000U bytes */
|
||||
if( td->td_nstrips >= 0x80000000U / ((tif->tif_flags&TIFF_BIGTIFF)?0x8U:0x4U) )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, "TIFFSetupStrips",
|
||||
"Too large Strip/Tile Offsets/ByteCounts arrays");
|
||||
return 0;
|
||||
}
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
td->td_stripsperimage /= td->td_samplesperpixel;
|
||||
td->td_stripoffset = (uint64 *)
|
||||
td->td_stripoffset_p = (uint64 *)
|
||||
_TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64),
|
||||
"for \"StripOffsets\" array");
|
||||
td->td_stripbytecount = (uint64 *)
|
||||
td->td_stripbytecount_p = (uint64 *)
|
||||
_TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64),
|
||||
"for \"StripByteCounts\" array");
|
||||
if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL)
|
||||
if (td->td_stripoffset_p == NULL || td->td_stripbytecount_p == NULL)
|
||||
return (0);
|
||||
/*
|
||||
* Place data at the end-of-file
|
||||
* (by setting offsets to zero).
|
||||
*/
|
||||
_TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint64));
|
||||
_TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint64));
|
||||
_TIFFmemset(td->td_stripoffset_p, 0, td->td_nstrips*sizeof (uint64));
|
||||
_TIFFmemset(td->td_stripbytecount_p, 0, td->td_nstrips*sizeof (uint64));
|
||||
TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
|
||||
TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);
|
||||
return (1);
|
||||
@@ -572,7 +577,7 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module)
|
||||
}
|
||||
if (tiles ^ isTiled(tif)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, tiles ?
|
||||
"Can not write tiles to a stripped image" :
|
||||
"Can not write tiles to a striped image" :
|
||||
"Can not write scanlines to a tiled image");
|
||||
return (0);
|
||||
}
|
||||
@@ -610,7 +615,7 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module)
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) {
|
||||
if (tif->tif_dir.td_stripoffset_p == NULL && !TIFFSetupStrips(tif)) {
|
||||
tif->tif_dir.td_nstrips = 0;
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "No space for %s arrays",
|
||||
isTiled(tif) ? "tile" : "strip");
|
||||
@@ -628,6 +633,20 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module)
|
||||
if (tif->tif_scanlinesize == 0)
|
||||
return (0);
|
||||
tif->tif_flags |= TIFF_BEENWRITING;
|
||||
|
||||
if( tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
|
||||
tif->tif_dir.td_stripoffset_entry.tdir_count == 0 &&
|
||||
tif->tif_dir.td_stripoffset_entry.tdir_type == 0 &&
|
||||
tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 &&
|
||||
tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 &&
|
||||
tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 &&
|
||||
tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 &&
|
||||
tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0 &&
|
||||
!(tif->tif_flags & TIFF_DIRTYDIRECT) )
|
||||
{
|
||||
TIFFForceStrileArrayWriting(tif);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -649,6 +668,10 @@ TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size)
|
||||
if (size == (tmsize_t)(-1)) {
|
||||
size = (isTiled(tif) ?
|
||||
tif->tif_tilesize : TIFFStripSize(tif));
|
||||
|
||||
/* Adds 10% margin for cases where compression would expand a bit */
|
||||
if( size < TIFF_TMSIZE_T_MAX - size / 10 )
|
||||
size += size / 10;
|
||||
/*
|
||||
* Make raw data buffer at least 8K
|
||||
*/
|
||||
@@ -684,9 +707,9 @@ TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module)
|
||||
uint64* new_stripbytecount;
|
||||
|
||||
assert(td->td_planarconfig == PLANARCONFIG_CONTIG);
|
||||
new_stripoffset = (uint64*)_TIFFrealloc(td->td_stripoffset,
|
||||
new_stripoffset = (uint64*)_TIFFrealloc(td->td_stripoffset_p,
|
||||
(td->td_nstrips + delta) * sizeof (uint64));
|
||||
new_stripbytecount = (uint64*)_TIFFrealloc(td->td_stripbytecount,
|
||||
new_stripbytecount = (uint64*)_TIFFrealloc(td->td_stripbytecount_p,
|
||||
(td->td_nstrips + delta) * sizeof (uint64));
|
||||
if (new_stripoffset == NULL || new_stripbytecount == NULL) {
|
||||
if (new_stripoffset)
|
||||
@@ -697,11 +720,11 @@ TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module)
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "No space to expand strip arrays");
|
||||
return (0);
|
||||
}
|
||||
td->td_stripoffset = new_stripoffset;
|
||||
td->td_stripbytecount = new_stripbytecount;
|
||||
_TIFFmemset(td->td_stripoffset + td->td_nstrips,
|
||||
td->td_stripoffset_p = new_stripoffset;
|
||||
td->td_stripbytecount_p = new_stripbytecount;
|
||||
_TIFFmemset(td->td_stripoffset_p + td->td_nstrips,
|
||||
0, delta*sizeof (uint64));
|
||||
_TIFFmemset(td->td_stripbytecount + td->td_nstrips,
|
||||
_TIFFmemset(td->td_stripbytecount_p + td->td_nstrips,
|
||||
0, delta*sizeof (uint64));
|
||||
td->td_nstrips += delta;
|
||||
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
||||
@@ -720,12 +743,12 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc)
|
||||
uint64 m;
|
||||
int64 old_byte_count = -1;
|
||||
|
||||
if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) {
|
||||
if (td->td_stripoffset_p[strip] == 0 || tif->tif_curoff == 0) {
|
||||
assert(td->td_nstrips > 0);
|
||||
|
||||
if( td->td_stripbytecount[strip] != 0
|
||||
&& td->td_stripoffset[strip] != 0
|
||||
&& td->td_stripbytecount[strip] >= (uint64) cc )
|
||||
if( td->td_stripbytecount_p[strip] != 0
|
||||
&& td->td_stripoffset_p[strip] != 0
|
||||
&& td->td_stripbytecount_p[strip] >= (uint64) cc )
|
||||
{
|
||||
/*
|
||||
* There is already tile data on disk, and the new tile
|
||||
@@ -734,7 +757,7 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc)
|
||||
* more data to append to this strip before we are done
|
||||
* depending on how we are getting called.
|
||||
*/
|
||||
if (!SeekOK(tif, td->td_stripoffset[strip])) {
|
||||
if (!SeekOK(tif, td->td_stripoffset_p[strip])) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Seek error at scanline %lu",
|
||||
(unsigned long)tif->tif_row);
|
||||
@@ -747,17 +770,17 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc)
|
||||
* Seek to end of file, and set that as our location to
|
||||
* write this strip.
|
||||
*/
|
||||
td->td_stripoffset[strip] = TIFFSeekFile(tif, 0, SEEK_END);
|
||||
td->td_stripoffset_p[strip] = TIFFSeekFile(tif, 0, SEEK_END);
|
||||
tif->tif_flags |= TIFF_DIRTYSTRIP;
|
||||
}
|
||||
|
||||
tif->tif_curoff = td->td_stripoffset[strip];
|
||||
tif->tif_curoff = td->td_stripoffset_p[strip];
|
||||
|
||||
/*
|
||||
* We are starting a fresh strip/tile, so set the size to zero.
|
||||
*/
|
||||
old_byte_count = td->td_stripbytecount[strip];
|
||||
td->td_stripbytecount[strip] = 0;
|
||||
old_byte_count = td->td_stripbytecount_p[strip];
|
||||
td->td_stripbytecount_p[strip] = 0;
|
||||
}
|
||||
|
||||
m = tif->tif_curoff+cc;
|
||||
@@ -774,9 +797,9 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc)
|
||||
return (0);
|
||||
}
|
||||
tif->tif_curoff = m;
|
||||
td->td_stripbytecount[strip] += cc;
|
||||
td->td_stripbytecount_p[strip] += cc;
|
||||
|
||||
if( (int64) td->td_stripbytecount[strip] != old_byte_count )
|
||||
if( (int64) td->td_stripbytecount_p[strip] != old_byte_count )
|
||||
tif->tif_flags |= TIFF_DIRTYSTRIP;
|
||||
|
||||
return (1);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user