Compare commits

..

1663 Commits

Author SHA1 Message Date
361bc70fe3 Merge branch hotfix/v8.2.1 into hotfix/v8.2.2 2024-11-22 10:46:56 +00:00
6d68d7aee5 . 2024-11-19 23:58:51 +03:00
61e6b54710 . 2024-11-19 16:44:39 +03:00
65ba8ffd3b Add method for get document type 2024-11-19 15:08:16 +03:00
d2713d0cfd fix perm 2024-11-19 11:24:16 +03:00
099ebc3de9 Enable JS error logs in release mode 2024-11-15 13:57:43 +03:00
8ad76e4e1f Fix bug 68072 2024-11-13 01:33:43 +03:00
029e6c6df7 Merge branch hotfix/v8.2.1 into master 2024-11-12 12:49:59 +00:00
2f525c1e4f Remove using iterator after remove it from list 2024-11-11 14:32:26 +03:00
e979defdee Add param for disable own xml wrappers 2024-11-09 00:21:05 +03:00
cc585185dd Fix bug 71045 2024-11-08 23:03:58 +03:00
9a5240cbba For bug 70996 2024-11-08 19:58:09 +03:00
ab2ab7a407 Merge pull request 'Fix bug 71505' (#95) from fix/bug-71505 into hotfix/v8.2.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/95
2024-11-08 09:07:45 +00:00
62c401ae5b Refactoring 2024-11-08 11:51:12 +03:00
c470363ec0 Fix template parameter redefines default argument 2024-11-08 10:01:50 +03:00
25be50f058 Fix unresolved external symbol, delete include 2024-11-07 22:55:12 +03:00
10931f937a implementation moved to cpp 2024-11-07 21:49:12 +03:00
647c8a3cde Without template 2024-11-07 18:39:20 +03:00
1d4f9b5c41 Reduce _CSoftMask 2024-11-07 18:21:41 +03:00
3de464a31e for bug #71527 2024-11-07 18:01:24 +03:00
3429e8b345 Fix bug 71505 2024-11-07 17:05:16 +03:00
485dcb5272 Fix write int in StringBuilder 2024-11-07 14:27:22 +03:00
1c9a9f53e3 fix bug #52676 2024-11-07 12:35:40 +03:00
ebaf0eb43a Fix bug with patch transform & unused memory 2024-11-06 07:35:46 +00:00
eab40d6bb2 fix bug #71478 2024-11-05 18:31:23 +03:00
8e51f9bdbb for bug #71449 2024-11-05 18:01:01 +03:00
ac8c99415f fix bug #71415 2024-11-02 19:26:45 +03:00
5a6a2f800f Fix bug 65824 2024-11-02 15:21:53 +03:00
1286dbaaaf Fix bug with numeric limits 2024-11-01 10:13:57 +00:00
1dbeea42b8 Fix build 2024-11-01 11:18:11 +03:00
a5ea301e3e fix bug #71334 2024-11-01 10:22:21 +03:00
fb40437d21 fix bug #53148 2024-11-01 09:37:20 +03:00
b00fbeff53 Fix bug #69024 2024-10-31 09:42:40 +00:00
819d1fad17 fix bug #71349 2024-10-31 11:24:20 +03:00
ce88c4ca95 Fix pattern bbox offset 2024-10-30 17:58:01 +03:00
a69a992a0d Fix bug 71330 2024-10-30 16:04:57 +03:00
949aed7bb4 Fix bug 71045 2024-10-30 14:17:48 +03:00
6ec4191483 Fix bug 71308 2024-10-30 12:30:33 +03:00
3401c2b02e Fix bug 70986 2024-10-29 15:05:49 +03:00
0dd0ad0023 Fix unbalanced text operator 2024-10-29 14:50:06 +03:00
1c2501eeb1 Merge pull request 'release/v8.2.0' (#85) from release/v8.2.0 into hotfix/v8.2.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/85
2024-10-29 10:50:11 +00:00
0d443743a8 Merge pull request 'fix/docx-renderer' (#79) from fix/docx-renderer into hotfix/v8.2.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/79
2024-10-29 10:49:29 +00:00
8c7a22b726 fix bug #70715 2024-10-29 13:39:55 +03:00
a14b3eb8e2 Fix bug 70952 2024-10-29 11:40:09 +03:00
6eaf590844 For bug #71100 2024-10-29 07:43:06 +00:00
fac279ba81 Fix bug #71100 2024-10-29 07:43:06 +00:00
571a7ee2d1 fix bug #71047 2024-10-29 10:13:34 +03:00
adb6d7bbc2 Remove debug logs by default 2024-10-28 21:22:40 +03:00
f7fa638591 Fix bug 69828 2024-10-28 19:11:56 +03:00
edfa558a38 Merge pull request 'Fix pdf widget AP' (#84) from fix/pdf-widget into hotfix/v8.2.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/84
2024-10-28 15:11:26 +00:00
b80ada4b4e Fix old server 2024-10-28 18:06:04 +03:00
492b821472 Fix old server 2024-10-28 17:44:50 +03:00
a8ce7eaad3 Fix crash on v8 engine 2024-10-28 15:49:28 +03:00
8cf78b9e58 Fix write listbox 2024-10-28 15:40:28 +03:00
28bcfafcc6 Fix change font 2024-10-28 15:40:28 +03:00
e527db9515 Write Text Widget AP 2024-10-28 15:40:27 +03:00
db2660a1a3 Text Widget write 2024-10-28 15:40:26 +03:00
03919dcb33 fix bug #71238 2024-10-26 18:10:52 +03:00
46588b05b1 Merge pull request 'fix/nativeDraw' (#82) from fix/nativeDraw into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/82
2024-10-26 13:32:02 +00:00
dc0ea6a7f3 Add fromJS functionality for Images 2024-10-26 16:28:48 +03:00
a84c8cc471 Add support Images in nativeEditors 2024-10-26 15:06:09 +03:00
cd1bb3b658 Merge pull request 'release/v8.2.0' (#81) from release/v8.2.0 into fix/nativeDraw
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/81
2024-10-25 13:44:43 +00:00
cd71bc0672 Fix build 2024-10-25 14:52:55 +03:00
14c9896773 Merge pull request 'Fix bug #71134' (#78) from fix/bug-71134 into hotfix/v8.2.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/78
2024-10-25 10:01:12 +00:00
19694bf32d Adjusted the definition of the possibility of obtaining a local image in html 2024-10-25 12:54:11 +03:00
96e1280082 fix bug #71076 2024-10-25 08:41:33 +03:00
ce41e42851 . 2024-10-25 07:38:01 +03:00
b414fb961e Develop native drawer 2024-10-25 00:57:02 +03:00
0370948e98 Merge pull request 'feature/cvalue-image' (#77) from feature/cvalue-image into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/77
2024-10-24 17:57:51 +00:00
ccbd9da871 Add externalize method to Image 2024-10-24 20:56:21 +03:00
cec8402adc Add tests 2024-10-24 20:57:34 +04:00
fd90f73c19 Add functionality 2024-10-24 20:57:29 +04:00
6447aeafa5 . 2024-10-24 15:03:37 +03:00
aa3e0759d7 Fix bug 71025 2024-10-24 11:40:47 +03:00
3db4bdc93f Fix bug 71169 2024-10-24 11:09:52 +03:00
5692bee77a Fix gradients in xps 2024-10-23 19:12:27 +03:00
d6864e044a Fix curves intersection 2024-10-23 18:31:43 +03:00
ad69100d3f fix bug #70790 2024-10-23 17:28:22 +03:00
b05a95d54e Merge pull request 'Fixed bugs in metafile conversion' (#74) from fix/Metafile into hotfix/v8.2.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/74
2024-10-23 12:00:38 +00:00
87a09faefb Fix bug #71134 2024-10-23 14:39:51 +03:00
5e35517d71 Merge pull request 'Fix hlinx binary reading' (#75) from fix/bug71042 into hotfix/v8.2.1
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/75
2024-10-23 11:30:53 +00:00
ca94882699 Fix hlinx binary reading 2024-10-23 17:27:21 +06:00
77ece713ee fix bug #71042 2024-10-22 10:50:04 +03:00
5b44611560 write alternative in binary 2024-10-20 20:27:27 +03:00
d43a724ee6 Fix drop cap logic 2024-10-18 16:20:07 +03:00
f57af6ecc1 Refactoring 2024-10-18 13:56:13 +03:00
af77bf3f77 Fix bug 70795 2024-10-18 13:42:51 +03:00
4578731001 Merge branch 'fix/fix-bugs-8.2.1' into hotfix/v8.2.1 2024-10-18 13:33:19 +03:00
72566e8064 Fix bug #70873 2024-10-18 13:32:37 +03:00
346f0e9dd0 Fixed a problem with writing the font name in metafile to svg conversion 2024-10-18 13:25:42 +03:00
e32bd8fd96 Fixed calcalate final transform 2024-10-18 13:25:30 +03:00
de51108ba7 Fixed unnecessary insertion of xml in an html document 2024-10-18 13:24:32 +03:00
83a6e52df2 Fix clip reset 2024-10-18 12:21:32 +03:00
4eb761eec3 fix bug #71000 2024-10-17 16:48:29 +03:00
baf9fb4a93 Merge branch release/v8.2.0 into master 2024-10-17 11:10:05 +00:00
0b8e833e77 fix bug #69488 2024-10-17 10:06:45 +03:00
94bb0f5306 Fix bug 70987 2024-10-16 17:23:50 +03:00
fc3ce62ec7 fix bug #70698 2024-10-15 08:50:11 +00:00
3fac5441cb Merge branch 'release/v8.2.0' into fix/fix-bugs-8.2.1 2024-10-15 11:09:22 +03:00
32bd8166d7 for bug #60796 2024-10-15 11:07:47 +03:00
4acdd6dd20 Fix bug 70888 2024-10-14 22:18:52 +03:00
518a4ddb2b Fix bug 70840 2024-10-14 15:06:44 +00:00
895082cc93 Fix bug 70823 2024-10-14 15:06:44 +00:00
f16fa656e9 Fix types 2024-10-14 14:46:46 +00:00
f16318aebb Add check ooxml limits 2024-10-14 14:46:46 +00:00
a5c28b72bb for bug #70894 2024-10-14 17:04:27 +03:00
290d50ebcc Fix empty contents 2024-10-14 15:11:25 +03:00
3de1152a3f Fix bug 70813 2024-10-14 13:43:07 +03:00
109c891c1b Improve used memory 2024-10-14 10:34:46 +03:00
1b2d803976 For bug 70792. Improve memory usage in the AddCurveIntersection method 2024-10-14 09:46:00 +03:00
9f4613b15c Fix bug 70578 2024-10-13 11:09:35 +03:00
ab7e8a07be Fixed bugs with clipping images in metafile conversion 2024-10-11 20:23:53 +03:00
7603aceee1 Optimization of image reflection in metafiles 2024-10-11 20:14:13 +03:00
7ea66d0bee For bug #70825 2024-10-11 20:14:02 +03:00
0e8230cc7f Fix inverseTransform in metafile conversion 2024-10-11 20:13:35 +03:00
0229d928ab Fix bug 70825 2024-10-11 16:54:25 +03:00
4bdea2d154 fix bug #70717 2024-10-11 11:14:10 +03:00
751a5d4d7d Fix bug 69723 2024-10-10 23:02:33 +03:00
4b1bd2fb70 fix bug #70790 2024-10-10 15:28:26 +03:00
cbbf650c56 Fix bug #69036 2024-10-10 09:50:29 +00:00
b55cd751d1 Merge branch 'release/v8.2.0' of git.onlyoffice.com:ONLYOFFICE/core into release/v8.2.0 2024-10-10 12:22:01 +03:00
c7d5b60637 Fix ios build 2024-10-10 12:21:55 +03:00
666f5c2f9e fix bug #70778 2024-10-10 10:34:51 +03:00
42b432b4de Add engine for base32 2024-10-10 02:59:18 +03:00
08ca60091c Fix bug 70130 2024-10-09 16:10:00 +03:00
88d9827d3f Fix bug 70129 2024-10-09 16:06:42 +03:00
bae672f718 Fix bug 68986 2024-10-09 15:51:19 +03:00
00344df9ad Fix for -D with brackets 2024-10-09 11:27:54 +03:00
cfb060e142 Fix build 2024-10-09 11:05:28 +03:00
0565e6164b Add data for hard update hunspell module 2024-10-09 10:47:24 +03:00
306cc3f985 For bug 70578 2024-10-08 23:31:46 +03:00
2739dd3abd Fix bug 69154 2024-10-08 22:54:19 +03:00
70e6df5aae fix bug #70440 2024-10-08 22:00:45 +03:00
96030aa322 Set timelimits of dictionaries tester bigger 2024-10-08 15:18:40 +03:00
fee801eeeb Merge pull request 'Add custom timelimits logic in dictionariestester' (#59) from fix/dictionariestester into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/59
2024-10-08 11:55:37 +00:00
750273b526 Change timelimits 2024-10-08 14:51:48 +03:00
cfdb541c28 Add custom timelimits logic in dictionariestester 2024-10-08 14:36:30 +03:00
11121961d9 Fix typo 2024-10-08 08:47:12 +00:00
45828709ee Merge pull request 'Fix bug #70515' (#57) from fix/bug70515 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/57
2024-10-08 08:15:23 +00:00
40916e5ccc Merge pull request 'Fix bug 60796' (#56) from fix/bug60796 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/56
2024-10-08 08:07:18 +00:00
319610c58d Fix bug 60796 2024-10-08 10:22:32 +03:00
1837a2737e Fix RefTo id 2024-10-07 15:17:03 +00:00
686fc60860 For bug 61203 2024-10-07 15:17:03 +00:00
51216f27f4 Fix bug 70466 2024-10-07 17:47:12 +03:00
2eb33ddd22 Merge pull request 'Fix bug #70484' (#30) from fix/bug70484 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/30
2024-10-07 14:05:10 +00:00
58c80b052b Merge pull request 'Fix bug #70492' (#34) from fix/bug70492 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/34
2024-10-07 14:04:42 +00:00
5eee408eeb Merge pull request 'Fix bug #70617' (#54) from fix/bug70617 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/54
2024-10-07 14:04:20 +00:00
b6ae1f272c Fix bug #70617 2024-10-07 15:41:28 +05:00
045f23d921 Fix bug 68091 2024-10-07 02:46:38 +03:00
d06b52988c Fix bug 70352 2024-10-06 18:56:06 +00:00
4717b47388 Fix bug in metafile conversion 2024-10-06 17:11:32 +00:00
31ce9f6a18 Fix bug #66337 2024-10-06 17:11:32 +00:00
e44c9fa4c9 Fix bug #31062 2024-10-06 17:11:32 +00:00
3c59ba7a13 fixed a bug with the location of the embedded metafile 2024-10-06 17:11:32 +00:00
42e84249e8 For bug #68708 2024-10-06 17:11:32 +00:00
e2dbde8722 fix bug #70163 2024-10-06 11:43:33 +03:00
36c67d79d5 fix bug #70717 2024-10-06 11:17:16 +03:00
cdc14d22f0 fix bug #70684 2024-10-04 22:22:16 +03:00
baed05236b fix bug #70368 2024-10-04 20:41:18 +03:00
c644f94c0b fix bug #69104 2024-10-04 20:23:36 +03:00
087e4433f2 For bug 69977 2024-10-04 13:31:36 +00:00
bc11a5cf5f Fix bug 70574 2024-10-04 16:28:30 +03:00
d86303e290 Fix bug 69704 2024-10-03 15:44:14 +00:00
51f1faa51a Fix uncheckedsqrfx conversion to xlsx
(cherry picked from commit 9f62108376)
2024-10-03 18:12:10 +03:00
6775dccc2c Fix font tables 2024-10-03 13:29:46 +00:00
ee3b4c612d Merge pull request 'Fix bug 70563' (#45) from fix/bug-70563 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/45
2024-10-03 12:37:44 +00:00
1144bb166c Remove using bitcode on ios 2024-10-03 14:19:08 +03:00
a9752208f6 Fix bug #70515 2024-10-03 15:43:45 +05:00
84016cf8cf Fix bug 70563 2024-10-03 13:00:18 +03:00
cb7edc373c Disable bitcode for ios builds with xcode 16+ 2024-10-03 12:11:31 +03:00
d1e43d68dc Fix getOriginPage 2024-10-03 11:47:04 +03:00
b5ab5f9b2b Fix bug 70559 2024-10-03 11:31:39 +03:00
761c5bec53 Fix detect allfonts path for builder 2024-10-03 00:11:28 +03:00
8cc7034c22 For bug 70566 2024-10-02 15:48:33 +00:00
ee1c385b54 Fix Bug 70566 2024-10-02 15:48:33 +00:00
ded640825b Fix alpha 2024-10-02 15:48:33 +00:00
84301531c8 . 2024-10-02 17:54:59 +03:00
310cd6d8fd Add full GetContext function 2024-10-02 13:51:43 +00:00
2d37cf634a Add new dependent libraries 2024-10-02 13:51:43 +00:00
04880b4e1d Merge pull request 'Fix bug 70590' (#41) from fix/bug-70590 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/41
2024-10-02 13:38:15 +00:00
1000b5d5bd Merge pull request 'Add full GetContext function to docbuilder python wrapper' (#40) from feature/docbuilder-wrappers-getcontext into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/40
2024-10-02 12:56:45 +00:00
c324b4a11c Add to python wrapper 2024-10-02 16:02:23 +04:00
a51fe4134c fix bug #68406 2024-10-01 19:37:56 +03:00
985d258bc1 Fix bug with rotated crop 2024-10-01 17:22:30 +03:00
fee5c112b4 Merge pull request 'fix bug70534' (#37) from fix/bug70534 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/37
2024-10-01 12:23:24 +00:00
9b50f9fbc2 Fix bug 68091 2024-10-01 14:43:27 +03:00
10f770fdbc Fix bug 70566 2024-10-01 13:10:52 +03:00
eb53c40135 fix 2024-10-01 12:32:29 +03:00
ded1655a04 Fix bug 70561 2024-10-01 12:20:54 +03:00
20c11889aa Fix bug 70590 2024-10-01 11:49:33 +03:00
910c2418d6 fix chartEx 2024-10-01 08:33:39 +03:00
e6ffdc0ae8 Merge remote-tracking branch 'origin/for-bug#68406' into release/v8.2.0 2024-09-30 19:27:52 +03:00
0335d330b8 Merge pull request 'Fix bug 69602' (#33) from fix/pdf-bugs into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/33
2024-09-30 14:55:14 +00:00
af2e86e777 Fix name OUserID 2024-09-30 17:16:30 +03:00
bcf7d08c51 Fix bug 69602 2024-09-30 16:26:03 +03:00
11886dcdf7 Add user-id for annots 2024-09-30 15:05:39 +03:00
615d0b682c formula size calculation 2024-09-30 12:50:46 +03:00
535028fa0e For bug 70559 2024-09-30 12:44:09 +03:00
5a6386e08b Fix bug #70492 2024-09-27 20:07:14 +05:00
7ca8b22160 fix bug #70518 2024-09-27 16:59:57 +03:00
ec16e247e9 Fix build 2024-09-27 13:39:27 +00:00
9a76575082 Fix bug 2024-09-27 13:39:27 +00:00
c1a586cb56 Fix bug 69974 2024-09-27 16:14:24 +03:00
7707aeb914 Fix NULL borderStyle in FreeText 2024-09-27 15:56:16 +03:00
50a8540f75 Fix build 2024-09-27 15:45:06 +03:00
cc2e755bca Fix bug 2024-09-26 15:18:30 +00:00
9c1efdeac2 Fix bug with text 2024-09-26 15:18:30 +00:00
ea1538bc11 Fix bug in xps 2024-09-26 15:18:30 +00:00
c0d0fb6f5c Critical fix 2024-09-26 15:18:30 +00:00
5e5e07b406 Fix bug 67321 2024-09-26 15:18:30 +00:00
9b5f762420 Fix bug #70484 2024-09-26 17:35:25 +05:00
7020548f06 Merge pull request 'Fix bug 69009' (#28) from fix/docx-renderer into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/28
2024-09-26 10:43:03 +00:00
2d2e15671a Fix bug 69009 2024-09-26 13:36:28 +03:00
00ad32d420 Merge pull request 'For bug #70040' (#27) from fix/bug70040 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/27
2024-09-26 08:23:58 +00:00
ba2cf66c31 Fix build 2024-09-26 10:44:12 +03:00
57ed9d0c32 Fix build 2024-09-26 06:15:42 +00:00
40d82f3287 Fix 2024-09-26 06:15:42 +00:00
9bdcbf0d89 Rollback std::vector 2024-09-26 06:15:42 +00:00
c1774219ec Fix pdf editor build 2024-09-26 06:15:42 +00:00
2a6f0bb1b6 Close any clip-path fix 2024-09-26 06:15:42 +00:00
a23ce22950 Add unit-tests 2024-09-26 06:15:42 +00:00
b4f0d32b6d Fix bugs 2024-09-26 06:15:42 +00:00
83db7f2165 Remove STL from export 2024-09-26 06:15:42 +00:00
3ce03d897d Fix bug 2024-09-26 06:15:42 +00:00
be12237042 Fix bug 2024-09-26 06:15:42 +00:00
cf7252b92d Fix bounds 2024-09-26 06:15:42 +00:00
523f3f24f9 Fix wrong bounds 2024-09-26 06:15:42 +00:00
0196a4bb57 Fix one inters 2024-09-26 06:15:42 +00:00
9ee9192cd4 Refactoring 2024-09-26 06:15:42 +00:00
5df63a58b7 Add more bullets 2024-09-26 06:15:42 +00:00
d107bd5df2 Fix unused font names in PDF 2024-09-26 06:15:42 +00:00
f51c1fced2 Fix bug 69109 2024-09-26 06:15:42 +00:00
86cba0bdcd Fix bug 70340 2024-09-26 06:15:42 +00:00
cceec83568 Transition from pointers to smart pointers 2024-09-26 06:15:42 +00:00
f733543b44 Fix memory leak 2024-09-26 06:15:42 +00:00
bb9d777c14 Refactoring 2024-09-26 06:15:42 +00:00
694dd852d0 Fix bug 2024-09-26 06:15:42 +00:00
18a18eaa40 Fix linux build 2024-09-26 06:15:42 +00:00
fb021b33ec Add limits 2024-09-26 06:15:42 +00:00
95ecd8468a Refactoring 2024-09-26 06:15:42 +00:00
fbb57d7009 Fix memory leak 2024-09-26 06:15:42 +00:00
22e9873208 Done gradients support 2024-09-26 06:15:42 +00:00
2581e9235d Develop rtl support 2024-09-26 06:15:42 +00:00
270fd0601f Fix close path 2024-09-26 06:15:42 +00:00
5f69b4f8e6 Fix bug with gradient 2024-09-26 06:15:42 +00:00
bdaf9fa10b Fix bug 2024-09-26 06:15:42 +00:00
77e64af80c Fix bug with gradient 2024-09-26 06:15:42 +00:00
6e3beac6bf Fix one point inters and refactoring 2024-09-26 06:15:42 +00:00
641297ac48 Fix bug with non-closed-paths 2024-09-26 06:15:42 +00:00
dcca1f06f4 Developing gradients 2024-09-26 06:15:42 +00:00
22d7cfb240 Fix bug 2024-09-26 06:15:42 +00:00
fa51ea21b4 Developing gradient support 2024-09-26 06:15:42 +00:00
7632be9f2f Fix stack overflow 2024-09-26 06:15:42 +00:00
cbf40d36f5 Develop gradient support (in porgress) 2024-09-26 06:15:42 +00:00
2b8e70e67f Add compound paths 2024-09-26 06:15:42 +00:00
4b05eb9a50 Indents fix + gitignore 2024-09-26 06:15:42 +00:00
3221e41e89 Add subtraction for all overlap 2024-09-26 06:15:42 +00:00
58cc6cf6e8 Fix epsilon 2024-09-26 06:15:42 +00:00
c86a8edd30 Fix 2024-09-26 06:15:42 +00:00
db1d6a935f Add metainfo in ToXmlPptx (CContText)
+ fix main in test
2024-09-26 06:15:42 +00:00
cb9589f6b4 Fix curve for pdf 2024-09-26 06:15:42 +00:00
cbad285a9f FIx curve conversion 2024-09-26 06:15:42 +00:00
82a3fa6132 Fix 2024-09-26 06:15:42 +00:00
0821eefbd3 Add figure "Cross" to test 2024-09-26 06:15:42 +00:00
38a9dfcd14 Fix subtract 2024-09-26 06:15:42 +00:00
0f222c15e9 Fix all overlap 2024-09-26 06:15:42 +00:00
d0a554c701 Fix overlap paths 2024-09-26 06:15:42 +00:00
acfec0ceb1 Rollback 2024-09-26 06:15:42 +00:00
899b27d697 Fix bug with stride for adobe 2024-09-26 06:15:42 +00:00
5a5db3e8c6 Fix bug with close 2024-09-26 06:15:42 +00:00
57fdf7eed5 Add test for negative vertices 2024-09-26 06:15:42 +00:00
7f13020f2f Fix bug with no clear clip vector 2024-09-26 06:15:42 +00:00
020298b023 Update clip logic
crop
2024-09-26 06:15:42 +00:00
8eb249056b Fix negative vertices 2024-09-26 06:15:42 +00:00
2ed7e803ca Fix 2024-09-26 06:15:42 +00:00
b9230ef5ff Develop clip + tile images 2024-09-26 06:15:42 +00:00
3907110e44 Fix + refactoring 2024-09-26 06:15:42 +00:00
787575a53f Fix including paths 2024-09-26 06:15:42 +00:00
b58554a3da Refactorting
in progress
2024-09-26 06:15:42 +00:00
9e8c0dfb16 Add clip logic
clip on clip is not working for now
2024-09-26 06:15:42 +00:00
6831820dd4 Fix 2024-09-26 06:15:42 +00:00
cac79cb66e Refactor includes + fix build dll 2024-09-26 06:15:42 +00:00
323213a63d Refacoring 2024-09-26 06:15:42 +00:00
473ef17be3 Fix 2024-09-26 06:15:42 +00:00
5e56d26a06 Fix bugs 2024-09-26 06:15:42 +00:00
a390c1ee18 Fix 2024-09-26 06:15:42 +00:00
4158ebcd98 FIx 2024-09-26 06:15:42 +00:00
7fc65a84ab Fix 2024-09-26 06:15:42 +00:00
69ffd656af Fix 2024-09-26 06:15:42 +00:00
cb929fc5c5 Fix 2024-09-26 06:15:42 +00:00
7cd7c9f98f Refactoring Winding 2024-09-26 06:15:42 +00:00
015c10495c Refactoring 2024-09-26 06:15:42 +00:00
e973c8f70b Refactoring test 2024-09-26 06:15:42 +00:00
a77987488b Refactoring 2024-09-26 06:15:42 +00:00
1cfd17e2f3 Fix and Refactoring 2024-09-26 06:15:42 +00:00
b4c6f69cee Add Test for Clip 2024-09-26 06:15:42 +00:00
67194499a8 Fix 2024-09-26 06:15:42 +00:00
9ec6489083 Fix 2024-09-26 06:15:42 +00:00
3971400c78 Fix 2024-09-26 06:15:42 +00:00
e21ed47019 Finish CGraphicsPathClip 2024-09-26 06:15:42 +00:00
2cf83df7d0 add new methods for clip 2024-09-26 06:15:42 +00:00
7f96336e75 add mathematical functions for clip 2024-09-26 06:15:42 +00:00
99da1e3b8c Move CPathForClip methods to CGraphicsPath 2024-09-26 06:15:42 +00:00
6d152880bd Add Clip lib for GraphicsPath 2024-09-26 06:15:42 +00:00
dd9fca2a5c Fix hor/ver shape trough logic 2024-09-26 06:15:42 +00:00
67043cf718 Fix & add logic 2024-09-26 06:15:42 +00:00
ba239f139d Images -> shapes 2024-09-26 06:15:42 +00:00
a99733c5a1 Fix bug 70119 2024-09-25 23:42:03 +03:00
a60bc542c7 Fix bug 70043 2024-09-25 14:36:12 +00:00
97d36fa1cd Fix multiline Text Widget indentation 2024-09-25 14:36:12 +00:00
87fa0f93be Fix bug 69972 2024-09-25 14:36:12 +00:00
29a48da730 Fix bug 69976 2024-09-25 14:36:12 +00:00
e0352541be Fix bug 69990 2024-09-25 16:53:33 +03:00
2e26a3697d For bug #70040 2024-09-25 18:23:21 +05:00
cd124d5112 Fix page sizes on build pdf file 2024-09-25 15:28:08 +03:00
4242d32d95 Fix release build 2024-09-25 12:18:18 +03:00
a6b5e7e010 Merge remote-tracking branch 'origin/release/v8.2.0' into release/v8.2.0 2024-09-24 22:05:25 +03:00
57800ec8dd fix bug #33177 2024-09-24 21:46:58 +03:00
0f3de35eb4 Fix bug 69927 2024-09-24 21:44:52 +03:00
8c83b18216 fix bug #70440 2024-09-24 21:23:16 +03:00
e1c2bf19d9 Fix build 2024-09-24 18:08:40 +03:00
f38767ccbb Merge pull request 'Fix bug #69036' (#22) from fix/bug-69036 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/22
2024-09-24 11:25:57 +00:00
fc94de8549 Refactoring and improving the debug mod 2024-09-24 11:48:59 +03:00
812fae8f6c Fix bug #69036 2024-09-24 11:46:34 +03:00
c938e2756e Merge pull request 'Fix bug #44363' (#20) from fix/bug44363 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/20
2024-09-24 07:23:22 +00:00
5679a7902f Merge pull request 'Fix placeholder styles conversion' (#19) from fix/placeholder_conversion into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/19
2024-09-24 07:22:22 +00:00
056bfb84ce Fix typo 2024-09-23 22:40:21 +03:00
2d745de7e2 Merge branch 'feature/pdf-font' into release/v8.2.0 2024-09-23 22:02:48 +03:00
a5c73127fd Fix pdf bugs (add build with embedded fonts in changes) 2024-09-23 21:59:36 +03:00
f0f4e39f5c Fix bug 70042 2024-09-23 19:08:27 +03:00
b536d6eb41 Create test GetEmbeddedFont 2024-09-23 15:43:48 +03:00
0af65b1137 Convert odp placeholder styles to pptx 2024-09-23 16:44:16 +05:00
5c3a697880 Fix for drawingfile 2024-09-23 13:31:55 +03:00
1b8c59ff87 Separate GetFontPath 2024-09-23 13:15:39 +03:00
6b4b645180 Create GetEmbeddedFontPath 2024-09-23 13:09:05 +03:00
30868b81bc Fix bug #70339 2024-09-21 16:16:53 +03:00
4c44edc9c9 Merge branch 'fix/bug70318' into fix/placeholder_conversion 2024-09-21 00:07:59 +05:00
60f9021bdd Merge pull request 'Fix bug #70318' (#15) from fix/bug70318 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/15
2024-09-19 14:57:52 +00:00
fd90fbae21 Fix bug #70318 2024-09-19 13:01:07 +05:00
c4979075aa Merge pull request 'Fix bug #70320' (#14) from fix/bug-70320 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/14
2024-09-19 05:16:16 +00:00
6c067ba6ee Merge pull request 'Fix SVG conversion' (#13) from fix/SVG into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/13
2024-09-19 05:16:01 +00:00
2456501f1d Fixes for txt/csv 2024-09-19 08:03:30 +03:00
07c0c58375 Fix bug #70320 2024-09-18 20:50:33 +03:00
db28751875 Fix placeholder conversion 2024-09-18 22:02:54 +05:00
81c9ae120f Fix bug 70293 2024-09-18 14:45:20 +03:00
830c5ec12c fix bug #46132 2024-09-18 10:52:04 +03:00
375f79cdac fix bug #69904 2024-09-17 21:22:24 +03:00
33627ab79c Added support for marker orientation in svg conversion 2024-09-17 19:45:13 +03:00
9f81e37196 fox bug #70227 2024-09-17 18:11:18 +03:00
32a409bb13 Merge pull request 'Enter new contexts by default' (#10) from feature/scoped-context into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/10
2024-09-17 14:27:31 +00:00
b53a1b3cd6 Merge pull request 'Add static CreateObject function to builder' (#11) from fix/bug70010 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/11
2024-09-17 14:27:12 +00:00
f5f0630b2d Redesigned the drawing of markers in svg conversion 2024-09-16 22:02:10 +03:00
19e5a2db2d fix bug #70240 2024-09-16 19:06:11 +03:00
8ad7b123aa Fix build pdf files 2024-09-16 14:39:43 +03:00
312a95d9e1 Fix bug #70010 2024-09-13 16:08:42 +04:00
0ac882b207 Merge branch hotfix/v8.1.3 into release/v8.2.0 2024-09-13 10:37:31 +00:00
4378becd0b Enter new contexts by default 2024-09-13 14:30:53 +04:00
8c62dc448a Fixed bug width text position in svg conversion 2024-09-12 20:04:22 +03:00
7f7e89babf fix bug #69781 2024-09-12 18:07:19 +03:00
d89d63e0db fix bug #70136 2024-09-12 14:50:41 +03:00
42a4fe53dd fix bug #70160 2024-09-12 11:01:32 +03:00
f738aa95ad . 2024-09-12 10:38:26 +03:00
a68b7e7354 fix bug #70134 2024-09-11 17:38:40 +03:00
3c16ba01f0 Fix max font size in svg conversion 2024-09-11 13:23:36 +03:00
106f448042 Fix build for xp 2024-09-11 12:15:46 +04:00
81d90420dd Normalize JSON in tests 2024-09-10 22:27:54 +00:00
2673b15835 Implement objects parsing in FromJSON 2024-09-10 22:27:54 +00:00
436d9ecdb7 Implement arrays parsing in FromJSON 2024-09-10 22:27:54 +00:00
150079e2f6 Implement FromJSON for primitives 2024-09-10 22:27:54 +00:00
ad18d65f7c Implement toJSON 2024-09-10 22:27:54 +00:00
56551c3745 Add IsBool function to Java wrapper
+ Add functionality of generating JNI headers
2024-09-10 22:25:25 +00:00
71342eb03d Add IsBool function to NET wrapper 2024-09-10 22:25:25 +00:00
f811822364 Fix bug #70046 2024-09-10 22:25:25 +00:00
765c27bdab Remove creation of empty string by default 2024-09-10 22:24:06 +00:00
f90022c50c Fix bug #70086 2024-09-10 22:24:06 +00:00
e345eff63a Fix build pdf files 2024-09-11 01:09:50 +03:00
0b16086ff5 Fix bugs in svg conversion and optimization 2024-09-10 21:08:12 +03:00
5904bb3507 Fix bug #69865 2024-09-10 21:07:39 +03:00
8917390185 binary mrun 2024-09-10 16:25:23 +03:00
6a2d3838ae Fix bug #70044 2024-09-10 03:24:57 +05:00
493cec92c6 Move methods from graphics renderer to base interface 2024-09-09 15:03:59 +03:00
f21d92ee92 Enable drawing file in doctrenderer 2024-09-09 14:23:54 +03:00
d1dd3b4791 Merge pull request 'fix bug70020' (#5) from fix/bug70020 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/5
2024-09-09 08:24:43 +00:00
b79c173f59 Add dependencies for doctrenderer 2024-09-09 07:48:27 +03:00
5a7909a901 Fix pivot cache definition conversion 2024-09-06 15:46:26 +06:00
47ec9ab80d Fix bugs and refactoring 2024-09-05 10:23:31 +00:00
8a56072454 Fix bugs and refactoring 2024-09-05 10:23:31 +00:00
b6593c89a3 Merge pull request 'Fix bug #69988' (#2) from fix/bug69988 into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/2
2024-09-05 08:59:29 +00:00
978ec43047 printPr 2024-09-04 20:01:10 +03:00
f6c48c1edb Fix bug #70039 2024-09-04 20:48:28 +05:00
386bce9b68 Fix bug #70020 2024-09-04 20:22:34 +06:00
ceeaff9585 Fixes for pdf 2024-09-04 14:51:31 +03:00
20a8de9440 Fix bug #69988 2024-09-04 16:32:52 +05:00
1cf1d16cf5 Merge pull request 'Fix non-existing dicts bug' (#1) from fix/dictionariestester into release/v8.2.0
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/1
2024-09-04 09:29:28 +00:00
ae98f0551a Delete src/dst dictionariestester 2024-09-04 12:27:52 +03:00
eddfd2abe4 Fix non-existing dicts bug 2024-09-04 12:25:02 +03:00
4c9c79628f Fix bug #69957 2024-09-03 13:20:36 +05:00
7625183fe3 Merge pull request #1636 from ONLYOFFICE/fix/office-utils
Fix Bug 69900
2024-09-02 06:08:59 -07:00
0567de6d9f . 2024-09-02 11:49:18 +03:00
7f23f77866 fix bug #69770 2024-09-02 10:31:01 +03:00
b3ce882885 Merge pull request #1635 from ONLYOFFICE/fix/bug69889
Fix bug #69889
2024-08-29 18:42:18 +03:00
2685f2807c fix bug #69947 2024-08-29 18:11:58 +03:00
a748b08143 for bug #69781 2024-08-29 18:08:37 +03:00
a14e684528 Fix Bug 69900 2024-08-29 18:00:26 +03:00
58c35139ea Merge branch 'fix/bug44363' of https://github.com/ONLYOFFICE/core into fix/bug44363
# Conflicts:
#	OdfFile/Reader/Format/text_elements.cpp
2024-08-29 19:41:23 +05:00
7d804f1c70 Fix bug #44363 2024-08-29 19:39:34 +05:00
ddf33fb441 Fix bug #69889 2024-08-29 18:07:35 +06:00
64dfeee050 Merge pull request #1634 from ONLYOFFICE/fix/docbuilder-snapshots
Some small fixes in snapshot related code
2024-08-29 04:27:53 -07:00
ea58d59b68 Remove static functions from editors.h 2024-08-29 14:12:22 +04:00
a73c9cc659 Some defines and typo fixes 2024-08-29 13:52:51 +04:00
58b927edb6 Merge pull request #1633 from ONLYOFFICE/fix/bug-69862
Fix bugs 69862, 69863
2024-08-29 01:51:28 -07:00
c7b72698a8 Fix ctm for write 2024-08-29 10:52:13 +03:00
b00c2eb773 Fix bug 69862 2024-08-29 10:45:55 +03:00
13088c6ed4 fix bug #69892 2024-08-28 16:45:32 +03:00
3b47ce04b4 Disable embedded drawing file 2024-08-28 16:07:31 +03:00
c9117df33d Fix work with snapshots 2024-08-28 15:57:05 +03:00
1771ce2354 Fix typo 2024-08-28 13:30:07 +03:00
e9248fe046 Merge pull request #1632 from ONLYOFFICE/feature/pdfBuild
Feature/pdf build
2024-08-28 03:08:50 -07:00
447e1f5ccc Fix for snapshots 2024-08-28 13:08:06 +03:00
94a67ed007 Fix build 2024-08-28 10:45:16 +03:00
06ee659edc Fixwork with replaceAll function 2024-08-27 23:07:25 +03:00
fe35178e26 Add support snapshots 2024-08-27 22:52:05 +03:00
13590d4c2e Refactoring work with cache 2024-08-27 13:04:20 +03:00
2ce1ee6b33 Merge pull request #1630 from ONLYOFFICE/fix/bug-69855
Fix bug 69855
2024-08-27 03:00:37 -07:00
ea77177077 Fix bug 69855 2024-08-27 12:30:31 +03:00
39c03bb5be Merge pull request #1628 from ONLYOFFICE/fix/bug56747
Fix bug #56747
2024-08-26 15:17:28 +03:00
5bbff01782 Merge remote-tracking branch 'origin/fix/bug57197' into release/v8.2.0 2024-08-26 15:14:52 +03:00
9cee5480b6 Merge remote-tracking branch 'origin/fix/bug61364' into release/v8.2.0 2024-08-26 15:13:38 +03:00
5debf76cda Merge remote-tracking branch 'origin/fix/bug59708' into release/v8.2.0 2024-08-26 15:13:11 +03:00
d5ebbf0542 Merge pull request #1627 from ONLYOFFICE/fix/bug63952
Fix bug #63952
2024-08-26 15:11:11 +03:00
84fc9f876e Add flag for fonts generation 2024-08-26 13:56:36 +03:00
7d118102a5 fix bug #69846 2024-08-25 18:43:19 +03:00
c87a043bd0 fix bug #69847 2024-08-25 18:34:30 +03:00
a72fcb705b fix bug #69850 2024-08-25 18:12:50 +03:00
dbd8344e6d Fix bug #63952 2024-08-24 19:37:44 +05:00
8b56f22d76 Fix bug #59708 2024-08-22 22:58:17 +05:00
5efb325394 Merge pull request #1626 from ONLYOFFICE/fix/bug-58084
Fix bug 58084
2024-08-22 07:12:32 -07:00
d61fe20d12 Merge pull request #1625 from ONLYOFFICE/fix/bug-65310
Fix bug 65310
2024-08-22 07:11:07 -07:00
1ac4ec3b0d Fix bug 58084 2024-08-22 15:16:55 +03:00
6ebccd7f4a Add DjVu test 2024-08-22 14:25:37 +03:00
685f8d2442 Fix bug 65310 2024-08-22 14:25:06 +03:00
5564e397ca Fix bug #61364 2024-08-22 14:13:50 +05:00
12e1f1f992 Fix bug #61364 2024-08-22 14:12:40 +05:00
e8cf13e89d Merge pull request #1624 from ONLYOFFICE/fix/bug66675
Fix bug #66675
2024-08-22 10:35:03 +03:00
ec3d6fa05b Fix bug #61364 2024-08-22 02:00:42 +05:00
c0f4ce46f0 Fix undefined values in conversion 2024-08-21 20:43:00 +06:00
e91c72a265 Fix bug #57197 2024-08-21 16:40:13 +05:00
c4530caac1 Merge pull request #1623 from ONLYOFFICE/release/v8.2.0
Release/v8.2.0
2024-08-21 04:17:49 -07:00
c018d57081 fix bug #69634 2024-08-21 12:52:16 +03:00
43f49b7a9d fix bug #69775 2024-08-21 12:14:48 +03:00
f8e19a7f0b Merge pull request #1620 from ONLYOFFICE/fix/bug-69767
Fix bug #69767
2024-08-20 05:39:52 -07:00
f245985bbd fix bug #69774 2024-08-20 11:29:57 +03:00
68171df991 Merge branch 'release/v8.2.0' of https://github.com/ONLYOFFICE/core into release/v8.2.0 2024-08-20 11:27:58 +03:00
bbf4003ec7 Refactoring 2024-08-20 11:00:12 +03:00
75cc7d8457 Fix bug #69767 2024-08-20 10:59:32 +03:00
7018402a58 Merge pull request #1619 from ONLYOFFICE/fix/pdf-bugs
Fix pdf bugs
2024-08-20 00:04:03 -07:00
6ce30ccaad Fix test 2024-08-20 09:23:10 +03:00
670677c23b Fix pdf clip 2024-08-20 09:22:39 +03:00
208f6efcc5 fix bug #69781 2024-08-20 08:39:42 +03:00
685165d270 fix bug #69780 2024-08-20 08:39:02 +03:00
b18bdcc0a0 Fix bug #56747 2024-08-20 04:29:45 +05:00
f18eb2ef5b Developing 2024-08-20 00:23:59 +03:00
facdff46fe Refactoring 2024-08-19 18:24:06 +03:00
feb3f4cdf0 Fix bug #66675 2024-08-19 19:35:23 +06:00
8843c3dd36 Merge pull request #1617 from ONLYOFFICE/feature/docbuilder-java
Add JAVA_HOME environment variable support when compiling docbuilder Java-wrapper
2024-08-19 04:50:27 -07:00
2708479152 Add class for embed pdf object 2024-08-19 13:57:26 +03:00
f3facfa8e8 Fix for some JDK versions 2024-08-19 14:13:19 +04:00
1e26e1723a For buf 59297 2024-08-19 12:57:30 +03:00
6d9242e1dd Add building support for JDK > 8 2024-08-19 13:49:43 +04:00
e8de8dc03b fix bug #60796 2024-08-16 17:39:11 +03:00
57447f757f Merge pull request #1618 from ONLYOFFICE/fix/pdf-time
Fix pdf clip
2024-08-16 04:24:27 -07:00
46d6eaa793 Fix test Save/Restore graphics 2024-08-16 13:35:03 +03:00
837ad1d8f7 Merge remote-tracking branch 'origin/release/v8.2.0' into develop 2024-08-16 09:33:59 +03:00
def502c7eb Refactoring drawingfile (native realization support) 2024-08-15 22:00:37 +03:00
1e5e43cbe5 Fix clip 2024-08-15 16:59:00 +03:00
60a888fc19 Fix PdfFile test 2024-08-15 16:58:39 +03:00
01ca25d798 Fix test 2024-08-15 16:58:20 +03:00
6812ebaa42 fix bug #68293 2024-08-15 10:46:06 +03:00
aacb2842f7 Fix typo 2024-08-14 16:39:41 +04:00
27a2a47cbe Fixes 2024-08-14 16:35:22 +04:00
02f8178c01 Merge pull request #1616 from ONLYOFFICE/fix/bug65304
Fix bug 65304
2024-08-14 01:55:26 -07:00
7dda21d1e1 Merge remote-tracking branch 'origin/release/v8.2.0' into develop 2024-08-14 11:28:37 +03:00
a0e2384409 fix bug #69490 2024-08-13 21:33:51 +03:00
56088e9eff Add support for JAVA_HOME environment variable 2024-08-13 20:44:46 +04:00
1d6b895496 Refactoring 2024-08-13 16:32:41 +03:00
fa4b8c8d76 Fix build 2024-08-13 11:40:51 +03:00
2db2b98c8f Fix bug 65304 2024-08-13 10:54:23 +03:00
f45fb3c6be for bug #69599 2024-08-13 09:40:06 +03:00
6f60d75863 Fix build 2024-08-13 00:24:51 +03:00
d1acdf35d8 Refactoring 2024-08-13 00:16:51 +03:00
a1bf6a76ed fix bug #69658 2024-08-12 19:25:27 +03:00
3634d59ece Merge branch 'release/v8.2.0' of https://github.com/ONLYOFFICE/core into release/v8.2.0 2024-08-12 19:07:54 +03:00
1b21e8f136 fix bug #69647 2024-08-12 19:07:07 +03:00
554ca5ec7c Merge pull request #1615 from ONLYOFFICE/fix/docbuilder-script-cache
Fix script caching on Windows
2024-08-12 08:15:16 -07:00
dc2e0edf80 fix bug #25787 2024-08-12 18:13:52 +03:00
e38fa336d2 Fix script caching with v8_89 2024-08-12 17:32:14 +04:00
357450f242 Merge pull request #1614 from ONLYOFFICE/fix/html
Fix html to ooxml conversion
2024-08-12 03:20:37 -07:00
4ed9925aff Merge pull request #1610 from ONLYOFFICE/feature/MetafileSize
The size setting of metafiles has been changed
2024-08-12 03:20:17 -07:00
796537565b Fixed unnecessary use of standard styles in html to ooxml conversion 2024-08-09 15:43:55 +03:00
fcf8e28ae8 Added tabs to the text in html to ooxml conversion 2024-08-09 15:27:29 +03:00
de949afbb6 fix bug #69618 2024-08-09 12:33:40 +03:00
fb7bb041c1 Merge pull request #1613 from ONLYOFFICE/fix/pdf-leaks
Fix pdf leaks, clip and read jpeg
2024-08-09 02:03:52 -07:00
8d6e15627b Refactoring RenderOutputDev and test diff 2024-08-08 18:42:43 +03:00
0583cbb5cc Merge branch 'release/v8.2.0' of https://github.com/ONLYOFFICE/core into release/v8.2.0 2024-08-08 17:31:35 +03:00
a68bec86df Improved html to ooxml conversion 2024-08-08 16:05:19 +03:00
6554185ec7 Refacroting DrawImage 2024-08-07 18:07:12 +03:00
22bbde155d fix bug #44738 2024-08-07 12:03:23 +03:00
4a123d33ea fix bug #69552 2024-08-07 08:18:32 +03:00
c7d0f27f6b Fix ReadImage 2024-08-06 18:59:28 +03:00
f1ddd51164 Add support /* comments in script files 2024-08-06 18:08:47 +03:00
1d636b717f [x2t] Fix bug 69574 2024-08-06 15:53:40 +03:00
c026f33aa7 Improved html to ooxml conversion 2024-08-06 15:47:58 +03:00
29e5769d6d fix bug #30042 2024-08-06 10:54:09 +03:00
6ba96b0ae8 Merge remote-tracking branch 'origin/release/v8.2.0' into develop 2024-08-06 09:38:42 +03:00
9d750ad3d4 . 2024-08-06 08:53:05 +03:00
5b156d72c0 Fix bug #44363 2024-08-06 01:19:19 +03:00
85a7c82aa7 . 2024-08-05 22:48:25 +03:00
6586fc39ee Merge pull request #1612 from ONLYOFFICE/feature/gradients
Feature/gradients
2024-08-05 11:50:27 -07:00
8a4b1672c9 . 2024-08-05 20:31:01 +03:00
0d71f1c158 . 2024-08-05 19:15:36 +03:00
394582df7a fix build 2024-08-05 18:50:23 +03:00
e8c7a4f670 Fix ReadDCT 2024-08-05 18:14:56 +03:00
ead6b305b2 Create ReadDCT for jpeg image in pdf 2024-08-05 16:36:50 +03:00
2de6a6d199 Merge pull request #1611 from ONLYOFFICE/feature/docbuilder-java
Feature/docbuilder java
2024-08-05 05:38:52 -07:00
c6ca99994b Fix build into JAR on mac and linux 2024-08-02 19:35:13 +04:00
b707510c88 Remove explicit workDirectory setting 2024-08-02 18:38:40 +04:00
7171dcb9f0 Set library path at runtime
Now there is no need to pass `-D...` parameter to run java program
2024-08-02 18:26:15 +04:00
49dedc7a6d fix bug #69392 2024-08-02 16:43:20 +03:00
431fa060c4 fix bug #69488 2024-08-02 16:10:50 +03:00
0fc5133d98 Fix for building test example 2024-08-02 16:05:08 +04:00
8d5fc7d6ca Fix build for JDK 8 and force build into JAR 2024-08-02 15:58:13 +04:00
3221d20d81 Remove docbuilder_jni_utils helper library 2024-08-02 12:36:17 +04:00
9fdb81554a fix bug #69518 2024-08-02 10:58:01 +03:00
95a1983e75 Refactoring RendererOutputDev 2024-08-01 18:59:19 +03:00
bef68d03c9 Merge pull request #1609 from ONLYOFFICE/feature/add-future-functions-conversion
Feature/add future functions conversion
2024-08-01 17:05:53 +03:00
a1100f0091 Fix copiright dates 2024-08-01 17:04:10 +06:00
15b18adf90 Fix copyright dates 2024-08-01 17:01:45 +06:00
c27aa4d807 Improved html to ooxml conversion 2024-08-01 13:54:07 +03:00
c4f8c524b5 Merge remote-tracking branch 'origin/release/v8.2.0' into fix/pdf-leaks 2024-08-01 12:32:12 +03:00
1a0a63c8dd Merge branch 'develop' into feature/add-future-functions-conversion 2024-08-01 15:23:44 +06:00
9010dcc220 Add initialization checks and default values in xslx 2 xlsb conversion 2024-08-01 15:22:57 +06:00
f7d55c08d8 fix bug #69474 2024-07-31 21:56:23 +03:00
4cfb8cc97a fix bug #69104 2024-07-31 21:51:15 +03:00
a41ecb0715 for bug #69405 2024-07-31 21:32:50 +03:00
faa9e5e640 Merge pull request #1608 from ONLYOFFICE/fix/bug-65822
For bug 65822
2024-07-31 05:40:58 -07:00
ac2ee1b56d Save line AP 2024-07-31 14:01:34 +03:00
b722238d21 Draw AP for markup annots 2024-07-31 14:00:24 +03:00
dca5f4f7c5 Add prefix check for future functions names 2024-07-31 16:55:05 +06:00
9875aed0a0 Add default values to style conversion 2024-07-31 15:17:47 +06:00
83e20057f4 Merge pull request #1607 from ONLYOFFICE/feature/docx-renderer
Feature/docx renderer
2024-07-30 10:34:35 -07:00
373786fca6 Update Clip 2024-07-30 18:35:57 +03:00
0fa1b4feec Add return 0/1 for builder external scripts 2024-07-30 11:47:13 +03:00
6a6204ae33 Fix add to conts & highlights 2024-07-30 11:35:39 +03:00
f02147b97c Fix jar build 2024-07-30 12:25:54 +04:00
88b1660735 Add another way to load native libraries 2024-07-30 11:36:47 +04:00
f5f7cb1aec . 2024-07-29 22:13:28 +03:00
af01306997 . 2024-07-29 21:58:34 +03:00
ef30a30e00 Fix first word width in splitted lines 2024-07-29 20:33:20 +03:00
16ae48ef4e Fix memory leaks 2024-07-29 17:56:48 +03:00
ab4fa069d1 Add xlsb buffer size reset after writing file 2024-07-29 20:41:52 +06:00
d00919e139 Fix fonts bls 2024-07-29 20:38:48 +06:00
0eb8c93cf9 Merge pull request #1606 from ONLYOFFICE/fix/bug66692
Fix bug #66692
2024-07-29 14:50:16 +03:00
c98285ffef Merge pull request #1605 from ONLYOFFICE/fix/bug66675
Fix bug #66675
2024-07-29 14:50:03 +03:00
4b99c4179b Fixed inaccuracies when converting html to ooxml elements big and small 2024-07-29 12:39:51 +03:00
e98dec952f Fix build 2024-07-26 21:43:43 +03:00
8b2d7035c1 Add build to JAR 2024-07-26 19:42:37 +04:00
234def9cd7 Autowrap function arguments
+ Add constructor from Java arrays
2024-07-26 19:10:32 +04:00
ce92766ef6 Fix paths 2024-07-26 17:16:06 +03:00
59c95c5039 Merge pull request #1597 from ONLYOFFICE/feature/pdf-layer
Feature pdf layer
2024-07-26 07:05:38 -07:00
a23002225a Merge pull request #1598 from ONLYOFFICE/fix/bug-59297
Feature pdf headings
2024-07-26 07:03:52 -07:00
cb64a5a266 Fix bug #66675 2024-07-26 16:51:24 +06:00
65483d0460 fix bug #69395 2024-07-26 13:31:16 +03:00
41758f0552 Merge pull request #1604 from ONLYOFFICE/feature/docx-renderer
Fix bug with spacing
2024-07-26 02:30:17 -07:00
bfd790ba11 Fix bug with spacing 2024-07-26 12:26:59 +03:00
81d9e3cfd7 Merge pull request #1603 from ONLYOFFICE/feature/docx_renderer
Feature/docx renderer
2024-07-26 01:42:31 -07:00
2920527898 Reformat code 2024-07-26 11:40:01 +03:00
7013fdcb8d Merge branch hotfix/v8.1.1 into release/v8.2.0 2024-07-26 08:05:06 +00:00
feda29eb77 Merge branch hotfix/v8.1.1 into develop 2024-07-26 08:05:02 +00:00
caf90eb3a3 Merge branch hotfix/v8.1.1 into master 2024-07-26 08:04:53 +00:00
0d84e22e79 Fix spaces more 2024-07-25 19:13:29 +03:00
f2acef6bb2 Add docbuilder.utils.Utils class to edit PATH on Windows 2024-07-25 20:06:11 +04:00
84b8850a52 Fix bug with spaces 2024-07-25 16:12:40 +03:00
b2a3de852a Fix bug #66692 2024-07-25 17:51:20 +06:00
a8fa59d64d Added ruby support and bug fixes 2024-07-25 14:44:20 +03:00
59b84f26ee Merge remote-tracking branch 'origin/fix/bug68344' into release/v8.2.0 2024-07-25 10:44:47 +03:00
5b17009fb9 Merge remote-tracking branch 'origin/fix/bug68540' into release/v8.2.0 2024-07-25 10:41:50 +03:00
a5827f187c Merge remote-tracking branch 'origin/fix/bug68585' into release/v8.2.0 2024-07-25 10:41:09 +03:00
6ae25ca4c4 Merge remote-tracking branch 'origin/fix/bug69238' into release/v8.2.0 2024-07-25 10:39:58 +03:00
ff4425e977 fix grad 2024-07-24 18:36:10 +03:00
06edc93c7b Fix bug #69238 2024-07-24 18:16:50 +03:00
8f9b35d94a Fix inline destination 2024-07-24 16:35:14 +03:00
14c06e4e7b Fix x coord Outlines 2024-07-24 15:16:21 +03:00
abaaa54bc2 Fix SetByIndex and test example
(now it does work)
2024-07-24 14:05:29 +04:00
7d0683e338 Update test example
(it doesn't work yet)
2024-07-23 20:32:44 +04:00
f9d6b49a05 Rename Call() to call() 2024-07-23 20:31:43 +04:00
01916b7de6 Add file type constants 2024-07-23 19:49:14 +04:00
666d62239e Add class CDocBuilderContext to Java and JNI 2024-07-23 19:36:49 +04:00
2e25f5dc64 Get previous array on return 2024-07-23 18:36:27 +03:00
cc61536a90 Fix function naming for CDocBuilderContextScope 2024-07-23 19:36:01 +04:00
58b5417ab4 Add class CDocBuilderContextScope to Java and JNI 2024-07-23 19:10:08 +04:00
c056c14303 Add hint how to run compiled Java example 2024-07-23 18:15:39 +04:00
1b975c7048 Get headings as an array
Get headings as an array with levels and convert to tree
2024-07-23 17:07:04 +03:00
3fd5b5612b Add test Java example 2024-07-23 17:32:51 +04:00
b8a8d36b8b Improved html to ooxml conversion 2024-07-23 14:55:38 +03:00
ccbeb28f8a fix bug #69325 2024-07-23 14:23:35 +03:00
6ab0d9d106 Fixes in Java code 2024-07-22 21:31:27 +04:00
79309d3f02 Add Java code for CDocBuilder
+ Change private members to package-private
2024-07-22 17:09:48 +04:00
c8c4edf592 Add JNI code for CDocBuilder 2024-07-22 16:37:17 +04:00
eac73b31b3 Add cell metadata conversion 2024-07-22 18:17:49 +06:00
64afe55078 Add Java code for CDocBuilderValue
+ Changed all JNI functions to static
2024-07-22 15:28:15 +04:00
383375ade2 Add metadata mdx binary reading 2024-07-22 15:54:10 +06:00
967a5728c7 fix build 2024-07-22 11:46:35 +03:00
16324b7bf1 Add future metadata bynary reading 2024-07-22 14:16:52 +06:00
62b96623a0 Add missed files 2024-07-22 11:04:18 +03:00
8a105d35d5 Merge pull request #1596 from ONLYOFFICE/fix/bug-69284
Fix bug 69284
2024-07-22 00:56:50 -07:00
d48e3ab6e0 Merge branch 'develop' into feature/add-future-functions-conversion 2024-07-22 13:12:00 +06:00
eaf2c02b86 Fix bug 69284 2024-07-20 13:37:23 +03:00
46f30b980f Add JNI code for CDocBuilderValue 2024-07-19 20:35:42 +04:00
ac4f15b999 Improved html to ooxml conversion 2024-07-19 16:59:58 +03:00
918a940e05 . 2024-07-19 15:18:58 +03:00
a28f12e170 Add metadata blocks conversion from bin 2024-07-19 17:09:59 +06:00
43e506cff1 Add metadata types conversion from bin 2024-07-19 16:17:45 +06:00
21cf3df902 Add esstr conversion from bin 2024-07-19 15:39:55 +06:00
47961709ad Fix docbuilder.c ToString function 2024-07-19 13:13:34 +04:00
a47e72cf2f fix bug #69311 2024-07-19 11:07:47 +03:00
91d63bc49f Merge branch 'develop' into feature/add-future-functions-conversion 2024-07-19 13:38:57 +06:00
bc65bf962e Fix metadata conversion to xlsb 2024-07-18 16:00:51 +06:00
4abc5b6bcc Add mdx metadata conversion 2024-07-18 14:38:16 +06:00
472c9ecd0d for bug #61035 2024-07-17 18:21:03 +03:00
7b8aa38c37 Fix bug 45813 2024-07-17 17:40:11 +03:00
5c87955ae2 Fix bug 56118 2024-07-17 16:12:53 +03:00
c37aa9d9dc Fix bug 55429 2024-07-17 16:11:02 +03:00
d699c30bda Fix bug 48721 2024-07-17 16:09:42 +03:00
4af9055ade Add future metadata conversion 2024-07-17 15:19:43 +06:00
9db017b9f4 Fix bug 69136 2024-07-17 12:16:44 +03:00
70fe676300 Improved colgroup support in html to ooxml conversion 2024-07-16 18:36:09 +03:00
e73d4455c2 Fix bug 55995
Support pTransferFunc for setSoftMask
2024-07-16 17:57:52 +03:00
96d994dc65 Add metadata blocks conversion to bin 2024-07-16 20:51:47 +06:00
87f7be4bc6 Add binary writing ESSTR and ESMDT 2024-07-16 19:40:20 +06:00
3158e830ff Indetns fix 2024-07-16 13:56:17 +03:00
33daee696c Delete unused 2024-07-16 13:13:28 +03:00
305492ec7b Fix flip SoftMask 2024-07-15 18:22:06 +03:00
e9f8045568 Add metadata records reading 2024-07-15 18:00:30 +06:00
90d46b55d8 Merge branch hotfix/v8.1.1 into master 2024-07-15 11:40:21 +00:00
2d213df8af Create CSoftMask 2024-07-12 18:25:11 +03:00
4bb3953171 Added colgroup implementation for tables in html to ooxml conversion 2024-07-12 18:03:18 +03:00
02c54d90c6 Add binary record reading 2024-07-12 20:45:53 +06:00
ce69cf40d2 Add mdxSet bin records 2024-07-12 19:39:03 +06:00
013ab00f06 Add Mdx Tuple binary records 2024-07-12 18:31:23 +06:00
2ef1e8f820 Add bmrIstr binary record 2024-07-12 16:47:16 +06:00
db980db306 Add mdxKpi binary struct 2024-07-12 16:24:55 +06:00
45a7827b1b Merge branch 'develop' into feature/add-future-functions-conversion 2024-07-12 13:49:11 +06:00
f8e894af67 Testing agg::scanline_u8_am 2024-07-11 18:27:49 +03:00
f1d932c084 Add Mdxmbrprop bin structs 2024-07-11 19:22:48 +06:00
a452a20049 Add Mdx bin structures 2024-07-11 18:53:39 +06:00
d69b861ff7 Merge branch 'develop' into feature/add-future-functions-conversion 2024-07-11 18:20:28 +06:00
4305ececd3 Add Esmdx bin structs 2024-07-11 18:20:18 +06:00
777be23513 [android] Replace dependencies 2024-07-11 14:59:43 +03:00
12adcfc8f1 Add ESMBD bin structures 2024-07-11 16:43:49 +06:00
b8af955fcd fix bug #69104 2024-07-11 10:52:47 +03:00
176290adaf Fix bug + refactoring 2024-07-10 19:34:01 +03:00
32a46c6859 Merge branch 'develop' into feature/add-future-functions-conversion 2024-07-10 20:06:27 +06:00
c89de96a1b Add Esstr bin records 2024-07-10 20:04:45 +06:00
b3868ff146 fix bug #54575 2024-07-10 16:49:08 +03:00
f30aba8bf1 Added support for the rules attribute for tables in html to ooxml conversion 2024-07-10 15:23:05 +03:00
b039eeca38 fix bug #69097 2024-07-10 13:00:33 +03:00
450cbf0ab1 fix bug #69096 2024-07-10 12:10:14 +03:00
2e33e7d097 fix bug #69095 2024-07-10 12:00:34 +03:00
e9af537e63 Merge remote-tracking branch 'origin/hotfix/v8.1.1' into develop 2024-07-10 11:27:41 +03:00
849d3fb09a Merge pull request #1592 from ONLYOFFICE/fix/pdf-layer 2024-07-09 20:24:32 -07:00
ea76a114f3 Fix Alpha type SoftMask and nesting of layers 2024-07-09 23:15:22 +03:00
fb209c6c8a Fix bugs 2024-07-09 19:49:21 +03:00
d4af1308c0 Merge pull request #1591 from ONLYOFFICE/feature/svg-font
Added custom SVG font
2024-07-09 18:48:00 +03:00
824d9c59cf Fix shapes merging 2024-07-09 16:56:43 +03:00
d4f3cd3801 Fix bugs in html to ooxml conversion 2024-07-09 16:44:50 +03:00
c7fc2bc3a7 The blockquote tag implementation has been added to the html to ooxml conversion 2024-07-09 16:44:32 +03:00
f9ecfee609 Merge pull request #1590 from ONLYOFFICE/pdf/fix-rotate-layer
Fix rotate layer
2024-07-09 06:37:59 -07:00
a8c815d7bd Fix bugs
Fix paragpraph bug
Fix bug with lines in tables
2024-07-09 16:25:32 +03:00
64234659aa Merge pull request #1589 from ONLYOFFICE/fix/bug69073
Fix bug #69073
2024-07-09 06:16:59 -07:00
09c066def3 Change whitespaces on tabs 2024-07-09 19:15:12 +06:00
685434b2ab Merge remote-tracking branch 'origin/hotfix/v8.1.1' into develop 2024-07-09 16:04:22 +03:00
bcfb9b3630 Fix rotate layer 2024-07-09 16:02:57 +03:00
17e6ebeb31 Merge pull request #1584 from ONLYOFFICE/fix/bug68998
Fix bug #68998
2024-07-09 05:28:27 -07:00
ae0e888186 Merge pull request #1588 from ONLYOFFICE/fix/bug-69049
Fix bug 69049
2024-07-09 05:15:46 -07:00
4559d53a97 Change CContText logic 2024-07-09 15:01:34 +03:00
dac41ff6f7 Fix bug #69073 2024-07-09 17:12:21 +06:00
8cecbf1fb1 Merge branch 'develop' into feature/add-future-functions-conversion 2024-07-09 16:27:37 +06:00
5e5fec1666 add bg 2024-07-09 11:37:35 +03:00
a2d32b59a1 Fix bug 69049 2024-07-09 10:33:56 +03:00
0889f82c76 Merge pull request #1587 from ONLYOFFICE/feature/x2ttester
Fix bug 69056
2024-07-08 11:22:05 -07:00
56f2b18184 Add metadata info and future metadata bin structures 2024-07-08 21:31:44 +06:00
ee6ea32ad1 Fix bug 69056 2024-07-08 17:30:49 +03:00
69e6ff99f6 Merge pull request #1586 from ONLYOFFICE/fix/EmfPlus
Fix EmfPlus
2024-07-08 04:04:26 -07:00
b763041695 Fixed working with the embedded EmfPlusOnly metafile 2024-07-08 13:58:23 +03:00
712d603ff2 Add metadata conversion structures 2024-07-08 01:24:16 +06:00
adfc64f01e fix bug #69031 2024-07-06 14:00:09 +03:00
f465f17b93 Merge pull request #1585 from ONLYOFFICE/fix/pdf-layer
Fix bugs #69016, #56088, #69019
2024-07-05 09:09:27 -07:00
efd7b5ac9a fix bug #69023 2024-07-05 17:24:33 +03:00
2375b476d0 Fix drawMaskedImage 2024-07-05 17:05:48 +03:00
f97bb4e688 Fix actual fonts 2024-07-05 17:04:56 +03:00
aff7b42f71 Add Isolated for AlphaMask and TransparencyGroup 2024-07-05 15:46:57 +03:00
0675b8c5b5 Fix bug 69019 2024-07-05 15:28:30 +03:00
a27c26dbe3 Fix bug #68998 2024-07-05 18:09:07 +06:00
74d7bbca7c Improvement in html to xml conversion of image size calculation 2024-07-04 18:00:32 +03:00
6eba82f433 Improvement in html to ooxml conversion of multi-level lists 2024-07-04 18:00:06 +03:00
d1460a057e Merge remote-tracking branch 'origin/fix/bug68957' into develop 2024-07-04 15:36:26 +03:00
21ba3ac0c9 fix bug #68957 2024-07-04 15:35:36 +03:00
1e2535f6e1 Remove metadata xlsb conversion 2024-07-04 16:52:19 +06:00
14196ddc9f Add Mask and Layer for pdf 2024-07-03 17:34:25 +03:00
18db2f8614 Merge pull request #1574 from ONLYOFFICE/fix/bug-68843
Fix bug #68843
2024-07-03 06:58:26 -07:00
81f01f49ed Merge pull request #1583 from ONLYOFFICE/fix/bug-68928
Fix bug 68928
2024-07-03 06:58:08 -07:00
4cb159a794 Fix bug #68928 2024-07-03 16:53:50 +03:00
ce6f6ea256 Add custom functions conversion 2024-07-03 19:05:39 +06:00
e164168418 fix bug #68971 2024-07-03 15:07:35 +03:00
fd60059dd6 fix bug #68974 2024-07-03 15:03:03 +03:00
e40be65c55 Merge pull request #1582 from ONLYOFFICE/fix/bug-68951
Fix bug 68951
2024-07-02 09:19:54 -07:00
0bf9663169 Fix bug 68951 2024-07-02 18:51:25 +03:00
a391316529 Merge branch 'develop' into feature/add-future-functions-conversion 2024-07-02 16:41:30 +06:00
b1ff8b79d3 Merge remote-tracking branch 'origin/hotfix/v8.1.1' into develop 2024-07-02 09:52:52 +03:00
efb9095dc5 fix bug #55042 2024-07-02 09:43:40 +03:00
06a60b2846 Add other future function names 2024-07-01 21:18:40 +06:00
3aab7fd183 fix bug #45681 2024-07-01 17:33:14 +03:00
0c0cd575ad Merge pull request #1579 from ONLYOFFICE/fix/pdf-bugs
Fix bug 60317
2024-07-01 03:17:14 -07:00
75b22f6e19 Merge branch 'develop' into feature/add-future-functions-conversion 2024-07-01 13:13:33 +06:00
82c06b5aaa Merge pull request #1581 from ONLYOFFICE/feature/libvlc-linux
Update libvlc build with changed RPATHs
2024-06-29 11:32:24 -07:00
efa4433195 Added rendering of custom fonts in svg 2024-06-28 21:18:00 +03:00
e9c9530d66 Update build with changed rpaths 2024-06-28 20:27:57 +04:00
6c36fc7146 Add script to change rpaths in libvlc build 2024-06-28 20:27:36 +04:00
d2724ac712 Add static constructor 2024-06-28 20:51:59 +06:00
34db65ff5e fix bug #68916 2024-06-28 14:36:40 +03:00
e4e35ab579 Add future function parser 2024-06-28 15:01:57 +06:00
5770551ed4 Merge remote-tracking branch 'origin/hotfix/v8.1.1' into develop 2024-06-28 11:28:45 +03:00
75c56c13fc fix bug #68864 2024-06-28 11:10:48 +03:00
e5b0c0f1f9 fix bug #68873 2024-06-28 10:46:51 +03:00
723dcef8aa fix bug #68895 2024-06-28 10:34:42 +03:00
bc56b97ce0 Merge branch release/v8.1.0 into master 2024-06-26 10:42:10 +00:00
880b96acfc Fix build 2024-06-26 12:30:03 +03:00
81806d96d0 Fix bug 60317 2024-06-26 12:29:51 +03:00
78c47b2007 Merge branch 'develop' into feature/add-future-functions-conversion 2024-06-26 14:58:21 +06:00
49a9205aad Merge pull request #1576 from ONLYOFFICE/fix/bug68834
Fix bug #68834
2024-06-26 11:58:10 +03:00
971205b325 For bug 59297 2024-06-26 11:02:05 +03:00
73fc80aa7d Merge remote-tracking branch 'origin/fix/bug23800' into develop 2024-06-26 10:03:49 +03:00
84836a3e8b Merge remote-tracking branch 'origin/fix/bug53148' into develop 2024-06-26 10:03:27 +03:00
6dc7ff0874 fix bug #49062 2024-06-26 09:51:20 +03:00
eec0fa47ce Merge remote-tracking branch 'origin/hotfix/v8.1.1' into develop 2024-06-26 09:14:19 +03:00
ebadb754c5 fix bug #68471 2024-06-26 08:59:12 +03:00
7d3bf0c328 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2024-06-26 08:41:11 +03:00
7e7ed8d746 Merge pull request #1577 from ONLYOFFICE/feature/libvlc-linux
Add new libva libraries to linux libVLC build
2024-06-25 11:30:59 -07:00
cd7b39acf2 fix bug #68852 2024-06-25 18:47:51 +03:00
92a3c6cfce Fix Dockerfile 2024-06-25 19:14:16 +04:00
f3e6b5bc21 Add libva libraries to build 2024-06-25 18:42:16 +04:00
95d2939a73 Fix bug 61747 2024-06-25 17:39:06 +03:00
da06f82447 [x2t] Fix bug 68805 2024-06-25 17:17:03 +03:00
5ad4cca9f4 Fix bug #68834 2024-06-25 20:15:58 +06:00
3d528bf8b5 Fix bug #68843
Added switch implementation in svg
2024-06-25 16:39:42 +03:00
fe489b9da0 Rebuild libvlc with libva2 2024-06-25 17:38:25 +04:00
6d9bccee65 fix bug #68601 2024-06-25 16:22:35 +03:00
6ae6c37ef1 Added reading of custom fonts in svg 2024-06-25 15:51:04 +03:00
cc3528c226 Merge pull request #1573 from ONLYOFFICE/fix/bug-68549
Fix bug 68549
2024-06-25 03:36:54 -07:00
db4ae797a1 Fix bug 68549 2024-06-25 13:25:47 +03:00
b1810af6f0 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2024-06-25 10:59:46 +03:00
54468d21d5 Merge branch 'develop' into feature/add-future-functions-conversion 2024-06-25 13:32:05 +06:00
263b48dea0 Fix bug #53148 2024-06-24 23:04:22 +05:00
128e09f839 Merge pull request #1571 from ONLYOFFICE/fix/bug68007
Fix bug #68007
2024-06-24 17:36:58 +03:00
5b16ea0693 Merge pull request #1570 from ONLYOFFICE/fix/bug58826
Fix bug #58826
2024-06-24 17:36:42 +03:00
be821d6b45 Fix bug #23800 2024-06-24 19:29:28 +05:00
4c08e60ecc Merge pull request #1572 from ONLYOFFICE/fix/bug-68712
Fix bugs 68712, 68751
2024-06-24 07:27:18 -07:00
e55101141c [x2t] Save changes.zip in applyChangesPdf; Fix bug 67341 2024-06-24 16:03:28 +03:00
ce9268f166 Fix for PdfWriter 2024-06-24 15:46:28 +03:00
e7751e891a Fix bug #58826 2024-06-24 17:47:13 +06:00
a3a734a558 fix bug #68769 2024-06-23 10:43:21 +03:00
7326f88aa0 Create CAnnotFonts 2024-06-21 17:23:00 +03:00
83f98f3186 Merge branch 'fix/pre-hotfix' into hotfix/v8.1.1 2024-06-21 17:19:38 +03:00
b60a956b84 Add future function conversion 2024-06-21 20:17:39 +06:00
2d6ef9a38b fix bug #68767 2024-06-21 16:02:21 +03:00
baae7b0a15 Fix bug 68754 2024-06-21 12:17:51 +03:00
5e7caad32a fix bug#68764 2024-06-20 16:16:28 +03:00
a517809a5d fix bug #68766 2024-06-20 16:11:44 +03:00
255fa70292 Fix bug 68751 2024-06-20 12:44:32 +03:00
71ecf1a1e0 Fix bug 68712 2024-06-19 18:29:03 +03:00
8d092ad6e4 Fix bug #68711 2024-06-19 17:55:43 +06:00
d9269bcd33 fix bug #68406 2024-06-19 13:23:11 +03:00
2f45e0952e Fix bug with cloud images 2024-06-19 11:28:22 +03:00
05293f43ce Merge branch release/v8.1.0 into master 2024-06-19 08:22:01 +00:00
df6c20b57d Fix bug #68007 2024-06-18 19:36:37 +06:00
59b3862d89 Fix bug #68585 2024-06-18 17:18:41 +05:00
e80e545024 Merge pull request #1566 from ONLYOFFICE/fix/bug-68688 2024-06-17 07:56:13 -07:00
2245952739 Merge pull request #1567 from ONLYOFFICE/fix/bug-68252 2024-06-17 07:55:25 -07:00
ff52afecc9 Fix bug #68252 2024-06-17 17:50:50 +03:00
5503208e95 Fix bug 68237 2024-06-17 17:29:04 +03:00
90c1ffe7de Fix bugs 68688, 68689
Related bugs 46629, 61014, 68479, 68545
2024-06-17 17:08:18 +03:00
23ef8fd8af Merge pull request #1565 from ONLYOFFICE/fix/bug-68638
Fix bug #68638
2024-06-17 05:01:09 -07:00
e5559e4cf8 Fix bug #68638 2024-06-17 14:22:19 +03:00
91b82d9dcb Merge remote-tracking branch 'origin/release/v8.1.0' into develop 2024-06-14 16:03:23 +03:00
142ed45a1b . 2024-06-14 16:02:49 +03:00
76623ec66d [pdf=>image] Support orientation 2024-06-14 15:51:28 +03:00
d5a4cf73ec Merge pull request #1564 from ONLYOFFICE/feature/StarMath
Fix StarMath
2024-06-14 05:36:03 -07:00
ef530fea0b fix bug 68587 2024-06-14 14:10:51 +03:00
a72b42bd6d Fix placeholder index attribute 2024-06-14 15:58:56 +05:00
e20f98aa4a Merge pull request #1563 from ONLYOFFICE/fix/bug-68629
Fix bug 68629
2024-06-14 02:48:42 -07:00
cc27db504f Fix embedded fonts 2024-06-14 12:34:34 +03:00
1da9dc12b5 Merge pull request #1562 from ONLYOFFICE/fix/svg
Fix svg
2024-06-14 02:11:45 -07:00
6cf95e6151 Fix bug #68638 2024-06-14 12:06:45 +03:00
ad4ba02895 For bug 65310 2024-06-14 11:16:08 +03:00
79c7fced0a For bug 68629 2024-06-14 11:15:33 +03:00
b63ff91ce4 Merge pull request #1561 from ONLYOFFICE/fix/bug-68629
For bug 68237
2024-06-13 23:34:45 -07:00
d0b6c55347 For bug 68237 2024-06-14 09:16:09 +03:00
53f9629194 Merge pull request #1560 from ONLYOFFICE/fix/bug-68609
Fix bug #68609
2024-06-13 09:56:58 -07:00
272b69ae70 Fix bug #68609 2024-06-13 19:43:25 +03:00
8c081c83c9 fix bug 68586 2024-06-13 19:31:38 +03:00
37bef7c398 Merge pull request #1559 from ONLYOFFICE/fix/bug-68546
Fix bug 68546
2024-06-13 08:26:39 -07:00
aae80a161c Clear 2024-06-13 18:04:39 +03:00
a498117748 Fix bug 68546 2024-06-13 17:54:14 +03:00
7a4cebb89c fix bug #68569 2024-06-13 17:46:06 +03:00
3a8c941649 Merge remote-tracking branch 'origin/release/v8.1.0' into develop 2024-06-13 17:22:43 +03:00
32464cb685 The size setting of metafiles has been changed 2024-06-13 17:22:09 +03:00
a8787e9220 Merge pull request #1558 from ONLYOFFICE/fix/bug68545
Fix bug 68545
2024-06-13 07:01:20 -07:00
17bc68d102 Fix bug 68545 2024-06-13 16:49:13 +03:00
ca17a96d32 Fix null 2024-06-13 13:08:21 +03:00
04419326f4 Fix bug 68545 2024-06-13 13:00:13 +03:00
adfbf6ea3f Merge pull request #1549 from ONLYOFFICE/fix/bug-68532
Fix bug 68532
2024-06-13 02:15:00 -07:00
61397b67c1 Merge pull request #1557 from ONLYOFFICE/fix/propsbinary 2024-06-13 02:06:29 -07:00
a6e87b589c add props to binary 2024-06-13 11:56:10 +03:00
5927b0113f Merge pull request #1556 from ONLYOFFICE/fix/bug68540
fix bug #68540
2024-06-11 22:01:39 +03:00
e03b3e9f1b fix bug #68540 2024-06-11 22:01:06 +03:00
ecef6154ff Merge pull request #1555 from ONLYOFFICE/fix/bug65788
fix bug #65788
2024-06-11 21:38:19 +03:00
e16578c3a1 fix bug #65788 2024-06-11 21:36:15 +03:00
3e709a99ed Merge pull request #1548 from ONLYOFFICE/fix/bug68485
Fix bug #68485
2024-06-11 19:56:16 +03:00
c2f0390b6a Merge pull request #1550 from ONLYOFFICE/fix/bug68503
Fix bug #68503
2024-06-11 19:56:04 +03:00
27619798b9 Merge pull request #1551 from ONLYOFFICE/fix/bug68510
Fix bug #68510
2024-06-11 19:55:50 +03:00
e62585a7fc Merge pull request #1553 from ONLYOFFICE/fix/bug68404
Fix bug #68404
2024-06-11 19:45:19 +03:00
19c4a674f6 Merge pull request #1554 from ONLYOFFICE/fix/bug68238
fix bug #68238
2024-06-11 19:45:06 +03:00
505d8093ef fix bug #68238 2024-06-11 19:42:41 +03:00
3316216f8e Fix bug #68404 2024-06-11 19:35:41 +06:00
7131129ba0 Merge pull request #1552 from ONLYOFFICE/feature/StarMath
Fix StarMath
2024-06-11 06:19:47 -07:00
4070725515 Fix bug #68510 2024-06-11 18:34:27 +06:00
5dfeeeb809 Fix bug #68503 2024-06-11 15:52:14 +06:00
14b66e2bb3 Fix bug 68532 2024-06-11 11:39:04 +03:00
9a5e1464bd Fix bug #68485 2024-06-11 12:32:39 +06:00
af9a69d0f2 Update logic & fix bugs 2024-06-11 08:00:48 +03:00
819e568a35 Merge pull request #1547 from ONLYOFFICE/fix/bug-64722
Fix bug #64722
2024-06-10 03:36:46 -07:00
c8ce9c8a35 Merge pull request #1546 from ONLYOFFICE/fix/bug-68479
Fix bug 68479
2024-06-10 01:39:53 -07:00
95f91b816a Fix bug #64722 2024-06-10 11:18:54 +03:00
29788a5d1b Fix bug 68479 2024-06-10 11:14:55 +03:00
a81fb19e1a fix bug 68445 2024-06-10 10:35:08 +03:00
c82c8743f8 improvement of parsing and bracket conversion 2024-06-10 10:08:23 +03:00
ebef9ad556 Merge pull request #1545 from ONLYOFFICE/fix/bug68186 2024-06-07 18:45:05 +03:00
a564d289b7 Merge pull request #1543 from ONLYOFFICE/fix/html-bugs
Fix html bugs
2024-06-07 18:31:25 +03:00
a98ee52dc5 Fix bug 68186 2024-06-07 17:32:55 +03:00
f39355156c Merge remote-tracking branch 'origin/release/v8.1.0' into develop 2024-06-07 17:28:36 +03:00
99a560bebd Merge pull request #1544 from ONLYOFFICE/fix/bug68390
Fix bug #68390
2024-06-07 14:28:46 +03:00
cb10bccd6a Merge pull request #1538 from ONLYOFFICE/fix/bug68404
Fix bug #68404
2024-06-07 14:27:57 +03:00
c219ce8b06 Merge pull request #1537 from ONLYOFFICE/fix/bug68402
Fix bug #68402
2024-06-07 14:27:04 +03:00
afc8dd6e48 Merge pull request #1536 from ONLYOFFICE/fix/bug68400
Fix bug #68400
2024-06-07 14:24:14 +03:00
505c28f88d Merge pull request #1532 from ONLYOFFICE/fix/bug68238
Fix bug #68238
2024-06-07 14:23:44 +03:00
49d789dc77 Merge pull request #1524 from ONLYOFFICE/fix/bug65172
Fix bug #65172
2024-06-07 14:22:56 +03:00
2da89c8b03 Fix bug #68390 2024-06-07 15:59:35 +06:00
24fb53ac6f Fix bug #68426 2024-06-07 12:20:28 +03:00
4af39960da Fix bug #50286 2024-06-07 12:20:08 +03:00
29115060b4 Merge pull request #1540 from ONLYOFFICE/release/v8.1.0
Release/v8.1.0
2024-06-06 23:03:36 +03:00
dc485997f0 Merge pull request #1539 from ONLYOFFICE/feature/StarMath
Fix StarMath
2024-06-06 22:15:52 +03:00
2e6d5450b4 fix bug #66811 2024-06-06 16:22:04 +03:00
4ed4c5596f Fix bug #68404 2024-06-06 17:38:26 +06:00
dea44f1829 Fix bug #68402 2024-06-06 16:57:06 +06:00
b428487d07 Merge pull request #1535 from ONLYOFFICE/fix/bug-68123
Fix bug 68123
2024-06-06 13:22:30 +03:00
f366cae604 Fix bug #68400 2024-06-06 16:20:11 +06:00
96ea86e3c0 Fix bug 68123 2024-06-06 13:09:07 +03:00
5c7d0a61be fix bug 68332 2024-06-06 11:59:48 +03:00
4014d4914f fix bug 68327 2024-06-06 11:02:30 +03:00
0b77fb2bba fix bug 68333 2024-06-06 10:38:01 +03:00
2e1ccbc985 For bug 46629 2024-06-06 10:21:51 +03:00
f5202108a1 Merge pull request #1534 from ONLYOFFICE/fix/bug-68252
Fix bug #68252
2024-06-06 09:45:18 +03:00
2f7407bd8e Merge pull request #1533 from ONLYOFFICE/fix/bug-67967
Fix bug 67967
2024-06-06 09:45:00 +03:00
ac721572f2 Fix bug #67967 2024-06-06 08:51:59 +03:00
33da43b2f4 Fix bug 67747 2024-06-05 19:57:56 +03:00
6000944cc9 Fix bug #68238 2024-06-05 19:20:58 +06:00
591dffc965 Merge pull request #1531 from ONLYOFFICE/feature/StarMath
fix bug 68328
2024-06-05 15:57:20 +03:00
cd74ef4ded fix bug 68328 2024-06-05 15:52:33 +03:00
c7612a259d Add support create & save pdf forms 2024-06-05 14:41:41 +03:00
f665afc1ad Fix bug #68344 2024-06-05 14:31:48 +05:00
586455310a Merge pull request #1530 from ONLYOFFICE/fix/pdf-tilingPattern
Fix swap RGB pdf tilingPattern
2024-06-05 12:25:31 +03:00
96008085d6 Fix swap RGB 2024-06-05 11:46:30 +03:00
282b87e518 Merge pull request #1529 from ONLYOFFICE/fix/bug-63346
Fix bugs 63346, 66523
2024-06-05 11:16:00 +03:00
115a60c273 For bug 68216 2024-06-05 02:26:58 +03:00
66d48673cf Fix min tilingPattern 2024-06-04 15:41:58 +03:00
29ef74770a Fix bug 66523 2024-06-04 13:22:18 +03:00
15247d39f0 Fix bug 63346 2024-06-04 12:22:21 +03:00
e18fc06c7b Fix bug in first word splitting 2024-06-04 11:12:18 +03:00
145154690b Merge pull request #1528 from ONLYOFFICE/fix/bug-68349
For bug 68349
2024-06-04 09:59:16 +03:00
4f28d8d3d8 For bug 68349 2024-06-04 09:55:42 +03:00
4cd6e99531 Merge pull request #1527 from ONLYOFFICE/release/v8.1.0
Release/v8.1.0
2024-06-03 20:10:54 +03:00
2d3cd6bd3a Merge remote-tracking branch 'origin/release/v8.1.0' into develop 2024-06-03 16:15:48 +03:00
2fdd88bee2 Merge remote-tracking branch 'origin/fix/bug68170' into release/v8.1.0 2024-06-03 14:50:28 +03:00
7c501fe5a3 Fix bug #68252 2024-06-03 12:06:29 +03:00
acbf5b0c40 Fix bug #68170
Add image alternative text and description
2024-06-03 13:22:38 +05:00
d843cf1fe1 Fix bug #63489
Convert text divided into columns
2024-06-03 13:21:35 +05:00
50529346e4 Merge remote-tracking branch 'origin/release/v8.1.0' into fix/bug63489 2024-06-03 13:21:03 +05:00
803fcf3602 fix bug #68304 2024-06-02 17:35:48 +03:00
d83930bf67 fix bug #68307 2024-06-02 16:59:20 +03:00
cd5ca284e1 Change IsDouble method: return true if value has integer type 2024-06-02 15:37:04 +03:00
7a1a59a883 For bug 68028 2024-06-02 10:20:52 +03:00
56a08867db refactoring 2024-05-31 21:45:44 +03:00
bfb97ef026 Merge pull request #1526 from ONLYOFFICE/fix/pdf-tilepattern
Fix pdf rotate point
2024-05-31 16:47:41 +03:00
742cfde620 Fix rotate point 2024-05-31 16:39:41 +03:00
600fd26e30 fix build 2024-05-31 13:45:15 +03:00
92fa08303e Merge pull request #1525 from ONLYOFFICE/fix/pdf-default-color
Fix default color
2024-05-31 11:52:22 +03:00
17bd0f99dd Fix default color 2024-05-31 11:49:05 +03:00
4eaf500040 Fix bug #65172 2024-05-30 23:20:35 +06:00
d5d4d06553 Merge pull request #1517 from ONLYOFFICE/fix/bug66009
Fix bug #66009
2024-05-30 16:47:53 +03:00
400da99fa9 Merge pull request #1522 from ONLYOFFICE/fix/bug68229
Fix bug #68229
2024-05-30 16:46:56 +03:00
85be8041b1 Merge remote-tracking branch 'origin/release/v8.1.0' into develop 2024-05-30 16:42:51 +03:00
b209e00333 fix bug #68276 2024-05-30 16:30:59 +03:00
f86548c873 Refactoring 2024-05-30 16:27:00 +03:00
1859173fb6 Merge pull request #1523 from ONLYOFFICE/fix/bug-68256
Fix bug 68256
2024-05-30 13:06:54 +03:00
dfb0aeefcb Fix read/write tilingPattern in pdf 2024-05-30 12:45:56 +03:00
6ba5d1141e Fix bug 68256 2024-05-30 12:45:17 +03:00
8d6a13b24a Fix bug #68229 2024-05-30 15:41:52 +06:00
a66fdc73a5 fix bug #68264 2024-05-29 20:35:44 +03:00
a2b8fcc5e1 for bug #61035 2024-05-29 20:03:17 +03:00
7ac5ff5383 Merge pull request #1521 from ONLYOFFICE/fix/bug-68233
Fix bug 68233
2024-05-29 15:50:42 +03:00
5e560528a4 Fix bug 68233 2024-05-29 15:08:32 +03:00
b8c57da779 Merge pull request #1519 from ONLYOFFICE/fix/html
Fix html/mht bugs
2024-05-29 11:43:39 +03:00
19951d807c Merge pull request #1520 from ONLYOFFICE/feature/jsc-inspectable-context
Set contexts inspectable for JSC
2024-05-29 09:58:59 +03:00
49d1426831 Fix bug #68230 2024-05-29 01:33:56 +03:00
e8ae960a26 Fix bug #68235 2024-05-29 01:32:54 +03:00
11ddc0ab4f Set contexts inspectable for JSC 2024-05-28 23:50:21 +04:00
5361740a02 Merge pull request #1518 from ONLYOFFICE/fix/bug-68225
Fix bug 68225
2024-05-28 16:44:09 +03:00
0050c6148c Fix bug 68225 2024-05-28 16:33:41 +03:00
8e3df68ffc fix bug #50594 2024-05-28 15:27:12 +03:00
ab829fa8db fix bug #68213 2024-05-28 11:28:19 +03:00
be64e3e624 Fix spacing 2024-05-28 11:05:59 +03:00
2f6a542d02 Fix tatPlainParagraph type 2024-05-28 05:48:49 +03:00
f69b52e232 Fix bug 68004 2024-05-28 04:57:26 +03:00
ce15265d5a Fix split logic (in progress) 2024-05-27 23:28:05 +03:00
370e317b79 Updated split logic (in progress) 2024-05-27 22:21:28 +03:00
bc56de19c1 Fix bug #66009 2024-05-27 20:11:30 +06:00
1de6787014 Merge pull request #1516 from ONLYOFFICE/feature/StarMath
fix StarMath attribute
2024-05-27 13:32:11 +03:00
b02189c14d Merge pull request #1504 from ONLYOFFICE/fix/html
Fix html bugs
2024-05-27 13:23:40 +03:00
63003a5e76 fix bug 68094 2024-05-27 11:57:54 +03:00
499810dbae . 2024-05-27 08:01:06 +03:00
f55d822c4f fix build 2024-05-26 20:17:44 +03:00
4c51371b96 Merge pull request #1513 from ONLYOFFICE/fix/pdf-rotate
Fix pdf rotate
2024-05-25 21:53:19 +03:00
4be711c0bf Merge remote-tracking branch 'origin/release/v8.1.0' into develop 2024-05-24 17:43:32 +03:00
986bcae0e2 Merge pull request #1514 from ONLYOFFICE/fix/bug68109
Fix bug #68109
2024-05-24 17:20:27 +03:00
96b87265bb Merge pull request #1515 from ONLYOFFICE/fix/bug68113
Fix bug #68113
2024-05-24 17:19:24 +03:00
0be217ba05 Fix bug #68109 2024-05-24 18:23:17 +06:00
af12226bfa Fix FlateDecode for annot view 2024-05-24 14:51:30 +03:00
d51f035561 Fix AddShape for NewPage 2024-05-24 14:32:29 +03:00
d01681bb1e Fix bug #66549 2024-05-24 12:02:18 +03:00
72e975f7d9 Merge pull request #1512 from ONLYOFFICE/fix/pdf-bug
Fix bugs 54371, 67641
2024-05-24 09:57:00 +03:00
ba87df6b9d Fix bug 67641 2024-05-24 09:36:51 +03:00
a1fed79a78 Fix bug 54371 2024-05-24 09:36:31 +03:00
08111e8fde fix bug #67992 2024-05-23 17:46:02 +03:00
1286b7f458 fix bug #68122 2024-05-23 17:27:42 +03:00
dcb4364410 Fix bug 67641 2024-05-23 17:23:06 +03:00
55a009713e Fix bug 54371 2024-05-23 16:56:40 +03:00
474828364f Merge remote-tracking branch 'origin/release/v8.1.0' into fix/pdf-rotate 2024-05-23 16:31:30 +03:00
9e145ef9e0 Merge pull request #1511 from ONLYOFFICE/fix/pdf-bug
Fix 67740
2024-05-23 16:27:40 +03:00
40b6178a0d Fix c_nPenWidth0As1px for annot/field renderer 2024-05-23 16:22:52 +03:00
a70f50206d fix bug #67917 2024-05-23 14:36:14 +03:00
40fa3e60c4 Merge remote-tracking branch 'origin/release/v8.1.0' into fix/bug63489 2024-05-23 16:35:05 +05:00
105a193742 fix bug #68143 2024-05-23 14:00:28 +03:00
4ca9a94609 Fix bugs in html 2024-05-23 13:00:50 +03:00
3bfb3ee045 Fix bug #68113 2024-05-23 15:17:23 +06:00
512df584ba Merge branch 'release/v8.1.0' of https://github.com/ONLYOFFICE/core into release/v8.1.0 2024-05-23 12:03:20 +03:00
84eebc69e1 fix bug #68135 2024-05-23 12:03:14 +03:00
7abb3899a7 Merge pull request #1499 from ONLYOFFICE/fix/bug65948
fix bug #65948
2024-05-23 11:48:49 +03:00
f19906c14c Merge pull request #1500 from ONLYOFFICE/fix/bug66694
Fix bug #66694
2024-05-23 11:48:09 +03:00
fd15cdf4d0 Merge pull request #1508 from ONLYOFFICE/fix/bug66675
Fix bug #66675
2024-05-23 11:47:32 +03:00
9d3e553086 Merge pull request #1510 from ONLYOFFICE/fix/bug68111
Fix bug #68111
2024-05-23 11:46:11 +03:00
a19b4a03b3 Fixed a bug with attributes of functions and indexes 2024-05-23 11:27:28 +03:00
90650b1af8 Merge remote-tracking branch 'origin/fix/bug67380' into release/v8.1.0 2024-05-22 19:27:19 +03:00
3780922610 Fix bug #68111 2024-05-22 21:42:33 +06:00
fbb7ab93d6 Fix bug 67740 2024-05-22 17:37:33 +03:00
ca5201e704 FreeText has Rotate 2024-05-22 16:49:19 +03:00
2b13696379 Merge pull request #1509 from ONLYOFFICE/feature/docbuilder-python
Add new features to python docbuilder wrapper
2024-05-22 16:41:20 +03:00
24b32a2ba7 Fix bug #67380 2024-05-22 17:56:53 +05:00
1cdb2b0f15 Add list constructor and automatic conversion to CValue in functions 2024-05-22 16:52:13 +04:00
7758da7173 Add number constants for file types 2024-05-22 15:55:39 +04:00
3cd89354bc Fix pdf rotate for drawingfile 2024-05-22 11:08:12 +03:00
5fbed3db1c Fix double hashtag for color in RC 2024-05-22 10:30:09 +03:00
f28119e646 fix bug #68010 2024-05-21 20:47:23 +03:00
a2b0495254 Fix bug #66675 2024-05-21 21:11:57 +06:00
28f873be5c Merge pull request #1507 from ONLYOFFICE/feature/docbuilder-python
Add functionality in docbuilder python wrapper
2024-05-21 18:10:39 +03:00
5dede9304b Add support added images on recognize 2024-05-21 16:52:54 +03:00
ab52ee7486 Move PATH modify to windows-only section 2024-05-21 17:37:34 +04:00
3bf80a74fe Add split logic in paragraph 2024-05-21 12:13:43 +03:00
8f711f607f fix bug #67989 2024-05-21 11:25:57 +03:00
f2c5fed3c1 Merge pull request #1506 from ONLYOFFICE/fix/pdf-free-text
Fix FreeText renderer length
2024-05-21 10:54:01 +03:00
1602fb2106 Fix FreeText renderer length 2024-05-21 10:49:49 +03:00
c3f72756a4 Merge pull request #1505 from ONLYOFFICE/fix/pdf-build 2024-05-21 10:19:51 +03:00
5f8b557eb5 Fix pdf build 2024-05-21 10:18:18 +03:00
de31b16f91 Add Split logic 2024-05-21 09:27:54 +03:00
9d8e75a957 Fix library names for linux and mac 2024-05-20 19:40:40 +04:00
839844cb4f Merge pull request #1503 from ONLYOFFICE/fix/pdf-shape-img
Fix pdf shape image
2024-05-20 17:57:59 +03:00
fac976a22e Read and write image ref for OShapes 2024-05-20 17:52:22 +03:00
84cb59d7b2 Merge pull request #1502 from ONLYOFFICE/fix/pdf-freetext-rc
Fix pdf freetext
2024-05-20 14:09:06 +03:00
788620079d Add loadLibrary() check and automatic Dispose() 2024-05-20 14:33:43 +04:00
0e5b95f1d8 Refactoring 2024-05-20 13:29:38 +04:00
d0a82d71ee Fix build 2024-05-20 12:29:00 +03:00
97f742f816 Merge remote-tracking branch 'origin/release/v8.1.0' into fix/pdf-freetext-rc
# Conflicts:
#	PdfFile/PdfEditor.cpp
2024-05-20 10:14:57 +03:00
58980e61b7 Fix typo and create folder for tests 2024-05-19 12:02:37 +03:00
5a04f9033b Fix build 2024-05-19 11:33:45 +03:00
28785f13bc Merge pull request #1501 from ONLYOFFICE/feature/docbuilder-python
Feature/docbuilder python
2024-05-19 11:23:46 +03:00
7a73d3288c Refactoring 2024-05-19 11:21:18 +03:00
d82b2dc6ef Fix bug #68073 2024-05-18 14:14:05 +03:00
6ad319554d Fix bug with font-size 2024-05-18 13:42:32 +03:00
ff3b94a23a Fix bug #68036 2024-05-18 13:05:58 +03:00
5227a593ed Fix bug #68034 2024-05-18 13:05:34 +03:00
c802944d3b Fixes in docbuilder.py
+ Add more complex example
+ Add .gitignore
2024-05-17 23:16:02 +04:00
93d77ee945 Added all classes to docbuilder.py 2024-05-17 22:09:38 +04:00
4c101b21d0 Changed lines ending for consistency 2024-05-17 22:07:17 +04:00
05366635c1 Remove development 2024-05-17 18:10:30 +03:00
d853d42090 Fix calculating glyph widths for Base14 fonts 2024-05-17 16:00:23 +03:00
cb06eae63e Merge remote-tracking branch 'origin/release/v8.1.0' into fix/bug63489 2024-05-17 17:20:42 +05:00
6ba40aba51 Fix bug #67380 2024-05-17 16:57:40 +05:00
b8d54fb295 fix bug #65948 2024-05-17 17:55:02 +06:00
84d7eb03f2 Add example of python wrapper 2024-05-17 14:11:22 +04:00
28cd584393 Fix delete functions and add simple c++ example 2024-05-17 14:10:50 +04:00
bd6cc8a759 Merge remote-tracking branch 'origin/fix/bug67926' into release/v8.1.0 2024-05-17 12:21:01 +03:00
7cfd4e2dfa Merge remote-tracking branch 'origin/fix/bug67822' into release/v8.1.0 2024-05-17 12:20:45 +03:00
f923f4e03d Merge remote-tracking branch 'origin/fix/bug67823' into release/v8.1.0 2024-05-17 12:20:32 +03:00
e8898ce424 Merge remote-tracking branch 'origin/fix/bug61378' into release/v8.1.0 2024-05-17 12:19:39 +03:00
ebe045a833 fix bug #67995 2024-05-17 11:56:18 +03:00
140f9970f9 Add wrapper library docbuilder_functions.dll and tests for it 2024-05-17 12:07:22 +04:00
3d23e74818 Fix bug #61378 2024-05-16 21:48:26 +05:00
c24c78267b Write Base14 fonts to pdf 2024-05-16 18:56:59 +03:00
a7501e370b Fix bug #66694 2024-05-16 19:06:13 +06:00
68200895d0 Merge pull request #1496 from ONLYOFFICE/fix/StarMath
Fix/StarMath
2024-05-16 13:57:28 +03:00
b6b99ee9f0 Redirect to annotation rendering 2024-05-15 17:43:59 +03:00
5ea601cde9 fix bug #67973 2024-05-15 16:25:51 +03:00
1e7611f3f9 Add method for duplicate image links on recognize 2024-05-15 13:20:20 +03:00
c14856ac6f fix bug #68011 2024-05-15 11:15:31 +03:00
8857d3daca fix bug #67972 2024-05-15 11:00:27 +03:00
ad1bd06bb3 fix bug #67968 2024-05-15 09:55:58 +03:00
52555f4d9d fix bug #67963 2024-05-15 09:24:08 +03:00
d85b3dd7f0 Support images on recognize 2024-05-14 21:43:21 +03:00
6af44146e5 Merge pull request #1495 from ONLYOFFICE/fix/bug66658
Fix bug 66658
2024-05-14 18:30:42 +03:00
f704c44e9e Merge pull request #1497 from ONLYOFFICE/fix/bug66678
Fix bug #66678
2024-05-14 18:30:10 +03:00
a9884c1efb Merge pull request #1498 from ONLYOFFICE/fix/bug66677
Fix bug #66677
2024-05-14 18:29:50 +03:00
2dc0956b3c Create CAnnotRenderer 2024-05-14 17:52:04 +03:00
7dbe7eb3e1 Fix bug #66677 2024-05-14 19:16:08 +06:00
5617968a0c Fix bug #67926 2024-05-14 17:51:19 +05:00
3b029ae4cd Merge branch 'release/v8.1.0' into fix/StarMath 2024-05-14 14:43:16 +03:00
73dc770870 Fix bug #66678 2024-05-14 17:41:48 +06:00
46e56afa5c bug fix(crashes, parsing correction) 2024-05-14 14:31:24 +03:00
e6842f50b3 Fix bug #bug66658 2024-05-14 15:20:51 +06:00
f4ec536794 Fix bug 67809 2024-05-14 10:40:54 +03:00
f008857ab2 Find Font for FreeText 2024-05-13 18:12:23 +03:00
e7022472ff Merge pull request #1492 from ONLYOFFICE/fix/bug67936
Fix bug #67936
2024-05-13 18:00:11 +03:00
b470c4b259 Merge pull request #1493 from ONLYOFFICE/fix/bug67933
Fix bug #67933
2024-05-13 17:59:56 +03:00
155103b40f Fix bug #67933 2024-05-13 15:30:01 +06:00
0eee7ea548 Merge pull request #1491 from ONLYOFFICE/fix/bug-67916
Fix bug #67916
2024-05-13 01:58:54 -07:00
b53527c9fd Fix bug #67936 2024-05-13 14:53:32 +06:00
fb12bfa57f Add MovablePoints on Label 2024-05-13 11:17:30 +03:00
1a5af05024 Merge pull request #1490 from ONLYOFFICE/release/v8.1.0
Release/v8.1.0
2024-05-13 00:36:14 -07:00
7a842c4b14 Merge pull request #1489 from ONLYOFFICE/fix/html
Fix html
2024-05-12 12:45:44 -07:00
9779e53fe7 The algorithm for checking arrays has been rewritten 2024-05-12 21:50:04 +03:00
5c495dcf8d Merge pull request #1488 from ONLYOFFICE/release/v8.1.0
Release/v8.1.0
2024-05-12 07:16:18 -07:00
6bccf233ee Merge pull request #1477 from ONLYOFFICE/fix/html
Fix bugs in html converter
2024-05-12 06:46:37 -07:00
83e020f492 Fix bug #67916 2024-05-10 14:32:23 +03:00
84e4797ddf fix bug #67940 2024-05-10 10:53:02 +03:00
40e7685751 fix bug #67941 2024-05-10 10:40:07 +03:00
bfdd7be53c Merge pull request #1487 from ONLYOFFICE/fix/bug67919
Fix bug #67919
2024-05-08 17:41:06 +03:00
198498a26d Merge pull request #1486 from ONLYOFFICE/fix/bug67922
Fix bug #67922
2024-05-08 17:40:34 +03:00
3ba74a0373 Merge pull request #1485 from ONLYOFFICE/fix/bug67923
Fix bug #67923
2024-05-08 17:40:17 +03:00
5c7b7615dd Fix find FreeText Fonts object 2024-05-08 17:40:11 +03:00
e2992c2a79 Fix bug #67919 2024-05-08 19:33:43 +06:00
aab5cfe30c Fix bug #67922 2024-05-08 19:15:45 +06:00
f32ace9737 Fix bug #67923 2024-05-08 18:50:17 +06:00
d8bed77b67 Fix bug #67823 2024-05-08 17:05:49 +05:00
7ae79f20b8 Fix bug #67822 2024-05-08 15:12:22 +05:00
0a09d4a872 Merge pull request #1482 from ONLYOFFICE/fix/bug67897
Fix bug67897
2024-05-08 13:06:42 +03:00
68e778ba1f Merge pull request #1483 from ONLYOFFICE/fix/bug67898
Fix bug #67898
2024-05-08 13:06:20 +03:00
6d28d1af1d Merge pull request #1484 from ONLYOFFICE/fix/bug67891
Fix bug #67891
2024-05-08 13:05:52 +03:00
7e7bc0eb0e Fix bug #67891 2024-05-08 15:39:02 +06:00
b32728c9f0 fix bug #66842 2024-05-08 12:06:28 +03:00
39748f9d9e fix bug #67895 2024-05-08 11:49:04 +03:00
dabe547fb4 [android] Build only arm arch 2024-05-08 11:33:09 +03:00
3104f84768 fix bug #67876 2024-05-08 10:53:05 +03:00
bb2967c3ea Write RD and CA for FreeText AP.N 2024-05-07 17:43:26 +03:00
de1c08d65a Fix bug #67898 2024-05-07 20:40:12 +06:00
a68f18c9f2 Fix bug #67897 2024-05-07 19:55:22 +06:00
d16d7a1e76 Merge pull request #1479 from ONLYOFFICE/fix/bug67867
Fix bug #67867
2024-05-07 15:21:18 +03:00
2338218fa6 Merge pull request #1478 from ONLYOFFICE/fix/bug67864
Fix bug67864
2024-05-07 15:21:05 +03:00
a46115f056 Merge pull request #1480 from ONLYOFFICE/fix/bug67860
Fix bug #67860
2024-05-07 15:20:53 +03:00
d61747c283 Merge pull request #1481 from ONLYOFFICE/feature/libvlc-player-vout
Add video output signal to libvlc
2024-05-07 05:12:50 -07:00
10afcda7a3 Add new signal to CVlcPlayer 2024-05-07 14:31:02 +04:00
680c3824f7 Fix bug #67860 2024-05-07 16:00:34 +06:00
194d1c2208 Fix bug #67864 2024-05-07 15:04:29 +06:00
88aba1cb02 Fix MK.IF.A default value 2024-05-07 11:43:20 +03:00
fd664bafae Fix bug #67867 2024-05-07 14:20:46 +06:00
c03ec96966 . 2024-05-07 10:40:24 +03:00
5e02a7c21e Merge remote-tracking branch 'origin/fix/xlsb_conversion' into release/v8.1.0 2024-05-07 10:25:34 +03:00
bce25e9788 Fix mac build 2024-05-06 22:14:57 +03:00
b8332ae05b Merge pull request #1461 from ONLYOFFICE/feature/libvlc-functions
Add some functionality to libvlc player
2024-05-06 09:39:26 -07:00
f1fbcf653b Create StartDrawFreeText 2024-05-06 17:48:12 +03:00
283d611ad7 Fix sparkline conversion 2024-05-06 20:44:19 +06:00
045ca4ad9e . 2024-05-06 16:03:34 +03:00
f7a623a052 Merge branch 'release/v8.1.0' of https://github.com/ONLYOFFICE/core into release/v8.1.0 2024-05-06 15:49:06 +03:00
0439347bc3 fix bug #67782 2024-05-06 15:49:01 +03:00
441716773f Add property for strip x2t library 2024-05-06 15:12:02 +03:00
801e068abb Merge remote-tracking branch 'origin/fix/bug67815' into release/v8.1.0 2024-05-06 14:35:09 +03:00
a44e22c726 fix bug #67818 2024-05-06 14:34:06 +03:00
63bd2a1cbf Fix bug #67815 2024-05-06 15:49:48 +05:00
c88c1aac96 [android] Fix copy libs and build 2024-05-04 20:52:51 +03:00
a2e76364e9 Fix bug #67827 2024-05-04 15:19:06 +03:00
051ae3fab6 Fix bug #67836 2024-05-04 00:34:50 +03:00
f1544a6f6c Fix bug#67829 2024-05-03 22:50:16 +03:00
715facaefc Create AP for FreeText 2024-05-03 17:32:37 +03:00
6de671ccd5 Added language consideration when converting EPUB files 2024-05-03 15:57:29 +03:00
e61a727180 Merge pull request #1475 from ONLYOFFICE/fix/pdf-link
Fix pdf link
2024-05-03 15:42:40 +03:00
30e09e731b Fix delete Link annot in edit mode 2024-05-03 15:39:54 +03:00
d516c625eb Fix EditPage when adding Link in edit mode 2024-05-03 15:39:13 +03:00
9dceffdbeb Fix write RC to NSStringUtils::CStringBuilder 2024-05-03 15:36:51 +03:00
e107a67f55 Fix delete Link annot in edit mode 2024-05-03 15:36:14 +03:00
ee85c3597e fix bug #67011 2024-05-03 15:06:19 +03:00
ddc413a1b3 Fix EditPage when adding Link in edit mode 2024-05-03 13:39:03 +03:00
5c6aaed51f Fix svg file size 2024-05-03 13:18:53 +03:00
234c1766dc Fix bug #67770 2024-05-03 13:18:26 +03:00
95d8fd2871 Fix bug #67767 2024-05-03 13:17:41 +03:00
a6d9af576d . 2024-05-03 12:38:06 +03:00
23c54255e3 Fix ptg conversion 2024-05-03 13:55:29 +06:00
013d6990ce Write RC to FreeText 2024-05-02 18:32:32 +03:00
25b33244a4 fix bug #67011 2024-05-02 15:57:47 +03:00
c8c4127fbb Merge pull request #1474 from ONLYOFFICE/fix/bug62568
Fix/bug62568
2024-05-02 14:53:13 +03:00
33fdfadcf7 fix bug #66679 2024-05-02 11:33:28 +03:00
3d7fa985f7 Change libraries list for x2t 2024-05-01 21:51:58 +03:00
63c9185fd2 Add choice of colors for non parametric gradients 2024-04-29 22:08:28 +03:00
e69dc4f898 Remove unneeded files from compilation 2024-04-27 16:45:28 +03:00
32b5dfc04a for bug #67352 2024-04-27 16:43:18 +03:00
2d78eda6ad Merge remote-tracking branch 'origin/fix/bug65612' into release/v8.1.0 2024-04-27 16:35:59 +03:00
ae03967fb6 Merge remote-tracking branch 'origin/fix/bug61378' into release/v8.1.0 2024-04-27 16:26:27 +03:00
5db50d2ff7 Merge branch 'release/v8.1.0' into fix/xlsb_conversion 2024-04-27 17:43:35 +06:00
af226ceb67 Merge pull request #1473 from ONLYOFFICE/fix/bug67544
fix bug #67544
2024-04-27 14:41:34 +03:00
b17a6be4d5 fix bug #67679 2024-04-27 14:27:17 +03:00
7f791ad265 fix bug #67544 2024-04-27 17:27:11 +06:00
03b568ad49 fix bug #67673 2024-04-27 12:24:30 +03:00
f9bfdee8c3 Merge pull request #1470 from ONLYOFFICE/release/v8.1.0
Release/v8.1.0
2024-04-27 11:53:22 +03:00
123fcf9d3c Merge pull request #1472 from ONLYOFFICE/fix/bug-63701
Fix bug #63701
2024-04-27 11:29:56 +03:00
e673fd5b38 Merge pull request #1471 from ONLYOFFICE/fix/bug-67716
Fix bug #67716
2024-04-27 11:29:24 +03:00
0b07bef0de Fix for pptx shapes 2024-04-27 02:22:33 +03:00
ba4c5b31d1 Fix previous commit 2024-04-27 01:46:43 +03:00
6b5f930a1e Add custom image storage to docxrenderer 2024-04-27 01:44:26 +03:00
51c6fe496b Add parametrs input 2024-04-26 19:40:08 +03:00
4880ff705b Merge branch 'release/v8.1.0' into fix/StarMath 2024-04-26 17:30:39 +03:00
4f7841fa85 Merge pull request #1464 from ONLYOFFICE/fix/bug67231
Fix bug 67231
2024-04-26 17:23:34 +03:00
3acb44a5c9 Fixed drop in assessment. fix bugs. 2024-04-26 17:08:50 +03:00
5108fa6b94 Fix bug 66740 2024-04-26 14:44:03 +03:00
db5909fdf5 Fix bug #67716 2024-04-26 14:39:34 +03:00
051a1fa7ef Fix bug 67444 2024-04-26 12:47:51 +03:00
2fa4cdebb9 Fix table conversion 2024-04-25 21:35:11 +06:00
3c2f4874fc Fix bug #63701 2024-04-25 16:15:48 +03:00
66d8690dc3 Fix bug 66872 2024-04-25 12:08:44 +03:00
0f9b8f14e6 Fix bug #61378 2024-04-24 22:19:35 +05:00
eb1bc2779b Fix formula types conversion 2024-04-24 18:35:38 +06:00
ed9a5f1a24 editing tabs 2024-04-23 15:55:32 +03:00
31090af440 Fix array formula conversion 2024-04-22 16:32:40 +06:00
73624f28ac Fix android build 2024-04-20 14:02:19 +03:00
9daa8a1239 Fix build 2024-04-20 13:21:45 +03:00
82b634878f Fix build 2024-04-20 12:40:01 +03:00
033f61576e Merge pull request #1466 from ONLYOFFICE/fix/mht
Improved html and mht conversion
2024-04-19 20:50:11 +03:00
283f21de86 Add class Custom label for handle click 2024-04-19 20:13:30 +03:00
6de60d2543 Fix bugs in html to ooxml conversion 2024-04-19 19:20:45 +03:00
b7af10970a Merge pull request #1465 from ONLYOFFICE/fix/csv-date-conversion
Fix csv date conversion
2024-04-19 14:26:56 +03:00
c18224ea07 Fix csv date conversion 2024-04-19 17:17:14 +06:00
0a088eb949 fix bug 67231 2024-04-18 21:32:51 +03:00
48df470387 Merge pull request #1463 from ONLYOFFICE/fix/pdf-text-annot
Fix pdf text annot
2024-04-18 18:19:01 +03:00
c3767cf68e Fix bug 67439 2024-04-18 18:01:23 +03:00
663248ae2b Merge branch 'release/v8.1.0' into fix/xlsb_conversion 2024-04-18 20:53:34 +06:00
040ead411f Fixed a bug with encoding detection 2024-04-18 15:04:50 +03:00
a94a068202 Fix cell error conversion 2024-04-18 17:58:50 +06:00
05ad136231 Draw AP for 11-16 types text annot 2024-04-18 12:18:57 +03:00
b6c81a1f05 Draw AP for 0-10 types text annot 2024-04-17 17:52:20 +03:00
513b39b156 Fix bugs in html to ooxml conversion 2024-04-17 16:33:44 +03:00
2956768477 Merge pull request #1462 from ONLYOFFICE/fix/pdf-annot-text
Fix pdf annot text
2024-04-17 13:17:01 +03:00
a782d26621 Fix build 2024-04-17 13:04:55 +03:00
c859b5c440 Rename IsEditPage 2024-04-17 12:50:43 +03:00
6065c8b1f2 Fix bug 67337 2024-04-17 12:47:42 +03:00
bd39d887cf Create DrawTextComment-N and -R 2024-04-16 17:35:52 +03:00
6778a4c0da Add operators check in pthtypesParsing 2024-04-16 18:17:49 +06:00
2901f337e7 Add some functionality to libvlc player 2024-04-16 15:15:37 +04:00
ca179304c3 Fix bugs in html to ooxml conversion 2024-04-15 21:46:24 +03:00
cb53604c13 Add parsing ptg types method 2024-04-15 19:27:19 +06:00
2ad2ad9dfd Merge pull request #1460 from ONLYOFFICE/fix/pdf-shape
Fix clear content
2024-04-15 14:34:47 +03:00
6431ba5245 Fix clear content 2024-04-15 14:02:43 +03:00
2e74e8fa11 fix bug #67398 2024-04-14 17:06:40 +03:00
1e18eb4335 Merge pull request #1459 from ONLYOFFICE/fix/x2t_date_time 2024-04-12 20:32:58 +03:00
ddb01d9478 Sets bDateTime true by default 2024-04-12 20:19:12 +03:00
e11ddf9153 Merge pull request #1458 from ONLYOFFICE/feature/pdf-shape
Feature pdf shape
2024-04-12 17:48:38 +03:00
2f916dcd11 Fix build 2024-04-12 17:45:31 +03:00
8b2b4d1bbf Add support shapes from metadata 2024-04-12 17:07:20 +03:00
6adc289948 Merge remote-tracking branch 'origin/release/v8.1.0' into feature/pdf-shape 2024-04-12 13:57:53 +03:00
4f3d495b3a Rotate page 2024-04-12 13:56:05 +03:00
79fa4f26a7 Remove GetShapes test 2024-04-12 13:55:14 +03:00
52a07814f4 Improving the quality of converting html tables to ooxml and refactoring 2024-04-12 13:17:13 +03:00
2e32a1b70a Remove GetShapes 2024-04-12 12:50:07 +03:00
79d90b89bd Merge pull request #1457 from ONLYOFFICE/fix/office_utils
Fix bug with headers in zip
2024-04-12 10:03:29 +03:00
43c05c6041 Fix fromJS method 2024-04-11 17:02:21 +03:00
3015aff491 . 2024-04-11 16:35:23 +03:00
490e3be6c4 Merge pull request #1456 from ONLYOFFICE/fix/bug66286
For bug 66286
2024-04-11 16:18:48 +03:00
1929e2e5c9 Fix page scale 2024-04-11 16:02:48 +03:00
b7ca461ba5 Fix coord shift 2024-04-11 14:42:11 +03:00
8309c5bbfe End every paragraph with a:endParaRPr 2024-04-11 15:12:26 +05:00
ad60357f6f Merge remote-tracking branch 'origin/release/v8.1.0' into feature/pdf-shape
# Conflicts:
#	DocxRenderer/src/resources/VectorGraphics.h
2024-04-11 11:13:32 +03:00
de2ecb08a0 . 2024-04-10 22:09:51 +03:00
897c7493da Fixes for .m files 2024-04-10 20:31:35 +03:00
0700038802 Refactoring 2024-04-10 19:12:01 +03:00
d733af03aa Fix icon set conversion 2024-04-10 20:30:26 +06:00
13b0458d47 Add support for external headers 2024-04-10 15:30:52 +03:00
defbcd77fb Add originIndex for drawingfile 2024-04-10 13:12:08 +03:00
5e02d5d943 Fix begin/end-MarkedContent 2024-04-10 13:07:21 +03:00
aa83a2dda2 ShapeStart, ShapeEnd for RendererOutputDev 2024-04-10 12:44:03 +03:00
5c7ebcd3ff BMC replaced by BDC for marked content 2024-04-10 12:42:32 +03:00
82d577c335 ShapeStart, ShapeEnd to DocInfo 2024-04-10 12:40:25 +03:00
cecf3fe9a8 Fix bug with headers in zip 2024-04-10 11:41:15 +03:00
3e4c531538 Add default parametrs and new gradient types 2024-04-10 01:18:40 +03:00
b4556c0254 Refactoring 2024-04-09 22:55:42 +03:00
5708517a0e fix bug #67016 2024-04-09 21:02:22 +03:00
e728a58222 Fix cond fmt conversion from xlsb to xlsx 2024-04-09 22:17:25 +06:00
7db54c9cef Merge pull request #1454 from ONLYOFFICE/fix/bug66286
Fix bug 66286
2024-04-09 17:55:59 +03:00
a9dd418841 Fix build 2024-04-09 17:39:45 +03:00
8491d20439 Add fmla test case 2024-04-09 20:31:24 +06:00
30ae04fd6e Update test files 2024-04-09 20:31:09 +06:00
85980186ac Fix bug 66286 2024-04-09 16:46:52 +03:00
471c9a4ebd Improved work with caption tables when html to ooxml conversion 2024-04-09 16:18:46 +03:00
2481f7f257 Fix build with old compilers 2024-04-09 13:09:01 +03:00
f5ca81240b Fix connection conversion 2024-04-09 14:13:29 +06:00
2038ace911 Fix build 2024-04-09 10:03:19 +03:00
2277feb87d fix bug #67327 2024-04-08 19:55:37 +03:00
229c88a7be fix build 2024-04-08 19:55:08 +03:00
7accccb3ab Merge remote-tracking branch 'origin/release/v8.1.0' into feature/pdf-shape
# Conflicts:
#	DesktopEditor/graphics/pro/js/wasm/src/drawingfile.cpp
#	DocxRenderer/src/logic/Page.cpp
2024-04-08 18:02:41 +03:00
e33e659c22 Restore write xfrm to docx shapes. Add pptx shapes to wasm module 2024-04-08 17:35:40 +03:00
4ddde8246d Add ctPageRotate, AddPage and RemovePage 2024-04-08 17:17:06 +03:00
2ab2cb7cf2 Fix connections conversion 2024-04-08 18:45:59 +06:00
dbbd6cbbe6 Merge pull request #1452 from ONLYOFFICE/feature/docx_renderer2
Feature/docx renderer2
2024-04-08 13:22:00 +03:00
29afb2aed9 Add Triangle gradient 2024-04-05 19:34:20 +03:00
8c522aa006 Fix repeat fonts 2024-04-05 17:21:51 +03:00
bb858cc24a . 2024-04-05 16:59:03 +03:00
31079f91be Merge remote-tracking branch 'origin/fix/bug60279' into release/v8.1.0 2024-04-05 16:54:46 +03:00
8ad98fae68 Merge remote-tracking branch 'origin/fix/bug61378' into release/v8.1.0 2024-04-05 16:50:09 +03:00
790f51dd1b Merge remote-tracking branch 'origin/fix/bug67089' into release/v8.1.0 2024-04-05 16:48:05 +03:00
d13e5dc3da Merge remote-tracking branch 'origin/feature/odg' into release/v8.1.0 2024-04-05 16:47:48 +03:00
10c6def10e Bug fixed. Editing sqrt and nroot, dropping parentheses. 2024-04-05 15:54:31 +03:00
b2bcdbc2bc Fix bug #61378 2024-04-05 16:02:06 +05:00
bfefe4d1b7 Merge remote-tracking branch 'origin/release/v8.1.0' into feature/pdf-shape
# Conflicts:
#	DesktopEditor/graphics/pro/js/wasm/src/pdfwriter.cpp
#	PdfFile/PdfReader.cpp
#	PdfFile/SrcWriter/Document.cpp
2024-04-05 12:25:30 +03:00
7f17f30650 for bug 67231 2024-04-04 20:42:29 +03:00
6fdac51409 Merge pull request #1451 from ONLYOFFICE/fix/bug66986
For bug #66986
2024-04-04 16:53:58 +03:00
463ca006ee Fixed bugs with tables in html to ooxml conversion 2024-04-04 16:48:52 +03:00
e8a69e39bc Fix bugs #67249, #65628 2024-04-04 16:40:41 +03:00
8b9c0d79bb Fix bug #67210 2024-04-04 14:27:48 +03:00
12fd3bd3ce Comment conditional formattings ext 2024-04-04 17:20:59 +06:00
2f7447f918 For bug #66986 2024-04-04 12:40:16 +03:00
86b53b7ede Refactoring 2024-04-04 10:22:35 +03:00
078e9afcc2 Fix conditional formatting conversion 2024-04-03 21:31:09 +06:00
91bc306369 Fix bug #67089 2024-04-03 19:58:18 +05:00
21e3293895 fix image size from pixels to millimeters 2024-04-03 15:31:07 +03:00
ab4a3ef546 fix bug #67231 2024-04-03 11:53:12 +03:00
3d2e43b5d7 fix namespace math 2024-04-03 11:50:09 +03:00
fcb4ae3909 Merge pull request #1446 from ONLYOFFICE/fix/bug66934
Fix bug #66934
2024-04-02 19:04:57 +03:00
ebe0248c3f fix bug #67016 2024-04-02 13:08:08 +03:00
083ced27c8 fix build 2024-04-02 12:32:04 +03:00
cd86a8a3c7 fix image size and GenerateImg method 2024-04-02 00:47:50 +03:00
3c8604390e Fix table styles conversion 2024-04-01 16:03:16 +06:00
d23268b76e Merge branch 'release/v8.1.0' into fix/xlsb_conversion 2024-04-01 14:30:24 +06:00
2b72bf3f53 Fix bugs (correction of indexes, without elements between them, editing of frac and binom)
(cherry picked from commit 43bee348aa)
2024-04-01 10:48:20 +03:00
110617547c improvements to attribute parsing
(cherry picked from commit 7776f15a35)
2024-04-01 10:47:46 +03:00
db95af6c58 refinement of parsing and conversion of indexes. editing and writing tests.
(cherry picked from commit 62b3b7b3c6)
2024-04-01 10:47:39 +03:00
b1794fcf96 editing parsing of indexes with operators. adding alignment.
(cherry picked from commit 1dff8bb868)
2024-04-01 10:47:27 +03:00
fcd0bec3ac conversion of unary symbols. code refactoring.
(cherry picked from commit 89287887a0)
2024-04-01 10:47:11 +03:00
3d394b173c fix bugs
(cherry picked from commit 97ddd35653)
2024-04-01 10:46:56 +03:00
0b05f25488 Merge commit '835f4ba89db4bf52993519a88948923821db17be' into feature/odf-math-2 2024-04-01 10:45:07 +03:00
c44aed0e9a Refactoring 2024-03-30 12:53:30 +03:00
2156d6e134 fix bug #66842 2024-03-29 17:28:02 +03:00
9094965909 Fix bug #60279 2024-03-29 17:04:39 +05:00
9e1e641218 Add test for Linear and Radial gradients 2024-03-29 12:37:31 +03:00
8332560d06 Fix data validations 2024-03-29 15:31:52 +06:00
b7a4c739eb fix bug #67121 2024-03-28 13:40:59 +03:00
db9015a3e7 Change ms placeholder presentation type 2024-03-28 14:01:38 +05:00
f203f73a4b fix bug #67087 2024-03-27 18:40:38 +03:00
7a31de1708 Merge branch 'release/v8.1.0' into fix/xlsb_conversion 2024-03-27 14:55:31 +06:00
e2d278c74b Fix dxfs conversion 2024-03-27 14:54:22 +06:00
c961f00fd1 fix bug #67043 2024-03-26 20:06:43 +03:00
a31361fe05 Added a method for equating any one to the nearest of the given ones 2024-03-26 19:38:12 +03:00
53b93ed9f2 fix bug #67109 2024-03-26 19:34:29 +03:00
22a255f351 Fix images bug 2024-03-26 17:57:31 +03:00
cbac820495 fix bug #67066 2024-03-26 17:37:06 +03:00
4cc7ec1ed0 Fix dxfs conversion 2024-03-26 18:03:51 +06:00
8b16b1625f Fix bug 2024-03-26 11:46:30 +03:00
9e260897b3 Fixed a bug with the percentage size of the svg file 2024-03-26 10:56:52 +03:00
b10e482fbb Fix dxf prop conversion 2024-03-25 22:21:22 +06:00
510a6a621d fix bug #67054 2024-03-25 18:13:10 +03:00
4a1f483315 Fix alignment + fix logic 2024-03-24 22:47:03 +03:00
7e1c27e5ad Merge pull request #1448 from ONLYOFFICE/fix/bug67066
Fix bug 67066
2024-03-22 14:17:39 +03:00
c223714b52 Fix bug 67066 2024-03-22 13:54:48 +03:00
23f6a3a3df Merge branch 'release/v8.1.0' into fix/xlsb_conversion 2024-03-22 13:48:24 +06:00
aad7f089e4 Fix pivot tables conversion 2024-03-21 20:31:04 +06:00
03244e9e83 For bug #65612
Fix Split/Cover transition parameter conversion
2024-03-21 14:44:44 +05:00
8adf556ea8 Merge pull request #1447 from ONLYOFFICE/fix/pdf-cropbox-ap
Fix cropbox offset for AP annots
2024-03-21 12:23:40 +03:00
bb84209b05 Fix cropbox offset for AP annots 2024-03-21 12:02:59 +03:00
e01aa641a0 Remove PdfWriter_empty 2024-03-20 18:15:42 +03:00
c9fbe4189c Added merging of extra cells in html to ooxml conversion 2024-03-20 13:51:18 +03:00
475d0be0bf fix bug #59931 2024-03-20 11:54:48 +03:00
70a4e3e792 fix bug #67008 2024-03-20 10:55:55 +03:00
7c349dfa18 Create PdfEditor 2024-03-19 18:58:52 +03:00
4943193ef7 fix bug #66868 2024-03-19 16:44:26 +03:00
3a6f74dc82 fix flags 2024-03-19 16:08:21 +03:00
8c00325004 Merge remote-tracking branch 'origin/feature/pdf-freetext' into feature/pdf-shape 2024-03-19 14:48:33 +03:00
4deae80350 Fix right alignments 2024-03-19 12:27:22 +03:00
d5a4cd43e3 Fix bug 2024-03-19 11:23:58 +03:00
6eaf5cc9d3 Fix ScanPagePptx 2024-03-19 11:15:25 +03:00
ad2c6b67f1 fix bug #66864 2024-03-19 11:00:37 +03:00
13542b1388 fIx content types writing for worksheets and pivot tables 2024-03-18 22:38:46 +06:00
1b865e9b13 Refactoring AnnotField and FormField 2024-03-18 17:53:32 +03:00
cfee077b9d Merge remote-tracking branch 'origin/fix/bug66795' into release/v8.1.0 2024-03-18 15:57:32 +03:00
30d4dbae5a Merge branch 'release/v8.1.0' into fix/xlsb_conversion 2024-03-18 18:28:44 +06:00
6874e110bb fix build 2024-03-18 15:21:21 +03:00
f89becf68f Fix bug #66934 2024-03-18 18:18:08 +06:00
88008a9e7e fix bug #66959 2024-03-17 11:34:53 +03:00
b20e29daaf fix bug #66960 2024-03-17 09:24:24 +03:00
95cf8bc4bd Merge branch 'feature/docx_renderer2' of https://github.com/ONLYOFFICE/core into feature/docx_renderer2 2024-03-15 18:38:51 +03:00
b311bb319b ScanPagePptx done 2024-03-15 18:37:48 +03:00
21f73ba724 Merge pull request #1445 from ONLYOFFICE/feature/json-strings
JSON: Simplification of working with strings
2024-03-15 17:41:20 +03:00
ce9d61a3aa Fixed json test 2024-03-15 18:31:42 +04:00
b2c8696d1d Change strings conversion function 2024-03-15 18:16:58 +04:00
be0c6b13e7 Strings unify 2024-03-15 17:56:17 +04:00
ba307e8d2b Merge pull request #1444 from ONLYOFFICE/fix/bug66947
Fix bug 66947
2024-03-15 16:43:28 +03:00
4364f95fb6 Fix bug 66947 2024-03-15 16:30:12 +03:00
fb4c8ebf32 Refactoring and fix bugs 2024-03-15 15:57:57 +03:00
e53416e934 Add worksheet write before another parts 2024-03-15 18:10:58 +06:00
1a92ec57e1 Fix multisheet reference conversion 2024-03-15 18:09:36 +06:00
d0adabc5f7 Fix bug #66795 2024-03-15 17:04:33 +05:00
b9bf82d932 Merge branch hotfix/v8.0.1 into release/v8.1.0 2024-03-15 11:12:33 +00:00
f067fc3268 Merge branch hotfix/v8.0.1 into develop 2024-03-15 11:12:29 +00:00
dc3a4a3ed9 Merge branch hotfix/v8.0.1 into master 2024-03-15 11:12:24 +00:00
53ca119a99 Improved conversion of tables from html to ooxml 2024-03-15 12:58:03 +03:00
bf63f5322c Merge pull request #1440 from ONLYOFFICE/fix/bug66933
Fix bug 66933
2024-03-15 12:51:36 +03:00
f682f51481 Fix bug 66933 2024-03-15 12:17:11 +03:00
933741ca88 Fix ios build 2024-03-15 12:12:53 +03:00
7adcec27ff Merge pull request #1439 from ONLYOFFICE/release/v8.1.0
Release/v8.1.0
2024-03-14 20:08:12 +03:00
a684336b72 Fix build 2024-03-14 20:06:20 +03:00
c3ef38b1e1 For bug 66933 2024-03-14 18:53:22 +03:00
94ceab0a03 Add multysheet xti using 2024-03-14 19:33:07 +06:00
8769924fe2 Merge pull request #1438 from ONLYOFFICE/fix/bug66721
Fix bug 66721
2024-03-14 16:06:30 +03:00
08ae2f5d2e Fix bug 66721 2024-03-14 15:37:38 +03:00
b436a70662 Merge pull request #1437 from ONLYOFFICE/fix/bug66537
Fix bug 66537
2024-03-14 12:43:05 +03:00
7d15bbc7c2 Fix build 2024-03-14 12:17:51 +03:00
00769d01c1 Fix bug 66537 2024-03-14 11:42:25 +03:00
3b1fa0a9bd Merge branch 'release/v8.1.0' of https://github.com/ONLYOFFICE/core into release/v8.1.0 2024-03-13 18:43:29 +03:00
1a676ace8b fix bug #66857 2024-03-13 18:43:13 +03:00
601ba0cedc Merge pull request #1436 from ONLYOFFICE/release/v8.1.0
Release/v8.1.0
2024-03-13 18:24:43 +03:00
261d8aad37 Merge pull request #1435 from ONLYOFFICE/hotfix/v8.0.1
Hotfix/v8.0.1
2024-03-13 18:21:50 +03:00
27ebebdd0e fix flags 2024-03-13 17:27:31 +03:00
0053b72656 Remove unused files 2024-03-13 17:13:25 +03:00
9832010dd7 Add xti reading while xml read 2024-03-13 19:22:40 +06:00
dfbb20035b Merge remote-tracking branch 'origin/feature/docx_renderer2' into feature/pdf-freetext
# Conflicts:
#	PdfFile/PdfReader.cpp
2024-03-13 13:11:58 +03:00
112dbd9e88 Fixes for build module 2024-03-13 12:18:59 +03:00
6995a5ef34 Fix endless formula conversion 2024-03-13 14:42:40 +06:00
e18edba2ba Merge pull request #1434 from ONLYOFFICE/fix/8.0.2
Fix/8.0.2
2024-03-13 11:12:36 +03:00
38ce36fa75 . 2024-03-13 11:11:58 +03:00
e518efc5e1 . 2024-03-13 11:10:31 +03:00
53677bf8cc Revert test changes 2024-03-13 11:04:55 +03:00
b065aff618 Fixes for android 2024-03-13 10:57:11 +03:00
a6370ec0a6 fix bug #66842 2024-03-13 10:37:33 +03:00
245ba212c4 fix bug #66849 2024-03-12 23:55:01 +03:00
48c1478374 fix bug #66840 2024-03-12 19:58:47 +03:00
65112e860e Fix query table conversion 2024-03-12 21:46:19 +06:00
4a22b26ac1 Fix connection conversion 2024-03-12 20:24:02 +06:00
e18883f126 Fix bugs in html to ooxml conversion 2024-03-12 14:54:08 +03:00
29a4119546 Fix inline string conversion 2024-03-12 15:04:00 +06:00
9ffc34b7e2 Developing DocxRenderer
- pptx shapes (in progress)
- no br logic
2024-03-12 11:51:47 +03:00
8a9e5ad267 Fix bugs in html to ooxml conversion 2024-03-12 10:46:05 +03:00
69a71d78ed [x2t] For bug 66819 2024-03-12 01:33:24 +03:00
db3d665f8c fix bug #66821 2024-03-11 19:27:53 +03:00
5c52489394 Fix function calling order 2024-03-11 18:04:37 +03:00
e8a4dab0ea Add office_drawing file to visual studio project 2024-03-11 18:40:48 +05:00
320dcf8a0f Add odg file format conversion 2024-03-11 18:25:03 +05:00
f10ad91f0f Merge remote-tracking branch 'origin/release/v8.1.0' into develop 2024-03-11 11:16:30 +03:00
1d594b93ea Merge remote-tracking branch 'origin/fix/xlsb_conv_errors' into release/v8.1.0 2024-03-11 11:15:00 +03:00
d68f4cedff Merge pull request #1433 from ONLYOFFICE/fix/bug27583
Fix bug 27583
2024-03-11 11:05:22 +03:00
c3571838ef Merge pull request #1432 from ONLYOFFICE/fix/bug66657
Fix bug #66657
2024-03-11 11:05:15 +03:00
76e05db9da Fix bug #66657 2024-03-11 13:54:41 +06:00
f93a628c24 Refactoring build 2024-03-10 21:58:34 +03:00
d81e70cfee fix bug #66798 2024-03-10 14:37:48 +03:00
26658a7189 fix bug #66796 2024-03-09 16:20:20 +03:00
e2ebe6a6d3 fix bug #66783 2024-03-07 16:39:55 +03:00
f9cd49a756 Fix bugs 2024-03-07 16:05:31 +03:00
e30c5fb79d fix bug #66777 2024-03-07 15:59:01 +03:00
57e06222c7 fix bug #66773 2024-03-07 15:52:13 +03:00
8bd978d2c6 Merge remote-tracking branch 'origin/fix/bug27583' into release/v8.1.0 2024-03-07 15:06:34 +03:00
04480bb9eb fix bug #66766 2024-03-06 20:06:43 +03:00
82cd32aa85 fix bug #66772 2024-03-06 19:38:20 +03:00
d92ab67b21 Fix validation 2024-03-06 16:20:28 +03:00
36dbd4f0e1 Refactoring 2024-03-06 15:55:12 +03:00
e787102046 Fix bug #27583 2024-03-06 18:47:52 +06:00
2445f6f2e3 Merge remote-tracking branch 'origin/release/v8.1.0' into develop 2024-03-06 15:38:39 +03:00
422f0736c4 Fix colot conversion 2024-03-06 17:45:57 +06:00
296383bd6f fix bug #66744 2024-03-06 12:05:45 +03:00
f6713d751b fix bug #66750 2024-03-06 11:41:39 +03:00
46fc80f423 fix bug #45218 2024-03-06 10:15:20 +03:00
b88d303ceb fix bug #66722 2024-03-04 19:43:28 +03:00
583f7b0d0c Create CFile.prototype["getShapes"] 2024-03-04 17:08:42 +03:00
86f288541f Merge branch 'release/v8.1.0' into fix/xlsb_conv_errors 2024-03-04 19:55:56 +06:00
9e24a89fd4 Fix bugs 2024-03-04 15:56:02 +03:00
f369715c55 Fix book view conversion 2024-03-04 18:12:00 +06:00
29852ddf25 Fix BeginShape to BeginMarkedContent 2024-03-04 10:31:02 +03:00
d88fc239b8 fix convert to xlsb 2024-03-02 15:42:11 +03:00
aad25c3da8 fix bug #66699 2024-03-02 15:22:30 +03:00
6bbf1190a7 Fix reference limits 2024-03-01 22:25:33 +06:00
3d1b8e64ac Fix shared formula conversion 2024-03-01 22:25:03 +06:00
e1ce2150dc Merge pull request #1431 from ONLYOFFICE/fix/bug66671
Fix bug 66671
2024-03-01 17:22:14 +03:00
1a86da3559 Fix bug #66670 2024-03-01 16:33:44 +03:00
1ff92a8e71 Fix def name conversion 2024-03-01 19:33:15 +06:00
00c95da6c0 Merge pull request #1430 from ONLYOFFICE/fix/66463
Fix bug #66463
2024-03-01 15:37:29 +03:00
bb1d5401d2 Refactoring 2024-03-01 15:24:09 +03:00
c9aad72ecc Fix bug 66671 2024-03-01 18:00:36 +06:00
e2dc625b0a Fix bugs and refactoring 2024-03-01 13:54:47 +03:00
c649de088a .
(cherry picked from commit bba6d180dc)
2024-03-01 13:29:13 +03:00
0476dedbac fix bug #66656 2024-02-29 21:54:50 +03:00
b71ed594da Add tests result 2024-02-29 20:03:36 +03:00
9c2e696710 Add words 2024-02-29 19:59:39 +03:00
f5ee86c94e Add tests for dictionaries 2024-02-29 19:44:28 +03:00
808782c1c8 Write BDC/EMC for MetaOForm 2024-02-29 17:34:37 +03:00
0dd978c000 Exist folder check: Add white list for some folders 2024-02-29 16:02:38 +03:00
bba6d180dc . 2024-02-29 15:54:56 +03:00
25ca9b5fcd meta in cell from/to bin 2024-02-29 12:24:02 +03:00
c7a1e3536d Meta from Cell 2024-02-29 12:02:26 +03:00
18e3ef0932 Merge remote-tracking branch 'origin/release/v8.1.0' into feature/pdf-shape 2024-02-29 11:37:43 +03:00
448156c905 Merge pull request #1429 from ONLYOFFICE/release/v8.1.0
Release/v8.1.0
2024-02-29 10:12:09 +03:00
db340198d6 Create GetShapesXML 2024-02-29 10:04:48 +03:00
7dd1dd3c8a Disable clear font streams in ScanPage mode 2024-02-28 22:33:07 +03:00
ec2687e5d1 for bug #57082 2024-02-28 21:29:46 +03:00
1ab06e503a Fix bug 2024-02-28 21:25:25 +03:00
f973a0a952 fix bug #66651 2024-02-28 21:13:35 +03:00
6a628a21fb Add 3dParty list 2024-02-28 17:08:44 +03:00
63c38399ad fix build 2024-02-28 14:50:08 +03:00
56c3b1a6d3 Fix bugs 2024-02-28 14:31:52 +03:00
163e21acf4 fix bug #53909 2024-02-27 17:56:13 +03:00
8ebd23defb UserProtectedRangeType 2024-02-27 17:17:35 +03:00
487c750020 Create CShapeStart::Read 2024-02-27 16:26:20 +03:00
4dc1751d89 Fix color conversion 2024-02-27 18:42:33 +06:00
fc3e6592f4 Fixes for support in js module 2024-02-27 15:00:33 +03:00
ed0d1fbdb0 Refactoring 2024-02-27 14:54:45 +03:00
849ad8ac87 Fixed bugs with styles in html->ooxml conversion and refactoring 2024-02-27 14:18:04 +03:00
9bb45aa05d fix bug #66622 2024-02-27 14:15:20 +03:00
306a61ba14 Fix NSFonts::IFontList::Add 2024-02-27 12:12:56 +03:00
a91500c4b7 Fix table conversion 2024-02-26 21:10:22 +06:00
88a6f5815c Add ScanPage 2024-02-26 17:29:21 +03:00
168aa04b8f Separate CAnnotMarkup::ReadRC 2024-02-26 17:27:37 +03:00
147d8ca783 for bug #66596 2024-02-26 16:14:04 +03:00
bb9e5c590a Create ctShapeStart and ctShapeEnd 2024-02-26 14:34:31 +03:00
7733825458 Fix compile 2024-02-26 11:56:48 +03:00
8ca63e5013 Merge branch hotfix/v8.0.1 into master 2024-02-26 07:33:51 +00:00
0c998e318b fix bug #34418 2024-02-24 12:10:57 +03:00
f8184532c8 Added support for reading @page and bug fixes in html to ooxml conversion 2024-02-22 18:10:26 +03:00
0927217246 Fix repeat font 2024-02-22 16:59:39 +03:00
0a1d3ddd91 Fix SetFont for FreeText annot 2024-02-22 15:03:28 +03:00
0bc356ebff fix bug #66057 2024-02-22 13:13:37 +03:00
620827ad53 . 2024-02-22 10:28:49 +03:00
c1025cf70b Merge remote-tracking branch 'origin/fix/xlsb_conversion' into release/v8.1.0 2024-02-22 10:27:33 +03:00
3320547735 Fix bug #66463 2024-02-21 22:41:35 +03:00
c1f1c3a683 add support oleObjects from Word 2003 XML 2024-02-21 20:45:07 +03:00
e8c375c864 Add FontSelection to FreeText 2024-02-21 18:54:58 +03:00
3d2ebf31b3 Fix sheet protection conversion 2024-02-21 14:32:01 +06:00
25be75004d Merge remote-tracking branch 'origin/hotfix/v8.0.1' into develop 2024-02-20 23:14:38 +03:00
cf90cd9e12 Merge pull request #1426 from ONLYOFFICE/fix/bug61241
fix bug #61241
2024-02-20 22:47:29 +03:00
690d17f6c4 fix bug #61241 2024-02-20 22:29:13 +03:00
ef0e18e1c9 Fix conditional formating refs conversion 2024-02-20 23:24:20 +06:00
001768d0c6 Try get by symbol 2024-02-20 19:58:30 +03:00
5cb6c32635 Merge pull request #1424 from ONLYOFFICE/feature/pdf-metaoform
Feature pdf metaoform
2024-02-20 16:21:16 +03:00
9c6c3e845b Merge remote-tracking branch 'origin/develop' into feature/docx_renderer2 2024-02-20 16:17:05 +03:00
f3bdeacf7e Fix bugs 2024-02-20 13:15:44 +03:00
7776743d8d Fix bug 66567 2024-02-19 22:15:10 +03:00
f672fcc665 oleObjects from ppt 2024-02-19 20:07:17 +03:00
b56e21d6c7 Improved padding in html to ooxml conversion 2024-02-19 18:33:31 +03:00
5326058947 Get fotn from AP 2024-02-19 18:06:42 +03:00
159ffec93b Merge pull request #1423 from ONLYOFFICE/fix/bug66562
Fix bug #66562
2024-02-19 17:37:53 +03:00
aba868b9ac Fix bug #66562 2024-02-19 18:25:05 +06:00
7d6a95d521 Fix bug 65583 2024-02-18 22:10:54 +03:00
8a6974a020 Add define to use default font to recalc 2024-02-17 14:57:38 +03:00
0ff68fcd8d Merge pull request #1422 from ONLYOFFICE/fix/bug66545 2024-02-17 10:42:05 +03:00
25fc759e61 Fix bug 66545 2024-02-17 10:18:10 +03:00
c90394b50a Update logic 2024-02-16 19:37:52 +03:00
6b74d80cd9 Merge branch 'develop' into fix/xlsb_conversion 2024-02-16 20:48:28 +06:00
ace094fc2a for bug #63610 2024-02-16 17:31:21 +03:00
56a09831cc Improved conversion of style settings of html tables to ooxml 2024-02-16 16:39:50 +03:00
8442596372 Fix conversion table formulas with empty square brackets 2024-02-16 15:58:57 +06:00
4ee1d59803 Fix default values setting up 2024-02-16 15:56:48 +06:00
77901663a0 Fix bug 66513 2024-02-16 12:50:59 +03:00
65a483461e Fix RC parser - span and #text 2024-02-16 11:57:58 +03:00
aa89e7fd4e Merge remote-tracking branch 'origin/hotfix/v8.0.1' into feature/pdf-metaoform 2024-02-16 10:48:22 +03:00
b7bc83f37d Create ValidMetaData 2024-02-16 10:47:08 +03:00
e11f145d30 Merge pull request #1420 from ONLYOFFICE/fix/bug66504
Fix bug 66504
2024-02-15 17:26:44 +03:00
5c69cb0358 Fix MemStream::setPos 2024-02-15 17:20:57 +03:00
2f4fee3555 Fix bug 66504 2024-02-15 16:35:27 +03:00
8eee4d470c Fix sparkline conversion 2024-02-15 19:29:51 +06:00
7710090d31 Merge pull request #1419 from ONLYOFFICE/fix/pdf-name
Fix T name due to Adobe
2024-02-15 16:16:16 +03:00
c7df1bc3ce Merge pull request #1418 from ONLYOFFICE/fix/bug66504
Fix bug 66504
2024-02-15 16:15:56 +03:00
7fdead0eda Fix T name due to Adobe 2024-02-15 16:13:33 +03:00
e78a4c84b4 Fix bug 66504 2024-02-15 15:50:36 +03:00
d1da32b922 add error style initialization check 2024-02-15 17:54:50 +06:00
ebc94a2615 Add new string removing from column names 2024-02-15 17:54:17 +06:00
b9a11bc30d Add ID with MetaOForm 2024-02-15 13:11:19 +03:00
95146474ff Fix comma processing 2024-02-14 16:15:37 +06:00
fa90923000 Fix table styles conversion 2024-02-14 16:03:53 +06:00
3d3daed655 Add table and column names to global info for formulas 2024-02-14 16:03:24 +06:00
c6b3238fa4 Fix dvals conversion 2024-02-14 16:02:06 +06:00
9a612d4543 Fix ptg list conversion 2024-02-14 16:01:11 +06:00
4736f93aa8 Fixed the unnecessary appearance of the table border in html to ooxml conversion 2024-02-13 18:10:17 +03:00
1eec0cffdb Update paragraph logic
in progress
2024-02-13 14:08:28 +03:00
d65cbf194a Added TextAssociationTypes 2024-02-13 10:21:49 +03:00
479943f5e2 Improved conversion of html tables to ooxml 2024-02-09 16:36:54 +03:00
80782f371c Fix pcdi conversion 2024-02-09 15:01:14 +06:00
c43536c618 Fix strings to shared strings conversion 2024-02-09 15:00:55 +06:00
835f4ba89d bug fixing 2024-02-09 11:20:24 +03:00
a7a80cb92e Fixed some inaccuracies in the conversion of html tables 2024-02-08 18:55:17 +03:00
593a7ba176 RC parser 2024-02-08 18:53:15 +03:00
0aa03275f4 Fix worbook defined names conversion 2024-02-08 19:27:33 +06:00
33058fbbce Fix worksheet parts conversion 2024-02-07 16:00:59 +06:00
127d70203c Fix worksheet writing sequence 2024-02-07 15:50:23 +06:00
ce2044a223 Fix default values for some structs 2024-02-07 14:42:40 +06:00
2160c86556 Fix underline xml reading 2024-02-07 14:39:57 +06:00
ae61dc5db9 Fix xml pattern fill writing 2024-02-07 14:39:30 +06:00
3e39bd8d13 Fix xf prop 2024-02-07 14:38:24 +06:00
92663a7ae3 Fix bug #62568 2024-02-06 17:37:12 +05:00
ee0ab7f042 Fix gradient path conversion 2024-02-06 17:36:36 +05:00
2e22646c34 Convert table templates 2024-02-06 17:36:06 +05:00
8a655f8600 deleting a file entry 2024-02-06 11:17:47 +03:00
7e5da0b22c Fix bug #63701 2024-02-06 10:38:49 +03:00
0d1e5198c4 Converting lim families with upper and lower indexes. Converting csub and csup. Bug fixing.Code refactoring. 2024-02-05 21:01:58 +03:00
b36c1ae9e7 Fix bug #59451 2024-02-05 18:05:55 +03:00
84f58b7b08 Add row col initialization check 2024-02-05 15:41:14 +06:00
aa8a0cfbc2 FIx array formula conversion 2024-02-02 23:18:05 +06:00
00671ffdd6 Fix shared formulas conversion 2024-02-02 14:47:45 +06:00
ba6267570b Merge pull request #1405 from ONLYOFFICE/feature/StarMathToOOXML
StarMathToOoxml
2024-02-01 16:59:47 +03:00
d4f4f4d500 Fix whitespace showing in worksheet 2024-01-30 15:00:13 +06:00
efbb6f38a0 Fix cell protection 2024-01-29 20:05:20 +06:00
71fc5323c7 Fix formula value conversion 2024-01-29 15:04:34 +06:00
7d3940a382 Fix area ptg conversion 2024-01-29 15:04:03 +06:00
3fbbf754a2 Fixed a bug in reading a function without an element. Adding a base attribute read. Code refactoring. 2024-01-26 12:22:13 +03:00
afdc28dbe4 Fix page setup 2024-01-25 18:44:32 +06:00
bccdeedc4e Fix cell refs conversion 2024-01-25 15:55:14 +06:00
9947e80e6c Fix XLUnicodeString_T operator= 2024-01-24 17:50:21 +06:00
8a03329e15 Merge remote-tracking branch 'origin/fix/bug65838' into feature/odf 2024-01-24 13:59:06 +03:00
0ac9b0bee8 Merge branch 'develop' into fix/xlsb_conversion 2024-01-24 16:42:57 +06:00
71afe4a0d5 Add relative reference saving 2024-01-24 16:41:41 +06:00
5b6735e3bf Fix formula conversion 2024-01-24 15:36:14 +06:00
755ea7761c Conversion of Greek characters, universal input of functions and operators. Writing tests. 2024-01-24 10:36:31 +03:00
6537a1998a add starmath convert 2024-01-23 19:36:48 +03:00
0be57e7316 Merge remote-tracking branch 'origin/feature/StarMathToOOXML' into feature/odf 2024-01-23 18:36:00 +03:00
d1a35c2e9c Refactoring in HtmlFile2 2024-01-22 18:39:00 +03:00
0bbd2d6d35 Fix xfs conversion 2024-01-18 20:03:38 +06:00
ec89b34514 editing diacritics, unary marks. bug fixing. 2024-01-18 13:05:41 +03:00
6e0a28f8c8 Fix merged cellc conversion 2024-01-17 22:02:15 +06:00
7d82d4a8b7 Fix conditional formating conversion 2024-01-17 22:01:51 +06:00
fb27d00490 Fix hyperlinks conversion 2024-01-15 15:49:20 +06:00
01ac03f24b Fix comment convert condition 2024-01-15 13:44:52 +06:00
fe2779824b Fix comment conversion error 2024-01-12 21:37:42 +06:00
7af7b50f66 Fix autofilter conversion 2024-01-12 20:12:33 +06:00
508167f0f9 Fix conditional formating conversion 2024-01-11 18:08:00 +06:00
1017b30776 Add numeric value cache for cell value 2024-01-10 14:14:09 +06:00
54ec885316 Fix cell value parsing 2024-01-09 20:21:40 +06:00
3cf686e08e Merge branch 'develop' into fix/xlsb_conversion 2024-01-09 18:19:32 +06:00
83a053a1dd Fix numbers conversion 2024-01-09 18:15:15 +06:00
1f92b15aae Fix blank cell conversion 2023-12-29 19:05:03 +06:00
9b06b9e7a8 Remove unused code 2023-12-29 19:04:40 +06:00
189269031a Fix shared string conversion 2023-12-29 17:49:12 +06:00
6f5fa6c4ca Switching to case-insensitive search in html2 2023-12-26 20:31:04 +03:00
bc6e7e2831 Refinement of attributes. Code refactoring. Editing logic. 2023-12-22 17:17:18 +03:00
35eb2849ef Adding conversion of indexed brackets, diacritics and attributes. Editing operator conversion. 2023-12-15 17:55:00 +03:00
50cb0b543e Fix indent 2023-12-11 22:41:01 +03:00
c196f282af Bugfix BuildParagraphes 2023-12-11 05:25:02 +03:00
bea162aef9 BuildParagraphes update
(in progress)
2023-12-11 00:25:17 +03:00
5533ac8a59 Adding conversion of brackets, matrices, scores and indexes. Tests. 2023-12-01 16:27:26 +03:00
fd95d72a08 Update ascent/descent
values in objects
crossing using ascent/descent
2023-11-26 01:17:33 +03:00
f9b4f8402b added conversion of operations on sets and connections. tests added 2023-11-17 12:04:13 +03:00
3a17ce21ef Reworking of the CElementOperator class, reworking of some part of the conversion, tests 2023-11-08 17:24:09 +03:00
e5a4ea21b0 Fix move 2023-11-06 17:19:48 +03:00
07b33be69a Fix bug
- shared -> wear ptrs
- fix bug with sort
2023-11-06 15:49:29 +03:00
21d8353cdc Fix bug with highlighting 2023-11-03 13:00:11 +03:00
29e44fb12c Refactoring
- tables romoved (for now)
- paragraph logic is broken (fix soon)
2023-11-03 12:22:14 +03:00
91fad82d6a Refactoring
in progress
2023-11-02 23:10:29 +03:00
8b9d5c9f51 Refactoring (still in porgress) 2023-11-02 18:34:45 +03:00
83e37ba5f0 Refactoring (in progress) 2023-11-02 14:12:58 +03:00
6374e3ba23 Refactoring 2023-10-31 17:17:17 +03:00
5b0516e398 Architecture refinement (adding connections, functions and operators) 2023-10-27 17:23:25 +03:00
eec0075e54 Сhange of architecture 2023-10-13 18:18:06 +03:00
dd0ede1405 Remove nodiscard 2023-10-04 19:20:42 +03:00
7ed274c3e9 Fix lines below text & size of super/sub script 2023-10-02 17:00:34 +03:00
417267a963 adding parsing of structures such as matrices, indexes 2023-09-25 16:12:50 +03:00
7a198ac6db Fix paragpraph logic
finally
2023-09-25 14:29:33 +03:00
35fbf84683 Change logic 2023-09-14 15:17:15 +03:00
e72afe11d3 Adding tests 2023-09-11 18:14:38 +03:00
0c55adc82a Conversion development 2023-09-10 15:19:45 +03:00
9e009cc0f8 Revision of reading brackets. Conversion development. 2023-09-02 10:11:57 +03:00
7dc8a4bb9b Fix bug
dropcaps fix
2023-09-01 18:52:29 +03:00
e11e314b22 Update drop caps
drop caps is shapes now
2023-08-29 22:51:37 +03:00
5ac9df5d89 Improvement of functionality (brackets, scalable brackets, attributes) 2023-08-25 18:28:53 +03:00
aa9ff37320 Development of algorithms 2023-08-18 19:44:42 +03:00
6aae88e521 Merge branch 'release/v7.5.0' into feature/docx_renderer2 2023-08-17 11:09:18 +03:00
7197545541 Started development of StarMath string parser 2023-08-11 17:38:50 +03:00
2968e8e303 Add DropCaps support
commented for now
2023-08-10 21:23:33 +03:00
bc5ab2719c Remove unused files 2023-08-10 14:37:30 +03:00
4ebbfad654 Fix spacing in different cconts 2023-08-08 12:05:01 +03:00
6afb01da00 ParagraphStyle Fix 2023-08-08 10:06:13 +03:00
7118da40a2 Fix bug
reload fonts
2023-07-28 11:36:33 +03:00
a65183616f Fix check files in test 2023-07-17 10:40:12 +03:00
03335551b6 Clear fonts cache & font streams on each convertaion 2023-07-17 10:35:47 +03:00
781338fb1e Sets Gid to 0 2023-07-14 18:17:22 +03:00
c4fe64423c Calc width in selected font 2023-07-12 17:19:43 +03:00
0c6a72df99 Fix bug with left sort
+ Changed consts space width
2023-07-12 13:31:35 +03:00
b0721b2c16 Rename param for x2t & remove src dependency for library (paragraph) 2023-07-09 21:35:44 +03:00
9602c52fae Merge branch 'develop' into feature/docx_renderer2 2023-07-09 21:19:50 +03:00
dac999e9e6 Clearing cache after document, not page
more optimization
no error if convert wasnt called
2023-07-07 13:48:58 +03:00
1b155518c2 Less comparsions 2023-07-02 19:18:16 +03:00
e2a3e82770 Fix bug
iterator exeption
2023-07-02 18:31:27 +03:00
e42f3031f8 Add caching fontstyle
like in fontmanager
2023-07-02 18:19:07 +03:00
f5d972573e Fix bug (tabulation)
\t symbol skipped and addded during analysis
2023-06-27 10:44:25 +03:00
8669470692 Fix bug 2023-06-23 17:15:42 +03:00
0b46254fed Fix rescale pen bug 2023-06-23 17:09:54 +03:00
25db8ee837 Fix bug 2023-05-21 15:22:31 +03:00
e626d013a8 Fix bug 2023-05-21 15:13:37 +03:00
66d846dcfc Fix bug 2023-05-19 01:26:33 +03:00
c012741f7f Fix memory leaks
Finally
2023-05-19 00:29:22 +03:00
ad3a23a708 Fix bug 2023-05-11 15:23:22 +03:00
41c351b72d Fix memory leaks 2023-05-10 13:10:29 +03:00
bac28708c1 Fix bug 2023-05-10 12:36:10 +03:00
3bb66721a1 Fix bug 2023-05-02 18:57:40 +03:00
cf85c54f43 Fix font selection 2023-04-28 00:52:58 +03:00
dcddfd15b5 Merge pull request #1168 from ONLYOFFICE/release/v7.4.0
Release/v7.4.0
2023-04-27 02:13:48 +05:00
265e9d8af8 Fix bug 2023-04-25 03:37:21 +03:00
acb9af928f Add paragraph styles 2023-04-18 22:05:29 +03:00
9a0d42b957 Update shape merging 2023-04-10 19:11:42 +03:00
531fae1486 FontStyles refactoring 2023-04-10 18:41:44 +03:00
fb22675e69 Fix bug
or not
2023-04-08 17:09:47 +03:00
49f9c96570 Refactoring 2023-04-02 10:15:43 +03:00
c3bd31a38e Add optimization 2023-04-02 05:27:15 +03:00
c69da0df04 Add path merging 2023-04-02 04:39:08 +03:00
69cbba7b2b Refactoring 2023-03-21 01:35:08 +03:00
caea7fbe2f Fix bug + refactoring 2023-03-21 01:27:58 +03:00
4007b826bf Refactoring 2023-03-20 03:44:36 +03:00
39c19db22a Refactoring (faster) 2023-03-20 02:55:43 +03:00
bacbfbf221 Fix bug 2023-03-20 02:51:15 +03:00
9cc07e916b Refactoring 2023-03-20 02:21:04 +03:00
8de7d01012 Add FontSelector (Refactoring) 2023-03-19 18:45:10 +03:00
21544a7ff7 Refactoring 2023-03-14 19:02:58 +03:00
2ab9f06493 Refactoring 2023-03-14 18:10:33 +03:00
118783c716 Fix bug 2023-03-05 13:27:15 +03:00
0d06216215 Refactoring 2023-03-05 13:06:18 +03:00
66050307ce Refactoring
CStyleManager* in conttext is useless
2023-03-02 16:48:47 +03:00
53bbeb0cdc Refactoring + VectrosGraphics update 2023-02-27 15:46:54 +03:00
623e664478 indents update
tabs instead of spaces
2023-02-19 12:37:53 +03:00
5cac25286d Refactoring 2023-02-19 12:27:08 +03:00
74c4bf6236 Fix docx_renderer test build 2023-01-19 14:02:27 +03:00
6f1018aa50 Merge pull request #1115 from ONLYOFFICE/develop
develop -> docx_renderer2
2023-01-19 13:38:23 +03:00
0a1e90958c Added base classes for table decoding.
Added a Converter class for use in various objects.
Added additional comments to the code.
Added tasks under the //todo label.
2022-10-20 14:00:12 +03:00
742ed66df1 Refactoring. Optimized operating logic. Conversion time is reduced. 2022-10-14 15:06:40 +03:00
9c0b3b33c4 Merge pull request #1046 from ONLYOFFICE/hotfix/v7.2.1
Hotfix/v7.2.1
2022-10-02 21:54:35 +03:00
e35a27e9dc Added recognition of Diacritical Symbols.
Paragraphs are allocated to shapes based on the distance between them.
2022-09-26 13:38:52 +03:00
cc69b4b830 All paragraphs on one page add to general text shape now. 2022-09-26 13:38:52 +03:00
35cc9e4f20 Added new TextAssociationType - tatParagraphToShape.
Added changes to logic of determing paragraphs.
Some fixes 6.
2022-09-26 13:38:51 +03:00
7a276227d3 Modified the packing of lines by paragraphs and the definition of the type of paragraph alignment. 2022-09-26 13:38:51 +03:00
791be217af Fix problem with determine of font name. 2022-09-26 13:38:51 +03:00
1475 changed files with 80576 additions and 60347 deletions

2
.gitignore vendored
View File

@ -46,3 +46,5 @@ DesktopEditor/fontengine/js/common/freetype-2.10.4
.qtc_clangd
Common/3dParty/openssl/openssl/
msvc_make.bat

18
3DPARTY.md Normal file
View File

@ -0,0 +1,18 @@
## Third-party
- boost ([BSL](https://raw.githubusercontent.com/boostorg/boost/master/LICENSE_1_0.txt))
- icu ([UNICODE LICENSE V3](https://raw.githubusercontent.com/unicode-org/icu/main/LICENSE))
- freetype ([FTL](https://raw.githubusercontent.com/freetype/freetype/master/docs/FTL.TXT))
- harfbuzz ([MIT](https://raw.githubusercontent.com/harfbuzz/harfbuzz/main/COPYING))
- hyphen ([MPL](https://raw.githubusercontent.com/hunspell/hyphen/master/COPYING))
- hunspell ([MPL](https://raw.githubusercontent.com/hunspell/hunspell/master/COPYING.MPL))
- gumbo ([Apache-2.0](https://raw.githubusercontent.com/google/gumbo-parser/master/COPYING))
- katana ([MIT](https://raw.githubusercontent.com/jasenhuang/katana-parser/master/LICENSE))
- cximage ([CXIMAGE LICENCE](https://raw.githubusercontent.com/movableink/cximage/master/license.txt))
- openjpeg ([2-clause BSD License](https://raw.githubusercontent.com/uclouvain/openjpeg/master/LICENSE))
- socket.io-client-cpp ([MIT](https://raw.githubusercontent.com/socketio/socket.io-client-cpp/master/LICENSE))
- curl ([CURL LICENCE](https://raw.githubusercontent.com/curl/curl/master/COPYING))
- cryptopp ([BSL](https://raw.githubusercontent.com/weidai11/cryptopp/master/License.txt))
- openssl ([Apache-2.0](https://raw.githubusercontent.com/openssl/openssl/master/LICENSE.txt))
- v8 ([3-clause BSD License](https://raw.githubusercontent.com/v8/v8/main/LICENSE))

View File

@ -1,9 +1,20 @@
INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include
CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
core_ios:CONFIG += disable_enum_constexpr_conversion
core_android:CONFIG += disable_enum_constexpr_conversion
core_mac:CONFIG += disable_enum_constexpr_conversion
core_android {
INCLUDEPATH += $$PWD/build/android/include
CORE_BOOST_LIBS = $$PWD/build/android/lib/$$CORE_BUILDS_PLATFORM_PREFIX
DEFINES += "_HAS_AUTO_PTR_ETC=0"
}
disable_enum_constexpr_conversion {
QMAKE_CFLAGS += -Wno-enum-constexpr-conversion
QMAKE_CXXFLAGS += -Wno-enum-constexpr-conversion
}
bundle_xcframeworks {

View File

@ -1,326 +0,0 @@
#!/bin/bash
cd boost_1_72_0
OUTPUT_DIR="../build/android"
BOOST_LIBS="filesystem system date_time regex"
CPPSTD="-std=c++11 -frtti -fexceptions"
# Must set these after parseArgs to fill in overriden values
# Todo: -g -DNDEBUG are for debug builds only...
# Boost.test defines are needed to build correct instrumentable boost_unit_test_framework static lib
# it does not affect the functionality of <boost/test/included/unit_test.hpp> single-header usage.
# See http://www.boost.org/doc/libs/1_66_0/libs/test/doc/html/boost_test/adv_scenarios/static_lib_customizations/entry_point.html
EXTRA_FLAGS="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS \
-DBOOST_TEST_NO_MAIN -DBOOST_TEST_ALTERNATIVE_INIT_API -DANDROID_STL=c++_static \
-Wno-unused-local-typedef"
EXTRA_ANDROID_FLAGS="$EXTRA_FLAGS"
if [[ -n "$USE_CXX11_ABI" ]]; then
EXTRA_LINUX_FLAGS="$EXTRA_FLAGS -D_GLIBCXX_USE_CXX11_ABI=$USE_CXX11_ABI"
else
EXTRA_LINUX_FLAGS="$EXTRA_FLAGS"
fi
doneSection()
{
echo
echo "Done"
echo "================================================================="
echo
}
bootstrapBoost()
{
BOOTSTRAP_LIBS=$BOOST_LIBS
BOOST_LIBS_COMMA=$(echo $BOOTSTRAP_LIBS | sed -e "s/ /,/g")
echo "Bootstrapping for $1 (with libs $BOOST_LIBS_COMMA)"
./bootstrap.sh --with-libraries=$BOOST_LIBS_COMMA
doneSection
}
generateAndroidUserConfig()
{
HOSTOS="$(uname | awk '{ print $1}' | tr [:upper:] [:lower:])-" # darwin or linux
OSARCH="$(uname -m)"
# Boost doesn't build with <compileflags>-Werror
# Reported to boost-users@lists.boost.org
cat > "./tools/build/src/user-config.jam" <<EOF
using clang : 5.0~x86
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
:
<architecture>x86 <target-os>android
<compileflags>--target=i686-none-linux-android
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/x86-4.9/prebuilt/$HOSTOS$OSARCH
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/i686-linux-android
<compileflags>-DANDROID
<compileflags>-D__ANDROID_API__=19
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-fno-limit-debug-info
<compileflags>-fPIC
<compileflags>-no-canonical-prefixes
<compileflags>-mstackrealign
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-Wall
<compileflags>-Wshadow
;
using clang : 5.0~x86_64
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
:
<architecture>x86 <target-os>android
<compileflags>--target=x86_64-none-linux-android
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/x86_64-4.9/prebuilt/$HOSTOS$OSARCH
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/x86_64-linux-android
<compileflags>-DANDROID
<compileflags>-D__ANDROID_API__=21
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-fno-limit-debug-info
<compileflags>-fPIC
<compileflags>-no-canonical-prefixes
<compileflags>-mstackrealign
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-Wall
<compileflags>-Wshadow
;
using clang : 5.0~arm
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
:
<architecture>arm <target-os>android
<compileflags>--target=armv7-none-linux-androideabi
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/$HOSTOS$OSARCH
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/arm-linux-androideabi
<compileflags>-DANDROID
<compileflags>-D__ANDROID_API__=19
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-fno-limit-debug-info
<compileflags>-fPIC
<compileflags>-fno-integrated-as
<compileflags>-no-canonical-prefixes
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-Wall
<compileflags>-Wshadow
<compileflags>-march=armv7-a
<compileflags>-mfloat-abi=softfp
<compileflags>-mfpu=vfpv3-d16
<compileflags>-mthumb
;
using clang : 5.0~arm64
: $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$HOSTOS$OSARCH/bin/clang++ $EXTRA_ANDROID_FLAGS
:
<architecture>arm <target-os>android
<compileflags>--target=aarch64-none-linux-android
<compileflags>--gcc-toolchain=$ANDROID_NDK_ROOT/toolchains/aarch64-linux-android-4.9/prebuilt/$HOSTOS$OSARCH
<compileflags>--sysroot=$ANDROID_NDK_ROOT/sysroot
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sources/android/support/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include
<compileflags>-isystem <compileflags>$ANDROID_NDK_ROOT/sysroot/usr/include/aarch64-linux-android
<compileflags>-DANDROID
<compileflags>-D__ANDROID_API__=21
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-fno-limit-debug-info
<compileflags>-fPIC
<compileflags>-no-canonical-prefixes
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-Wall
<compileflags>-Wshadow
;
EOF
}
buildBoost_Android()
{
mkdir -p $OUTPUT_DIR
echo > ${OUTPUT_DIR}/android-build.log
if [[ -z "$ANDROID_NDK_ROOT" ]]; then
echo "Must specify ANDROID_NDK_ROOT"
exit 1
fi
export NO_BZIP2=1
# build libicu if locale requested but not provided
# if echo $LIBRARIES | grep locale; then
# if [ -e libiconv-libicu-android ]; then
# echo "ICONV and ICU already compiled"
# else
# echo "boost_locale selected - compiling ICONV and ICU"
# git clone https://github.com/pelya/libiconv-libicu-android.git
# cd libiconv-libicu-android
# ./build.sh || exit 1
# cd ..
# fi
# fi
echo clean
./b2 --clean
echo Building release x86 Boost for Android Emulator
./b2 --build-dir=android-build --stagedir=android-build/stage \
--prefix="$OUTPUT_DIR" \
--libdir="$OUTPUT_DIR/lib/x86" toolset=clang-5.0~x86 \
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
optimization=speed \
address-model=32 variant=release cxxflags="${CPPSTD}" \
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
doneSection
echo Building release x86_64 Boost for Android Emulator
./b2 --build-dir=android-build --stagedir=android-build/stage \
--prefix="$OUTPUT_DIR" \
--libdir="$OUTPUT_DIR/lib/x86_64" toolset=clang-5.0~x86_64 \
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
optimization=speed \
address-model=64 variant=release cxxflags="${CPPSTD}" \
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
doneSection
echo Building release armv7 Boost for Android
./b2 --build-dir=android-build --stagedir=android-build/stage \
--prefix="$OUTPUT_DIR" \
--libdir="$OUTPUT_DIR/lib/armeabi-v7a" toolset=clang-5.0~arm \
abi=aapcs architecture=arm address-model=32 binary-format=elf threading=multi \
optimization=space \
target-os=android variant=release cxxflags="${CPPSTD}" \
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
doneSection
echo Building release arm64 Boost for Android
./b2 --build-dir=android-build --stagedir=android-build/stage \
--prefix="$OUTPUT_DIR" \
--libdir="$OUTPUT_DIR/lib/arm64-v8a" toolset=clang-5.0~arm64 \
abi=aapcs architecture=arm address-model=64 binary-format=elf threading=multi \
optimization=space \
target-os=android variant=release cxxflags="${CPPSTD}" \
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
doneSection
}
buildBoost_Android_debug()
{
mkdir -p $OUTPUT_DIR
echo > ${OUTPUT_DIR}/android-build.log
export NO_BZIP2=1
# build libicu if locale requested but not provided
# if echo $LIBRARIES | grep locale; then
# if [ -e libiconv-libicu-android ]; then
# echo "ICONV and ICU already compiled"
# else
# echo "boost_locale selected - compiling ICONV and ICU"
# git clone https://github.com/pelya/libiconv-libicu-android.git
# cd libiconv-libicu-android
# ./build.sh || exit 1
# cd ..
# fi
# fi
echo Building debug x86 Boost for Android Emulator
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
--prefix="$OUTPUT_DIR" \
--libdir="$OUTPUT_DIR/lib/debug/x86" toolset=clang-5.0~x86 \
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
optimization=speed \
address-model=32 variant=debug cxxflags="${CPPSTD}" \
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
doneSection
echo Building debug x86_64 Boost for Android Emulator
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
--prefix="$OUTPUT_DIR" \
--libdir="$OUTPUT_DIR/lib/debug/x86_64" toolset=clang-5.0~x86_64 \
architecture=x86 target-os=android define=_LITTLE_ENDIAN \
optimization=speed \
address-model=64 variant=debug cxxflags="${CPPSTD}" \
link=static threading=multi install >> "${OUTPUT_DIR}/android-build.log" 2>&1
if [ $? != 0 ]; then echo "Error staging Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
doneSection
echo Building debug armv7 Boost for Android
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
--prefix="$OUTPUT_DIR" \
--libdir="$OUTPUT_DIR/lib/debug/armeabi-v7a" toolset=clang-5.0~arm \
abi=aapcs architecture=arm address-model=32 binary-format=elf threading=multi \
optimization=space \
target-os=android variant=debug cxxflags="${CPPSTD}" \
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
doneSection
echo Building debug arm64 Boost for Android
./b2 $THREADS --build-dir=android-build --stagedir=android-build/stage \
--prefix="$OUTPUT_DIR" \
--libdir="$OUTPUT_DIR/lib/debug/arm64-v8a" toolset=clang-5.0~arm64 \
abi=aapcs architecture=arm address-model=64 binary-format=elf threading=multi \
optimization=space \
target-os=android variant=debug cxxflags="${CPPSTD}" \
link=static install >> "${OUTPUT_DIR}/android-build.log" 2>&1
if [ $? != 0 ]; then echo "Error installing Android. Check ${OUTPUT_DIR}/android-build.log"; exit 1; fi
doneSection
}
bootstrapBoost
generateAndroidUserConfig
buildBoost_Android
#buildBoost_Android_debug
echo "Completed successfully"

View File

@ -27,7 +27,7 @@ CLEAN=
BOOST_VERSION=1.72.0
BOOST_VERSION2=1_72_0
MIN_IOS_VERSION=8.0
IOS_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="YES" OTHER_CFLAGS="-fembed-bitcode" -showsdks | grep iphoneos | \
IOS_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="NO" -showsdks | grep iphoneos | \
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`
OSX_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="YES" OTHER_CFLAGS="-fembed-bitcode" -showsdks | grep macosx | \
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`
@ -42,7 +42,7 @@ XCODE_ROOT=`xcode-select -print-path`
#
# Should perhaps also consider/use instead: -BOOST_SP_USE_PTHREADS
EXTRA_CPPFLAGS="-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -g -DNDEBUG \
-std=c++11 -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden -fembed-bitcode"
-std=c++11 -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden"
EXTRA_IOS_CPPFLAGS="$EXTRA_CPPFLAGS -mios-version-min=$MIN_IOS_VERSION"
EXTRA_OSX_CPPFLAGS="$EXTRA_CPPFLAGS"
@ -259,20 +259,17 @@ buildBoost()
echo Building Boost for iPhone
# Install this one so we can copy the headers for the frameworks...
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
cxxflags="-fembed-bitcode" \
--prefix=$PREFIXDIR toolset=darwin architecture=arm target-os=iphone \
macosx-version=iphone-${IOS_SDK_VERSION} define=_LITTLE_ENDIAN \
link=static stage
./b2 -j16 --build-dir=iphone-build --stagedir=iphone-build/stage \
--prefix=$PREFIXDIR toolset=darwin architecture=arm \
cxxflags="-fembed-bitcode" \
target-os=iphone macosx-version=iphone-${IOS_SDK_VERSION} \
define=_LITTLE_ENDIAN link=static install
doneSection
echo Building Boost for iPhoneSimulator
./b2 -j16 --build-dir=iphonesim-build --stagedir=iphonesim-build/stage \
cxxflags="-fembed-bitcode" \
toolset=darwin-${IOS_SDK_VERSION}~iphonesim architecture=x86 \
target-os=iphone macosx-version=iphonesim-${IOS_SDK_VERSION} \
link=static stage

View File

@ -1,220 +0,0 @@
#!/bin/bash
#
# Copyright 2016 leenjewel
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source ./build-common.sh
export PLATFORM_TYPE="Android"
export ARCHS=("arm" "arm64" "x86" "x86_64")
export ABIS=("armeabi-v7a" "arm64-v8a" "x86" "x86_64")
export ABI_TRIPLES=("arm-linux-androideabi" "aarch64-linux-android" "i686-linux-android" "x86_64-linux-android")
export ANDROID_API=21
# for test
# export ARCHS=("x86_64")
# export ABIS=("x86_64")
# export ABI_TRIPLES=("x86_64-linux-android")
if [[ -z ${ANDROID_NDK_ROOT} ]]; then
echo "ANDROID_NDK_ROOT not defined"
exit 1
fi
function get_toolchain() {
HOST_OS=$(uname -s)
case ${HOST_OS} in
Darwin) HOST_OS=darwin ;;
Linux) HOST_OS=linux ;;
FreeBsd) HOST_OS=freebsd ;;
CYGWIN* | *_NT-*) HOST_OS=cygwin ;;
esac
HOST_ARCH=$(uname -m)
case ${HOST_ARCH} in
i?86) HOST_ARCH=x86 ;;
x86_64 | amd64) HOST_ARCH=x86_64 ;;
esac
echo "${HOST_OS}-${HOST_ARCH}"
}
function get_android_arch() {
local common_arch=$1
case ${common_arch} in
arm)
echo "arm-v7a"
;;
arm64)
echo "arm64-v8a"
;;
x86)
echo "x86"
;;
x86_64)
echo "x86-64"
;;
esac
}
function get_target_build() {
local arch=$1
case ${arch} in
arm-v7a)
echo "arm"
;;
arm64-v8a)
echo "arm64"
;;
x86)
echo "x86"
;;
x86-64)
echo "x86_64"
;;
esac
}
function get_build_host_internal() {
local arch=$1
case ${arch} in
arm-v7a | arm-v7a-neon)
echo "arm-linux-androideabi"
;;
arm64-v8a)
echo "aarch64-linux-android"
;;
x86)
echo "i686-linux-android"
;;
x86-64)
echo "x86_64-linux-android"
;;
esac
}
function android_get_build_host() {
local arch=$(get_android_arch $1)
get_build_host_internal $arch
}
function get_clang_target_host() {
local arch=$1
local api=$2
case ${arch} in
arm-v7a | arm-v7a-neon)
echo "armv7a-linux-androideabi${api}"
;;
arm64-v8a)
echo "aarch64-linux-android${api}"
;;
x86)
echo "i686-linux-android${api}"
;;
x86-64)
echo "x86_64-linux-android${api}"
;;
esac
}
function set_android_toolchain_bin() {
export PATH=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/$(get_toolchain)/bin:$PATH
echo PATH=$PATH
}
function set_android_toolchain() {
local name=$1
local arch=$(get_android_arch $2)
local api=$3
local build_host=$(get_build_host_internal "$arch")
local clang_target_host=$(get_clang_target_host "$arch" "$api")
export AR=${build_host}-ar
export CC=${clang_target_host}-clang
export CXX=${clang_target_host}-clang++
export AS=${build_host}-as
export LD=${build_host}-ld
export RANLIB=${build_host}-ranlib
export STRIP=${build_host}-strip
}
function get_common_includes() {
local toolchain=$(get_toolchain)
echo "-I${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/include -I${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/local/include"
}
function get_common_linked_libraries() {
local api=$1
local arch=$2
local toolchain=$(get_toolchain)
local build_host=$(get_build_host_internal "$arch")
echo "-L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/${build_host}/lib -L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/sysroot/usr/lib/${build_host}/${api} -L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${toolchain}/lib"
}
function set_android_cpu_feature() {
local name=$1
local arch=$(get_android_arch $2)
local api=$3
case ${arch} in
arm-v7a | arm-v7a-neon)
export CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
export LDFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
export CPPFLAGS=${CFLAGS}
;;
arm64-v8a)
export CFLAGS="-march=armv8-a -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
export LDFLAGS="-march=armv8-a -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
export CPPFLAGS=${CFLAGS}
;;
x86)
export CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
export LDFLAGS="-march=i686 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
export CPPFLAGS=${CFLAGS}
;;
x86-64)
export CFLAGS="-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -Wno-unused-function -fno-integrated-as -fstrict-aliasing -fPIC -DANDROID -D__ANDROID_API__=${api} -Os -ffunction-sections -fdata-sections $(get_common_includes)"
export CXXFLAGS="-std=c++11 -Os -ffunction-sections -fdata-sections"
export LDFLAGS="-march=x86-64 -Wl,--gc-sections -Os -ffunction-sections -fdata-sections $(get_common_linked_libraries ${api} ${arch})"
export CPPFLAGS=${CFLAGS}
;;
esac
}
function android_printf_global_params() {
local arch=$1
local abi=$2
local abi_triple=$3
local in_dir=$4
local out_dir=$5
echo -e "arch = $arch"
echo -e "abi = $abi"
echo -e "abi_triple = $abi_triple"
echo -e "PLATFORM_TYPE = $PLATFORM_TYPE"
echo -e "ANDROID_API = $ANDROID_API"
echo -e "in_dir = $in_dir"
echo -e "out_dir = $out_dir"
echo -e "AR = $AR"
echo -e "CC = $CC"
echo -e "CXX = $CXX"
echo -e "AS = $AS"
echo -e "LD = $LD"
echo -e "RANLIB = $RANLIB"
echo -e "STRIP = $STRIP"
echo -e "CFLAGS = $CFLAGS"
echo -e "CXXFLAGS = $CXXFLAGS"
echo -e "LDFLAGS = $LDFLAGS"
echo -e "CPPFLAGS = $CPPFLAGS"
}

View File

@ -1,128 +0,0 @@
#!/bin/bash
#
# Copyright 2016 leenjewel
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# # read -n1 -p "Press any key to continue..."
set -u
source ./build-android-common.sh
init_log_color
TOOLS_ROOT=$(pwd)
SOURCE="$0"
while [ -h "$SOURCE" ]; do
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
pwd_path="$(cd -P "$(dirname "$SOURCE")" && pwd)"
echo pwd_path=${pwd_path}
echo TOOLS_ROOT=${TOOLS_ROOT}
LIB_VERSION="curl-7_68_0"
LIB_NAME="curl-7.68.0"
LIB_DEST_DIR="${pwd_path}/build/android/curl-universal"
echo "https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz"
# https://curl.haxx.se/download/${LIB_NAME}.tar.gz
# https://github.com/curl/curl/releases/download/curl-7_69_0/curl-7.69.0.tar.gz
# https://github.com/curl/curl/releases/download/curl-7_68_0/curl-7.68.0.tar.gz
rm -rf "${LIB_DEST_DIR}" "${LIB_NAME}"
[ -f "${LIB_NAME}.tar.gz" ] || curl -L -o ${LIB_NAME}.tar.gz https://github.com/curl/curl/releases/download/${LIB_VERSION}/${LIB_NAME}.tar.gz -s
[ -f "${LIB_NAME}.tar.gz" ] || log_error "curl download error!"
set_android_toolchain_bin
function configure_make() {
ARCH=$1
ABI=$2
ABI_TRIPLE=$3
log_info "configure $ABI start..."
if [ -d "${LIB_NAME}" ]; then
rm -fr "${LIB_NAME}"
fi
tar xfz "${LIB_NAME}.tar.gz"
pushd .
cd "${LIB_NAME}"
PREFIX_DIR="${pwd_path}/build/android/${ABI}"
if [ -d "${PREFIX_DIR}" ]; then
rm -fr "${PREFIX_DIR}"
fi
mkdir -p "${PREFIX_DIR}"
OUTPUT_ROOT=${TOOLS_ROOT}/build/android/${ABI}
mkdir -p ${OUTPUT_ROOT}/log
set_android_toolchain "curl" "${ARCH}" "${ANDROID_API}"
set_android_cpu_feature "curl" "${ARCH}" "${ANDROID_API}"
export ANDROID_NDK_HOME=${ANDROID_NDK_ROOT}
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME}
OPENSSL_OUT_DIR="${pwd_path}/../openssl/build/android/${ABI}"
export LDFLAGS="${LDFLAGS} -L${OPENSSL_OUT_DIR}/lib"
# export LDFLAGS="-Wl,-rpath-link,-L${OPENSSL_OUT_DIR}/lib $LDFLAGS "
android_printf_global_params "$ARCH" "$ABI" "$ABI_TRIPLE" "$PREFIX_DIR" "$OUTPUT_ROOT"
if [[ "${ARCH}" == "x86_64" ]]; then
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
elif [[ "${ARCH}" == "x86" ]]; then
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
elif [[ "${ARCH}" == "arm" ]]; then
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
elif [[ "${ARCH}" == "arm64" ]]; then
./configure --host=$(android_get_build_host "${ARCH}") --prefix="${PREFIX_DIR}" --enable-ipv6 --with-ssl=${OPENSSL_OUT_DIR} --enable-static --disable-shared >"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
else
log_error "not support" && exit 1
fi
log_info "make $ABI start..."
make clean >>"${OUTPUT_ROOT}/log/${ABI}.log"
if make -j$(get_cpu_count) >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1; then
make install >>"${OUTPUT_ROOT}/log/${ABI}.log" 2>&1
fi
popd
}
log_info "${PLATFORM_TYPE} ${LIB_NAME} start..."
for ((i = 0; i < ${#ARCHS[@]}; i++)); do
if [[ $# -eq 0 || "$1" == "${ARCHS[i]}" ]]; then
configure_make "${ARCHS[i]}" "${ABIS[i]}" "${ABI_TRIPLES[i]}"
fi
done
log_info "${PLATFORM_TYPE} ${LIB_NAME} end..."

View File

@ -78,24 +78,24 @@ function set_ios_cpu_feature() {
armv7)
export CC="xcrun -sdk iphoneos clang -arch armv7"
export CXX="xcrun -sdk iphoneos clang++ -arch armv7"
export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
export CXXFLAGS="-std=c++11 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export CFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export LDFLAGS="-arch armv7 -target armv7-ios-darwin -march=armv7 -isysroot ${sysroot} -L${sysroot}/usr/lib "
export CXXFLAGS="-std=c++11 -arch armv7 -target armv7-ios-darwin -march=armv7 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
;;
arm64)
export CC="xcrun -sdk iphoneos clang -arch arm64"
export CXX="xcrun -sdk iphoneos clang++ -arch arm64"
export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export CFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export LDFLAGS="-arch arm64 -target aarch64-ios-darwin -march=armv8 -isysroot ${sysroot} -L${sysroot}/usr/lib "
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-ios-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
;;
arm64e)
# -march=armv8.3 ???
export CC="xcrun -sdk iphoneos clang -arch arm64e"
export CXX="xcrun -sdk iphoneos clang++ -arch arm64e"
export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -fembed-bitcode -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
export CXXFLAGS="-std=c++11 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -fembed-bitcode -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export CFLAGS="-arch arm64e -target aarch64-ios-darwin -Wno-unused-function -fstrict-aliasing -DIOS -isysroot ${sysroot} -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
export LDFLAGS="-arch arm64e -target aarch64-ios-darwin -isysroot ${sysroot} -L${sysroot}/usr/lib "
export CXXFLAGS="-std=c++11 -arch arm64e -target aarch64-ios-darwin -fstrict-aliasing -DIOS -miphoneos-version-min=${ios_min_target} -I${sysroot}/usr/include"
;;
i386)
export CC="xcrun -sdk iphonesimulator clang -arch i386"

View File

@ -1,18 +1,10 @@
core_android {
ABI_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
contains(ABI_PATH, "armv7" ) {
ABI_PATH = $$replace(ABI_PATH, "armv7", "armeabi-v7a")
}
contains(ABI_PATH, "arm64_v8a" ) {
ABI_PATH = $$replace(ABI_PATH, "arm64_v8a", "arm64-v8a")
}
INCLUDEPATH += \
$$PWD/build/android/$$ABI_PATH/include \
$$PWD/../openssl/build/android/$$ABI_PATH/include \
$$PWD/build/android/include \
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/include
LIBS += \
$$PWD/build/android/$$ABI_PATH/lib/libcurl.a \
$$PWD/../openssl/build/android/$$ABI_PATH/lib/libssl.a \
$$PWD/../openssl/build/android/$$ABI_PATH/lib/libcrypto.a \
$$PWD/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libcurl.a \
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/lib/libssl.a \
$$PWD/../openssl/build/android/$$CORE_BUILDS_PLATFORM_PREFIX_DST/lib/libcrypto.a \
}

View File

@ -12,22 +12,20 @@
#include "StaticFunctions.h"
#include "ConstValues.h"
#define DEFAULTFONTSIZE 28 // 14 * 2
#define DEFAULT_FONT_SIZE 14
namespace NSCSS
{
typedef std::map<std::wstring, std::wstring>::const_iterator styles_iterator;
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point)
{
m_oFont.SetSize(std::to_wstring(DEFAULTFONTSIZE), 0, true);
}
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point), m_dCoreFontSize(DEFAULT_FONT_SIZE)
{}
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure),
m_oFont(oStyle.m_oFont), m_oMargin(oStyle.m_oMargin), m_oPadding(oStyle.m_oPadding), m_oBackground(oStyle.m_oBackground),
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay){}
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure), m_dCoreFontSize(oStyle.m_dCoreFontSize),
m_oFont(oStyle.m_oFont), m_oMargin(oStyle.m_oMargin), m_oPadding(oStyle.m_oPadding), m_oBackground(oStyle.m_oBackground),
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay){}
CCompiledStyle::~CCompiledStyle()
{
@ -36,6 +34,9 @@ namespace NSCSS
CCompiledStyle& CCompiledStyle::operator+= (const CCompiledStyle &oElement)
{
if (oElement.Empty())
return *this;
m_oBackground += oElement.m_oBackground;
m_oBorder += oElement.m_oBorder;
m_oFont += oElement.m_oFont;
@ -44,6 +45,9 @@ namespace NSCSS
m_oText += oElement.m_oText;
m_oDisplay += oElement.m_oDisplay;
if (!oElement.m_sId.empty())
m_sId += L'+' + oElement.m_sId;
return *this;
}
@ -68,9 +72,7 @@ namespace NSCSS
bool CCompiledStyle::operator== (const CCompiledStyle& oStyle) const
{
return GetId()[0] == oStyle.GetId()[0] &&
m_arParentsStyles == oStyle.m_arParentsStyles &&
m_oBackground == oStyle.m_oBackground &&
return m_oBackground == oStyle.m_oBackground &&
m_oBorder == oStyle.m_oBorder &&
m_oFont == oStyle.m_oFont &&
m_oMargin == oStyle.m_oMargin &&
@ -100,16 +102,6 @@ namespace NSCSS
m_UnitMeasure = enUnitMeasure;
}
void CCompiledStyle::SetSizeSourceWindow(const CSizeWindow &oSizeWindow)
{
m_oSourceWindow = oSizeWindow;
}
void CCompiledStyle::SetSizeDeviceWindow(const CSizeWindow &oSizeWindow)
{
m_oDeviceWindow = oSizeWindow;
}
bool CCompiledStyle::Empty() const
{
return m_oBackground.Empty() && m_oBorder.Empty() && m_oFont.Empty() &&
@ -124,8 +116,11 @@ namespace NSCSS
void CCompiledStyle::AddStyle(const std::map<std::wstring, std::wstring>& mStyle, const unsigned int unLevel, const bool& bHardMode)
{
const bool bIsThereBorder = (m_oBorder.Empty()) ? false : true;
const double dFontSize = m_oFont.GetSize().ToDouble(NSCSS::Twips);
const double dParentFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE;
if (0 == unLevel)
m_dCoreFontSize = dParentFontSize;
for (std::pair<std::wstring, std::wstring> pPropertie : mStyle)
{
std::transform(pPropertie.first.begin(), pPropertie.first.end(), pPropertie.first.begin(), tolower);
@ -136,15 +131,15 @@ namespace NSCSS
CASE(L"font"):
{
m_oFont.SetValue(pPropertie.second, unLevel, bHardMode);
m_oFont.UpdateSize(dFontSize);
m_oFont.UpdateLineHeight(dFontSize);
m_oFont.UpdateSize(dParentFontSize, m_dCoreFontSize);
m_oFont.UpdateLineHeight(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"font-size"):
CASE(L"font-size-adjust"):
{
m_oFont.SetSize(pPropertie.second, unLevel, bHardMode);
m_oFont.UpdateSize(dFontSize);
m_oFont.UpdateSize(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"font-stretch"):
@ -183,82 +178,85 @@ namespace NSCSS
if (bIsThereBorder)
break;
m_oMargin.AddValue(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateAll(dFontSize);
m_oMargin.SetValues(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateAll(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"margin-top"):
CASE(L"topmargin"):
{
if (bIsThereBorder)
break;
m_oMargin.AddTop(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateTop(dFontSize);
m_oMargin.SetTop(pPropertie.second, unLevel, bHardMode);
break;
}
CASE(L"margin-right"):
CASE(L"margin-block-end"):
CASE(L"rightmargin"):
{
if (bIsThereBorder)
break;
m_oMargin.AddRight(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateRight(dFontSize);
m_oMargin.SetRight(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateRight(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"margin-bottom"):
CASE(L"bottommargin"):
{
if (bIsThereBorder)
break;
m_oMargin.AddBottom(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateBottom(dFontSize);
m_oMargin.SetBottom(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateBottom(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"margin-left"):
CASE(L"margin-block-start"):
CASE(L"leftmargin"):
{
if (bIsThereBorder)
break;
m_oMargin.AddLeft(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateLeft(dFontSize);
m_oMargin.SetLeft(pPropertie.second, unLevel, bHardMode);
m_oMargin.UpdateLeft(dParentFontSize, m_dCoreFontSize);
break;
}
//PADDING
CASE(L"padding"):
CASE(L"mso-padding-alt"):
{
m_oPadding.AddValue(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateAll(dFontSize);
m_oPadding.SetValues(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateAll(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"padding-top"):
CASE(L"mso-padding-top-alt"):
{
m_oPadding.AddTop(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateTop(dFontSize);
m_oPadding.SetTop(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateTop(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"padding-right"):
CASE(L"mso-padding-right-alt"):
{
m_oPadding.AddRight(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateRight(dFontSize);
m_oPadding.SetRight(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateRight(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"padding-bottom"):
CASE(L"mso-padding-bottom-alt"):
{
m_oPadding.AddBottom(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateBottom(dFontSize);
m_oPadding.SetBottom(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateBottom(dParentFontSize, m_dCoreFontSize);
break;
}
CASE(L"padding-left"):
CASE(L"mso-padding-left-alt"):
{
m_oPadding.AddLeft(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateLeft(dFontSize);
m_oPadding.SetLeft(pPropertie.second, unLevel, bHardMode);
m_oPadding.UpdateLeft(dParentFontSize, m_dCoreFontSize);
break;
}
// TEXT
@ -305,6 +303,11 @@ namespace NSCSS
m_oBorder.SetColor(pPropertie.second, unLevel, bHardMode);
break;
}
CASE(L"border-collapse"):
{
m_oBorder.SetCollapse(pPropertie.second, unLevel, bHardMode);
break;
}
//BORDER TOP
CASE(L"border-top"):
{
@ -393,20 +396,12 @@ namespace NSCSS
CASE(L"background-color"):
{
m_oBackground.SetColor(pPropertie.second, unLevel, bHardMode);
if (bIsThereBorder)
m_oBackground.InBorder();
break;
}
CASE(L"background"):
CASE(L"bgcolor"):
{
m_oBackground.SetBackground(pPropertie.second, unLevel, bHardMode);
if (bIsThereBorder)
m_oBackground.InBorder();
break;
}
//DISPLAY
@ -431,6 +426,7 @@ namespace NSCSS
break;
}
CASE(L"vertical-align"):
CASE(L"valign"):
{
m_oDisplay.SetVAlign(pPropertie.second, unLevel, bHardMode);
break;
@ -501,6 +497,11 @@ namespace NSCSS
return arParentsName;
}
std::set<std::wstring> CCompiledStyle::GetParentsNamesSet() const
{
return m_arParentsStyles;
}
void CCompiledStyle::SetID(const std::wstring& sId)
{
m_sId = sId;
@ -510,4 +511,9 @@ namespace NSCSS
{
return m_sId;
}
bool CCompiledStyle::HaveThisParent(const std::wstring &wsParentName) const
{
return m_arParentsStyles.end() != m_arParentsStyles.find(wsParentName);
}
}

View File

@ -22,9 +22,7 @@ namespace NSCSS
unsigned short int m_nDpi;
UnitMeasure m_UnitMeasure;
CSizeWindow m_oSourceWindow;
CSizeWindow m_oDeviceWindow;
double m_dCoreFontSize;
public:
NSProperties::CFont m_oFont;
NSProperties::CIndent m_oMargin;
@ -41,8 +39,6 @@ namespace NSCSS
void SetDpi(const unsigned short& uiDpi);
void SetUnitMeasure(const UnitMeasure& enUnitMeasure);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
bool Empty() const;
@ -53,10 +49,13 @@ namespace NSCSS
void AddParent(const std::wstring& sParentName);
std::vector<std::wstring> GetParentsName() const;
std::set<std::wstring> GetParentsNamesSet() const;
void SetID(const std::wstring& sId);
std::wstring GetId() const;
bool HaveThisParent(const std::wstring& wsParentName) const;
CCompiledStyle& operator+= (const CCompiledStyle& oElement);
CCompiledStyle& operator= (const CCompiledStyle& oElement);
bool operator== (const CCompiledStyle& oElement) const;

View File

@ -1,7 +1,6 @@
#include "CCssCalculator.h"
#include "CCssCalculator_Private.h"
namespace NSCSS
{
CCssCalculator::CCssCalculator()
@ -24,6 +23,16 @@ namespace NSCSS
return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
}
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
{
return m_pInternal->CalculateStyleId(oNode);
}
bool CCssCalculator::CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors)
{
return m_pInternal->CalculatePageStyle(oPageData, arSelectors);
}
void CCssCalculator::AddStyles(const std::string &sStyle)
{
m_pInternal->AddStyles(sStyle);
@ -54,26 +63,6 @@ namespace NSCSS
m_pInternal->SetBodyTree(oTree);
}
void CCssCalculator::SetSizeSourceWindow(const CSizeWindow &oSizeWindow)
{
m_pInternal->SetSizeSourceWindow(oSizeWindow);
}
void CCssCalculator::SetSizeDeviceWindow(const CSizeWindow &oSizeWindow)
{
m_pInternal->SetSizeDeviceWindow(oSizeWindow);
}
CSizeWindow CCssCalculator::GetSizeSourceWindow() const
{
return m_pInternal->GetSizeSourceWindow();
}
CSizeWindow CCssCalculator::GetSizeDeviceWindow() const
{
return m_pInternal->GetSizeDeviceWindow();
}
UnitMeasure CCssCalculator::GetUnitMeasure() const
{
return m_pInternal->GetUnitMeasure();

View File

@ -22,6 +22,9 @@ namespace NSCSS
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
std::wstring CalculateStyleId(const CNode& oNode);
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
// void AddStyle(const std::vector<std::string>& sSelectors, const std::string& sStyle);
void AddStyles (const std::string& sStyle);
void AddStyles (const std::wstring& wsStyle);
@ -31,12 +34,6 @@ namespace NSCSS
void SetDpi(const unsigned short int& nValue);
void SetBodyTree(const CTree &oTree);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
CSizeWindow GetSizeSourceWindow() const;
CSizeWindow GetSizeDeviceWindow() const;
UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;

View File

@ -16,8 +16,9 @@
#define MaxNumberRepetitions 6
inline static std::wstring StringifyValueList(const KatanaArray* oValues);
inline static std::wstring StringifyValue(const KatanaValue* oValue);
inline static std::wstring StringifyValueList(const KatanaArray* oValues);
inline static std::wstring StringifyValue(const KatanaValue* oValue);
inline static bool IsTableElement(const std::wstring& wsNameTag);
bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vector<NSCSS::CNode> &arRightSelectors)
{
@ -52,13 +53,6 @@ namespace NSCSS
m_mData.clear();
#ifdef CSS_CALCULATOR_WITH_XHTML
for (std::map<std::vector<CNode>, CCompiledStyle*>::iterator iter = m_mUsedStyles.begin(); iter != m_mUsedStyles.end(); ++iter)
delete iter->second;
m_mUsedStyles.clear();
#endif
if (NULL != m_mStatictics)
delete m_mStatictics;
}
@ -86,6 +80,182 @@ namespace NSCSS
}
#ifdef CSS_CALCULATOR_WITH_XHTML
std::map<std::wstring, std::wstring> CCssCalculator_Private::GetPageData(const std::wstring &wsPageName)
{
if (m_arPageDatas.empty())
return {};
for (const TPageData& oPageData : m_arPageDatas)
{
if (std::find(oPageData.m_wsNames.begin(), oPageData.m_wsNames.end(), wsPageName) != oPageData.m_wsNames.end())
return oPageData.m_mData;
}
return {};
}
void CCssCalculator_Private::SetPageData(NSProperties::CPage &oPage, const std::map<std::wstring, std::wstring> &mData, unsigned int unLevel, bool bHardMode)
{
for (const std::pair<std::wstring, std::wstring> &oData : mData)
{
if (L"margin" == oData.first)
oPage.SetMargin(oData.second, unLevel, bHardMode);
else if (L"size" == oData.first)
oPage.SetSize(oData.second, unLevel, bHardMode);
else if (L"mso-header-margin" == oData.first)
oPage.SetHeader(oData.second, unLevel, bHardMode);
else if (L"mso-footer-margin" == oData.first)
oPage.SetFooter(oData.second, unLevel, bHardMode);
}
}
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors)
{
std::vector<std::wstring> arNodes;
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
{
if (!oNode->m_wsName.empty())
arNodes.push_back(oNode->m_wsName);
if (!oNode->m_wsClass.empty())
{
if (oNode->m_wsClass.find(L' ') != std::wstring::npos)
{
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode->m_wsClass, false, L" ");
arNodes.push_back(std::accumulate(arClasses.begin(), arClasses.end(), std::wstring(),
[](std::wstring sRes, const std::wstring& sClass)
{return sRes += L'.' + sClass + L' ';}));
}
else
arNodes.push_back(L'.' + oNode->m_wsClass);
}
if (!oNode->m_wsId.empty())
arNodes.push_back(L'#' + oNode->m_wsId);
}
return arNodes;
}
void CCssCalculator_Private::FindPrevAndKindElements(const CElement *pElement, const std::vector<std::wstring> &arNextNodes, std::vector<CElement*>& arFindedElements, const std::wstring &wsName, const std::vector<std::wstring> &arClasses)
{
if (arNextNodes.empty())
return;
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.crbegin() + 1, arNextNodes.crend());
const std::vector<CElement*> arTempKins = pElement->GetNextOfKin(wsName, arClasses);
if (!arTempPrev.empty())
arFindedElements.insert(arFindedElements.end(), arTempPrev.begin(), arTempPrev.end());
if (!arTempKins.empty())
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
}
std::vector<CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes, bool bIsSettings)
{
if (arNodes.empty())
return {};
std::vector<CElement*> arFindedElements;
std::wstring wsName, wsId;
std::vector<std::wstring> arClasses;
if (!arNodes.empty() && arNodes.back()[0] == L'#')
{
wsId = arNodes.back();
arNodes.pop_back();
arNextNodes.push_back(wsId);
}
if (!arNodes.empty() && arNodes.back()[0] == L'.')
{
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arNodes.back(), false, L" ");
arNextNodes.push_back(arNodes.back());
arNodes.pop_back();
}
if (!arNodes.empty())
{
wsName = arNodes.back();
arNodes.pop_back();
arNextNodes.push_back(wsName);
}
const std::map<std::wstring, CElement*>::const_iterator oFindName = m_mData.find(wsName);
std::map<std::wstring, CElement*>::const_iterator oFindId;
if (!wsId.empty())
{
oFindId = m_mData.find(wsId);
if (oFindId != m_mData.end() && NULL != m_mStatictics)
{
std::map<StatistickElement, unsigned int>::const_iterator oFindCountId = m_mStatictics->find(StatistickElement{StatistickElement::IsId, wsId});
if ((m_mStatictics->end() != oFindCountId) &&
(((bIsSettings && oFindCountId->second < MaxNumberRepetitions) ||
(!bIsSettings && oFindCountId->second >= MaxNumberRepetitions))))
{
if (!oFindId->second->Empty())
arFindedElements.push_back(oFindId->second);
}
FindPrevAndKindElements(oFindId->second, arNextNodes, arFindedElements, wsName);
}
}
if (!arClasses.empty())
{
if (!bIsSettings)
{
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
{
const std::map<std::wstring, CElement*>::const_iterator oFindClass = m_mData.find(*iClass);
if (oFindClass != m_mData.end())
{
if (!oFindClass->second->Empty())
arFindedElements.push_back(oFindClass->second);
FindPrevAndKindElements(oFindClass->second, arNextNodes, arFindedElements, wsName);
}
}
}
}
if (oFindName != m_mData.end())
{
if (!bIsSettings)
{
if (!oFindName->second->Empty())
arFindedElements.push_back(oFindName->second);
FindPrevAndKindElements(oFindName->second, arNextNodes, arFindedElements, wsName, arClasses);
}
}
if (arFindedElements.size() > 1)
{
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
[](CElement* oFirstElement, CElement* oSecondElement)
{
return oFirstElement->GetWeight() > oSecondElement->GetWeight();
});
}
return arFindedElements;
}
#endif
void CCssCalculator_Private::AddPageData(const std::wstring &wsPageNames, const std::wstring &wsStyles)
{
m_arPageDatas.push_back({NS_STATIC_FUNCTIONS::GetWordsW(wsPageNames), NS_STATIC_FUNCTIONS::GetRules(wsStyles)});
}
inline void CCssCalculator_Private::GetStylesheet(const KatanaStylesheet *oStylesheet)
{
for (size_t i = 0; i < oStylesheet->imports.length; ++i)
@ -308,231 +478,11 @@ namespace NSCSS
if (arSelectors.empty())
return CCompiledStyle();
SetUnitMeasure(unitMeasure);
CCompiledStyle oStyle;
if (!bIsSettings)
{
const std::map<std::vector<CNode>, CCompiledStyle*>::iterator oItem = m_mUsedStyles.find(arSelectors);
GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
if (oItem != m_mUsedStyles.end())
return *oItem->second;
}
else if (NULL == m_mStatictics || m_mStatictics->empty())
{
CCompiledStyle oStyle;
oStyle.SetDpi(m_nDpi);
oStyle.SetUnitMeasure(m_UnitMeasure);
oStyle.SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
oStyle.SetSizeDeviceWindow(m_oDeviceWindow);
oStyle.SetSizeSourceWindow(m_oSourceWindow);
return oStyle;
}
CCompiledStyle *pStyle = new CCompiledStyle();
pStyle->SetDpi(m_nDpi);
pStyle->SetUnitMeasure(m_UnitMeasure);
pStyle->SetSizeDeviceWindow(m_oDeviceWindow);
pStyle->SetSizeSourceWindow(m_oSourceWindow);
std::vector<std::wstring> arWords;
arWords.reserve(arSelectors.size() * 2);
std::vector<std::wstring> arNextNodes;
arNextNodes.reserve(arSelectors.size() * 2);
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
{
arWords.push_back(oNode->m_wsName);
//TODO:: проверить данный момент
// if (oNode->m_sName == L"td")
// pStyle->m_oMargin.SetPermission(false);
if (oNode->m_wsName == L"table")
pStyle->m_oBorder.Block();
if (!oNode->m_wsClass.empty())
{
if (oNode->m_wsClass.find(L' ') != std::wstring::npos)
{
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode->m_wsClass, false, L" ");
if (arClasses.size() > 1)
arClasses.resize(unique(arClasses.begin(),arClasses.end()) - arClasses.begin());
switch (arClasses.size())
{
case 1:
{
arWords.push_back(L'.' + arClasses[0]);
break;
}
case 2:
{
arWords.push_back(L'.' + arClasses[0] + L" ." + arClasses[1]);
break;
}
case 3:
{
arWords.push_back(L'.' + arClasses[0] + L" ." + arClasses[1] + L" ." + arClasses[2]);
break;
}
default:
{
arWords.push_back(std::accumulate(arClasses.begin(), arClasses.end(), std::wstring(),
[](std::wstring sRes, const std::wstring& sClass)
{return sRes += L'.' + sClass + L' ';}));
break;
}
}
}
else
arWords.push_back(L'.' + oNode->m_wsClass);
}
if (!oNode->m_wsId.empty())
arWords.push_back(L'#' + oNode->m_wsId);
}
std::vector<CElement*> arElements;
for (size_t i = 0; i < arSelectors.size(); ++i)
{
std::wstring sName, sId;
std::vector<std::wstring> arClasses;
if (arWords.back()[0] == L'#')
{
sId = arWords.back();
arWords.pop_back();
arNextNodes.push_back(sId);
}
if (arWords.back()[0] == L'.')
{
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arWords.back(), false, L" ");
arNextNodes.push_back(arWords.back());
arWords.pop_back();
}
sName = arWords.back();
arWords.pop_back();
arNextNodes.push_back(sName);
pStyle->AddParent(sName);
const std::map<std::wstring, CElement*>::const_iterator oFindName = m_mData.find(sName);
std::map<std::wstring, CElement*>::const_iterator oFindId;
std::vector<CElement*> arFindElements;
if (!sId.empty())
{
oFindId = m_mData.find(sId);
if (oFindId != m_mData.end() && NULL != m_mStatictics)
{
std::map<StatistickElement, unsigned int>::const_iterator oFindCountId = m_mStatictics->find(StatistickElement{StatistickElement::IsId, sId});
if ((m_mStatictics->end() != oFindCountId) &&
(((bIsSettings && oFindCountId->second < MaxNumberRepetitions) ||
(!bIsSettings && oFindCountId->second >= MaxNumberRepetitions))))
{
if (!oFindId->second->Empty())
arFindElements.push_back(oFindId->second);
}
const std::vector<CElement*> arTempPrev = oFindId->second->GetPrevElements(arNextNodes.rbegin() + ((arClasses.empty()) ? 1 : 2), arNextNodes.rend());
if (!arTempPrev.empty())
arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end());
}
}
if (!arClasses.empty())
{
if (!bIsSettings)
{
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
{
const std::map<std::wstring, CElement*>::const_iterator oFindClass = m_mData.find(*iClass);
if (oFindClass != m_mData.end())
{
if (!oFindClass->second->Empty())
arFindElements.push_back(oFindClass->second);
const std::vector<CElement*> arTempPrev = oFindClass->second->GetPrevElements(arNextNodes.rbegin() + 2, arNextNodes.rend());
const std::vector<CElement*> arTempKins = oFindClass->second->GetNextOfKin(sName);
if (!arTempPrev.empty())
arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end());
if (!arTempKins.empty())
arFindElements.insert(arFindElements.end(), arTempKins.begin(), arTempKins.end());
}
}
}
}
if (oFindName != m_mData.end())
{
if (!bIsSettings)
{
if (!oFindName->second->Empty())
arFindElements.push_back(oFindName->second);
const std::vector<CElement*> arTempPrev = oFindName->second->GetPrevElements(arNextNodes.rbegin() + 1, arNextNodes.rend());
const std::vector<CElement*> arTempKins = oFindName->second->GetNextOfKin(sName, arClasses);
if (!arTempPrev.empty())
arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end());
if (!arTempKins.empty())
arFindElements.insert(arFindElements.end(), arTempKins.begin(), arTempKins.end());
}
}
if (arFindElements.size() > 1)
{
std::sort(arFindElements.rbegin(), arFindElements.rend(),
[](CElement* oFirstElement, CElement* oSecondElement)
{
return oFirstElement->GetWeight() > oSecondElement->GetWeight();
});
}
pStyle->AddStyle(arSelectors[i].m_mAttributes, i + 1);
for (const CElement* oElement : arFindElements)
pStyle->AddStyle(oElement->GetStyle(), i + 1);
if (NULL != m_mStatictics)
{
std::map<StatistickElement, unsigned int>::const_iterator oFindCountStyle = m_mStatictics->find(StatistickElement{StatistickElement::IsStyle, arSelectors[i].m_wsStyle});
if (oFindCountStyle != m_mStatictics->end())
{
if ((bIsSettings && oFindCountStyle->second < MaxNumberRepetitions) ||
(!bIsSettings && oFindCountStyle->second >= MaxNumberRepetitions))
pStyle->AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
else if (!bIsSettings)
pStyle->AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
}
else if (bIsSettings)
pStyle->AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
}
else
pStyle->AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
}
if (!bIsSettings)
{
pStyle->SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
m_mUsedStyles[arSelectors] = pStyle;
}
return *pStyle;
return oStyle;
}
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure)
@ -544,11 +494,11 @@ namespace NSCSS
if (!bIsSettings)
{
const std::map<std::vector<CNode>, CCompiledStyle*>::iterator oItem = m_mUsedStyles.find(arSelectors);
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
if (oItem != m_mUsedStyles.end())
{
oStyle = *oItem->second;
oStyle = oItem->second;
return true;
}
}
@ -558,180 +508,35 @@ namespace NSCSS
oStyle.SetUnitMeasure(m_UnitMeasure);
oStyle.SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
oStyle.SetSizeDeviceWindow(m_oDeviceWindow);
oStyle.SetSizeSourceWindow(m_oSourceWindow);
return false;
}
oStyle.SetDpi(m_nDpi);
oStyle.SetUnitMeasure(m_UnitMeasure);
oStyle.SetSizeDeviceWindow(m_oDeviceWindow);
oStyle.SetSizeSourceWindow(m_oSourceWindow);
std::vector<std::wstring> arWords;
arWords.reserve(arSelectors.size() * 2);
std::vector<std::wstring> arNextNodes;
arNextNodes.reserve(arSelectors.size() * 2);
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
{
arWords.push_back(oNode->m_wsName);
// if (oNode->m_sName == L"td")
// oStyle.m_pMargin.SetPermission(false);
if (oNode->m_wsName == L"table")
oStyle.m_oBorder.Block();
if (!oNode->m_wsClass.empty())
{
if (oNode->m_wsClass.find(L' ') != std::wstring::npos)
{
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode->m_wsClass, false, L" ");
if (arClasses.size() > 1)
arClasses.resize(unique(arClasses.begin(),arClasses.end()) - arClasses.begin());
switch (arClasses.size())
{
case 1:
{
arWords.push_back(L'.' + arClasses[0]);
break;
}
case 2:
{
arWords.push_back(L'.' + arClasses[0] + L" ." + arClasses[1]);
break;
}
case 3:
{
arWords.push_back(L'.' + arClasses[0] + L" ." + arClasses[1] + L" ." + arClasses[2]);
break;
}
default:
{
arWords.push_back(std::accumulate(arClasses.begin(), arClasses.end(), std::wstring(),
[](std::wstring sRes, const std::wstring& sClass)
{return sRes += L'.' + sClass + L' ';}));
break;
}
}
}
else
arWords.push_back(L'.' + oNode->m_wsClass);
}
if (!oNode->m_wsId.empty())
arWords.push_back(L'#' + oNode->m_wsId);
}
std::vector<CElement*> arElements;
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
std::vector<std::wstring> arPrevNodes;
bool bInTable = false;
for (size_t i = 0; i < arSelectors.size(); ++i)
{
std::wstring sName, sId;
std::vector<std::wstring> arClasses;
oStyle.AddParent(arSelectors[i].m_wsName);
if (arWords.back()[0] == L'#')
if (!bInTable)
bInTable = IsTableElement(arSelectors[i].m_wsName);
if (bInTable)
{
sId = arWords.back();
arWords.pop_back();
arNextNodes.push_back(sId);
oStyle.m_oBackground.Clear();
oStyle.m_oBorder.Clear();
}
if (arWords.back()[0] == L'.')
{
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arWords.back(), false, L" ");
arNextNodes.push_back(arWords.back());
arWords.pop_back();
}
CCompiledStyle oTempStyle;
sName = arWords.back();
arWords.pop_back();
arNextNodes.push_back(sName);
oStyle.AddParent(sName);
oTempStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
const std::map<std::wstring, CElement*>::const_iterator oFindName = m_mData.find(sName);
std::map<std::wstring, CElement*>::const_iterator oFindId;
std::vector<CElement*> arFindElements;
if (!sId.empty())
{
oFindId = m_mData.find(sId);
if (oFindId != m_mData.end() && NULL != m_mStatictics)
{
std::map<StatistickElement, unsigned int>::const_iterator oFindCountId = m_mStatictics->find(StatistickElement{StatistickElement::IsId, sId});
if ((m_mStatictics->end() != oFindCountId) &&
(((bIsSettings && oFindCountId->second < MaxNumberRepetitions) ||
(!bIsSettings && oFindCountId->second >= MaxNumberRepetitions))))
{
if (!oFindId->second->Empty())
arFindElements.push_back(oFindId->second);
}
const std::vector<CElement*> arTempPrev = oFindId->second->GetPrevElements(arNextNodes.rbegin() + ((arClasses.empty()) ? 1 : 2), arNextNodes.rend());
if (!arTempPrev.empty())
arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end());
}
}
if (!arClasses.empty())
{
if (!bIsSettings)
{
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
{
const std::map<std::wstring, CElement*>::const_iterator oFindClass = m_mData.find(*iClass);
if (oFindClass != m_mData.end())
{
if (!oFindClass->second->Empty())
arFindElements.push_back(oFindClass->second);
const std::vector<CElement*> arTempPrev = oFindClass->second->GetPrevElements(arNextNodes.rbegin() + 2, arNextNodes.rend());
const std::vector<CElement*> arTempKins = oFindClass->second->GetNextOfKin(sName);
if (!arTempPrev.empty())
arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end());
if (!arTempKins.empty())
arFindElements.insert(arFindElements.end(), arTempKins.begin(), arTempKins.end());
}
}
}
}
if (oFindName != m_mData.end())
{
if (!bIsSettings)
{
if (!oFindName->second->Empty())
arFindElements.push_back(oFindName->second);
const std::vector<CElement*> arTempPrev = oFindName->second->GetPrevElements(arNextNodes.rbegin() + 1, arNextNodes.rend());
const std::vector<CElement*> arTempKins = oFindName->second->GetNextOfKin(sName, arClasses);
if (!arTempPrev.empty())
arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end());
if (!arTempKins.empty())
arFindElements.insert(arFindElements.end(), arTempKins.begin(), arTempKins.end());
}
}
if (arFindElements.size() > 1)
{
std::sort(arFindElements.rbegin(), arFindElements.rend(),
[](CElement* oFirstElement, CElement* oSecondElement)
{
return oFirstElement->GetWeight() > oSecondElement->GetWeight();
});
}
for (const CElement* oElement : FindElements(arNodes, arPrevNodes, bIsSettings))
oTempStyle.AddStyle(oElement->GetStyle(), i + 1);
if (NULL != m_mStatictics)
{
@ -741,31 +546,68 @@ namespace NSCSS
{
if ((bIsSettings && oFindCountStyle->second < MaxNumberRepetitions) ||
(!bIsSettings && oFindCountStyle->second >= MaxNumberRepetitions))
oStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
else if (!bIsSettings)
oStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
}
else if (bIsSettings)
oStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
else /*if (bIsSettings)*/
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
}
else
oStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
for (const CElement* oElement : arFindElements)
oStyle.AddStyle(oElement->GetStyle(), i + 1);
oStyle += oTempStyle;
oStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
if (bInTable && i < arSelectors.size() - 1)
{
oStyle.m_oFont.GetLineHeight().Clear();
oStyle.m_oPadding.Clear();
oStyle.m_oMargin.Clear();
}
}
if (!bIsSettings)
oStyle.SetID(CalculateStyleId(arSelectors.back()));
if (!bIsSettings && !oStyle.Empty())
m_mUsedStyles[arSelectors] = oStyle;
return true;
}
std::wstring CCssCalculator_Private::CalculateStyleId(const CNode& oNode)
{
return oNode.m_wsName + ((!oNode.m_wsClass.empty()) ? L'.' + oNode.m_wsClass : L"") + ((oNode.m_wsId.empty()) ? L"" : L'#' + oNode.m_wsId) + L'-' + std::to_wstring(++m_nCountNodes);
}
bool CCssCalculator_Private::CalculatePageStyle(NSProperties::CPage &oPageData, const std::vector<CNode> &arSelectors)
{
if (arSelectors.empty())
return false;
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
std::vector<std::wstring> arNextNodes;
for (size_t i = 0; i < arSelectors.size(); ++i)
{
oStyle.SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
if (!arSelectors[i].m_wsStyle.empty() && std::wstring::npos != arSelectors[i].m_wsStyle.find(L"page"))
{
std::map<std::wstring, std::wstring> mRules = NS_STATIC_FUNCTIONS::GetRules(arSelectors[i].m_wsStyle);
if (mRules.end() != mRules.find(L"page"))
SetPageData(oPageData, GetPageData(mRules[L"page"]), i + 1, true);
}
CCompiledStyle *pTemp = new CCompiledStyle(oStyle);
for (const CElement* oElement : FindElements(arNodes, arNextNodes, false))
{
std::map<std::wstring, std::wstring> mRules = oElement->GetStyle();
if (mRules.end() != mRules.find(L"page"))
SetPageData(oPageData, GetPageData(mRules[L"page"]), i + 1, true);
}
m_mUsedStyles[arSelectors] = pTemp;
if (arSelectors[i].m_mAttributes.end() != arSelectors[i].m_mAttributes.find(L"page"))
SetPageData(oPageData, GetPageData(arSelectors[i].m_mAttributes.at(L"page")), i + 1, false);
}
return true;
}
#endif
@ -784,6 +626,16 @@ namespace NSCSS
if (wsStyle.empty())
return;
std::wregex oRegex(L"@page\\s*([^{]*)(\\{[^}]*\\})");
std::wsmatch oMatch;
std::wstring::const_iterator oSearchStart(wsStyle.cbegin());
while (std::regex_search(oSearchStart, wsStyle.cend(), oMatch, oRegex))
{
AddPageData(oMatch[1].str(), oMatch[2].str());
oSearchStart = oMatch.suffix().first;
}
AddStyles(U_TO_UTF8(wsStyle));
}
@ -810,26 +662,6 @@ namespace NSCSS
CTree::CountingNumberRepetitions(oTree, *m_mStatictics);
}
void CCssCalculator_Private::SetSizeSourceWindow(const CSizeWindow &oSizeWindow)
{
m_oSourceWindow = oSizeWindow;
}
void CCssCalculator_Private::SetSizeDeviceWindow(const CSizeWindow &oSizeWindow)
{
m_oDeviceWindow = oSizeWindow;
}
CSizeWindow CCssCalculator_Private::GetSizeSourceWindow() const
{
return m_oSourceWindow;
}
CSizeWindow CCssCalculator_Private::GetSizeDeviceWindow() const
{
return m_oDeviceWindow;
}
void CCssCalculator_Private::SetUnitMeasure(const UnitMeasure& nType)
{
m_UnitMeasure = nType;
@ -863,9 +695,6 @@ namespace NSCSS
m_mData.clear();
m_arFiles.clear();
m_oDeviceWindow.Clear();
m_oSourceWindow.Clear();
}
}
inline static std::wstring StringifyValueList(const KatanaArray* oValues)
@ -968,4 +797,11 @@ inline static std::wstring StringifyValue(const KatanaValue* oValue)
return str;
}
inline static bool IsTableElement(const std::wstring& wsNameTag)
{
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
L"tbody" == wsNameTag || L"thead" == wsNameTag || L"tfoot" == wsNameTag ||
L"th" == wsNameTag;
}

View File

@ -26,16 +26,31 @@ namespace NSCSS
std::map<std::wstring, CElement*> m_mData;
typedef struct
{
std::vector<std::wstring> m_wsNames;
std::map<std::wstring, std::wstring> m_mData;
} TPageData;
std::vector<TPageData> m_arPageDatas;
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
#ifdef CSS_CALCULATOR_WITH_XHTML
std::map<std::vector<CNode>, CCompiledStyle*> m_mUsedStyles;
std::map<std::vector<CNode>, CCompiledStyle> m_mUsedStyles;
std::map<std::wstring, std::wstring> GetPageData(const std::wstring& wsPageName);
void SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode = false);
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
void FindPrevAndKindElements(const CElement* pElement, const std::vector<std::wstring>& arNextNodes, std::vector<CElement*>& arFindedElements, const std::wstring& wsName, const std::vector<std::wstring>& arClasses = {});
std::vector<CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes, bool bIsSettings);
#endif
std::wstring m_sEncoding;
CSizeWindow m_oSourceWindow;
CSizeWindow m_oDeviceWindow;
void AddPageData(const std::wstring& wsPageName, const std::wstring& wsStyles);
void GetStylesheet(const KatanaStylesheet* oStylesheet);
void GetRule(const KatanaRule* oRule);
@ -59,6 +74,9 @@ namespace NSCSS
#ifdef CSS_CALCULATOR_WITH_XHTML
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
std::wstring CalculateStyleId(const CNode& oNode);
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
#endif
void AddStyles(const std::string& sStyle);
@ -69,12 +87,6 @@ namespace NSCSS
void SetDpi(unsigned short int nValue);
void SetBodyTree(const CTree &oTree);
void SetSizeSourceWindow(const CSizeWindow& oSizeWindow);
void SetSizeDeviceWindow(const CSizeWindow& oSizeWindow);
CSizeWindow GetSizeSourceWindow() const;
CSizeWindow GetSizeDeviceWindow() const;
UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;

View File

@ -173,26 +173,26 @@ namespace NSCSS
return arElements;
}
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::reverse_iterator &arNodesRBegin, const std::vector<std::wstring>::reverse_iterator &arNodesREnd) const
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::const_reverse_iterator& oNodesRBegin, const std::vector<std::wstring>::const_reverse_iterator& oNodesREnd) const
{
if (arNodesRBegin >= arNodesREnd || m_arPrevElements.empty())
if (oNodesRBegin >= oNodesREnd || m_arPrevElements.empty())
return std::vector<CElement*>();
std::vector<CElement*> arElements;
for (std::vector<std::wstring>::reverse_iterator iWord = arNodesRBegin; iWord != arNodesREnd; ++iWord)
for (std::vector<std::wstring>::const_reverse_iterator iWord = oNodesRBegin; iWord != oNodesREnd; ++iWord)
{
if ((*iWord)[0] == L'.' && ((*iWord).find(L" ") != std::wstring::npos))
{
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(*iWord, false, L" ");
for (std::wstring sClass : arClasses)
for (const std::wstring& wsClass : arClasses)
{
for (CElement* oPrevElement : m_arPrevElements)
{
if (oPrevElement->m_sSelector == sClass)
if (oPrevElement->m_sSelector == wsClass)
{
arElements.push_back(oPrevElement);
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd);
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesREnd);
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
}
}
@ -205,7 +205,7 @@ namespace NSCSS
if (oPrevElement->m_sSelector == *iWord)
{
arElements.push_back(oPrevElement);
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd);
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesREnd);
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
// return arElements;
}

View File

@ -39,7 +39,7 @@ namespace NSCSS
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<CNode>& arSelectors) const;
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<std::wstring>& arNodes) const;
std::vector<CElement *> GetNextOfKin(const std::wstring& sName, const std::vector<std::wstring>& arClasses = {}) const;
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::reverse_iterator &arNodesRBegin, const std::vector<std::wstring>::reverse_iterator &arNodesREnd) const;
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::const_reverse_iterator& oNodesRBegin, const std::vector<std::wstring>::const_reverse_iterator& oNodesREnd) const;
std::map<std::wstring, std::wstring> GetConvertStyle(const std::vector<CNode>& arNodes) const;
CElement *FindPrevElement(const std::wstring& sSelector) const;

View File

@ -5,7 +5,7 @@ namespace NSCSS
CNode::CNode()
{}
CNode::CNode(std::wstring wsName, std::wstring wsClass, std::wstring wsId)
CNode::CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId)
: m_wsName(wsName), m_wsClass(wsClass), m_wsId(wsId)
{}
@ -14,6 +14,15 @@ namespace NSCSS
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
}
void CNode::Clear()
{
m_wsName .clear();
m_wsClass .clear();
m_wsId .clear();
m_wsStyle .clear();
m_mAttributes.clear();
}
std::vector<std::wstring> CNode::GetData() const
{
std::vector<std::wstring> arValues;

View File

@ -18,10 +18,12 @@ namespace NSCSS
public:
CNode();
CNode(std::wstring wsName, std::wstring wsClass, std::wstring wsId);
CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId);
bool Empty() const;
void Clear();
std::vector<std::wstring> GetData() const;
bool operator< (const CNode& oNode) const;
bool operator== (const CNode& oNode) const;

View File

@ -14,23 +14,21 @@ namespace NSCSS
{
switch (enUnitMeasure)
{
case NSCSS::Pixel:
return dValue;
case NSCSS::Point:
return 72. / (double)ushDPI * dValue;
return dValue * 72. / (double)ushDPI;
case NSCSS::Cantimeter:
return dValue / (double)ushDPI * 2.54;
case NSCSS::Millimeter:
return dValue / (double)ushDPI * 25.4;
case NSCSS::Inch:
return 1. / (double)ushDPI * dValue;
return dValue / (double)ushDPI;
case NSCSS::Peak:
return 0.16667 / (double)ushDPI * dValue;
return dValue * 6. / (double)ushDPI; // 1 дюйм = 6 пик
case NSCSS::Twips:
return (dValue / (double)ushDPI) * 144.;
return dValue * 1440. / (double)ushDPI;
default:
return dValue;
}
return 0.;
}
double CUnitMeasureConverter::ConvertCm(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI)
@ -38,22 +36,20 @@ namespace NSCSS
switch (enUnitMeasure)
{
case NSCSS::Point:
return 28.35 * dValue;
return dValue * 28.3465 ; // 1 см = (2.54 / 72) пункта
case NSCSS::Pixel:
return (double)ushDPI / 2.54 * dValue;
case NSCSS::Cantimeter:
return dValue;
return dValue * (double)ushDPI / 2.54;
case NSCSS::Millimeter:
return dValue * 10.;
case NSCSS::Inch:
return dValue / 2.54f;
return dValue / 2.54; // 1 дюйм = 2.54 см
case NSCSS::Peak:
return 2.36 * dValue;
return dValue * 2.36; // 2.36 = 6 / 2.54
case NSCSS::Twips:
return (dValue) * 0.3937 * (double)ushDPI;
return dValue * 567.; // 1 см = (1440 / 2.54) твипов
default:
return dValue;
}
return 0.;
}
double CUnitMeasureConverter::ConvertMm(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
@ -61,22 +57,20 @@ namespace NSCSS
switch (enUnitMeasure)
{
case NSCSS::Point:
return 2.835 * dValue;
return dValue * 2.8346; // 1 мм = (25.4 / 72) пункта
case NSCSS::Pixel:
return (double)ushDPI / 25.4 * dValue;
return dValue * (double)ushDPI / 25.4;
case NSCSS::Cantimeter:
return dValue / 10.;
case NSCSS::Millimeter:
return dValue;
case NSCSS::Inch:
return dValue / 25.4;
case NSCSS::Peak:
return 0.236 * dValue;
return dValue * 0.236; // 0.236 = 6 / 25.4
case NSCSS::Twips:
return (dValue / 10.) * 0.3937 * (double)ushDPI;
return dValue * 56.7;
default:
return dValue;
}
return 0.;
}
double CUnitMeasureConverter::ConvertIn(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
@ -84,45 +78,41 @@ namespace NSCSS
switch (enUnitMeasure)
{
case NSCSS::Point:
return dValue / 6.;
return dValue / 72.;
case NSCSS::Pixel:
return dValue * (double)ushDPI;
case NSCSS::Cantimeter:
return dValue * 2.54;
return dValue * 2.54; // 1 дюйм = 2.54 см
case NSCSS::Millimeter:
return dValue * 25.4;
case NSCSS::Inch:
return dValue;
case NSCSS::Peak:
return dValue / 72.;
return dValue * 6.;
case NSCSS::Twips:
return dValue * 144.;
return dValue * 1440.;
default:
return dValue;
}
return 0.;
}
double CUnitMeasureConverter::ConvertPt(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
{
switch (enUnitMeasure)
{
case NSCSS::Point:
return dValue;
case NSCSS::Pixel:
return (double)ushDPI / 72. * dValue;
return dValue * (double)ushDPI / 72.;
case NSCSS::Cantimeter:
return dValue * 0.03528;
return dValue * 0.03528; // 0.03528 = 2.54 / 72
case NSCSS::Millimeter:
return dValue * 0.3528;
case NSCSS::Inch:
return dValue / 72.;
return dValue / 72.; // 1 дюйм = 72 пункта
case NSCSS::Peak:
return dValue / 12.;
return dValue * 0.0833; // 0.0833 = 6 / 72 (1 пункт = 1/72 дюйма)
case NSCSS::Twips:
return (dValue / 72.) * 144.;
return dValue * 20.; // 20 = 1440 / 72
default:
return dValue;
}
return 0.;
}
double CUnitMeasureConverter::ConvertPc(double dValue, NSCSS::UnitMeasure enUnitMeasure, unsigned short ushDPI)
@ -130,27 +120,49 @@ namespace NSCSS
switch (enUnitMeasure)
{
case NSCSS::Point:
return dValue * 12.;
return dValue * 12.; // 12 = 72 / 6
case NSCSS::Pixel:
return (double)ushDPI / 6. * dValue;
return dValue * (double)ushDPI / 6.; // 1 дюйм = 6 пика
case NSCSS::Cantimeter:
return dValue * 0.423;
return dValue * 0.423; // 0.423 = 2.54 / 6
case NSCSS::Millimeter:
return dValue * 4.23;
return dValue * 4.233; // 4.23 = 25.4 / 6
case NSCSS::Inch:
return dValue / 6.;
case NSCSS::Peak:
return dValue;
case NSCSS::Twips:
return dValue * 24.;
return dValue * 3.333; // 3.333 = 20 / 6
default:
return dValue;
}
}
double CUnitMeasureConverter::ConvertTw(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI)
{
switch (enUnitMeasure)
{
case NSCSS::Point:
return dValue * 0.05; // 0.05 = 72. / 1440.
case NSCSS::Pixel:
return dValue * (double)ushDPI / 1440.; // 1 дюйм = 1440 твипов
case NSCSS::Cantimeter:
return dValue * 0.001764; // 0.001764 = 2.54 / 1440
case NSCSS::Millimeter:
return dValue * 0.01764;
case NSCSS::Inch:
return dValue * 1440.;
case NSCSS::Peak:
return dValue * 0.004167; // 0.004167 = 6 / 1440
default:
return dValue;
}
return 0.;
}
bool CUnitMeasureConverter::GetValue(const std::wstring &wsValue, double &dValue, UnitMeasure &enUnitMeasure)
{
std::wregex oRegex(LR"((-?\.\d+|-?\d+(\.\d+)?)\s*(px|pt|cm|mm|in|pc|%|em|rem)?)");
if (wsValue.empty() || wsValue.end() == std::find_if(wsValue.begin(), wsValue.end(), [](wchar_t wChar) { return iswdigit(wChar);}))
return false;
std::wregex oRegex(LR"((-?\.\d+|-?\d+(\.\d+)?)\s*(px|pt|cm|mm|in|pc|%|em|rem|tw)?)");
std::wsmatch oMatches;
if(!std::regex_search(wsValue, oMatches, oRegex))
@ -176,6 +188,8 @@ namespace NSCSS
enUnitMeasure = Em;
else if (L"rem" == oMatches[3])
enUnitMeasure = Rem;
else if (L"tw" == oMatches[3])
enUnitMeasure = Twips;
else
enUnitMeasure = None;

View File

@ -30,6 +30,7 @@ namespace NSCSS
static double ConvertIn(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertPt(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertPc(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static double ConvertTw(double dValue, UnitMeasure enUnitMeasure, unsigned short ushDPI);
static bool GetValue(const std::wstring& wsValue, double& dValue, UnitMeasure& enUnitMeasure);
};

View File

@ -2,45 +2,23 @@
namespace NSCSS
{
CSizeWindow::CSizeWindow()
: m_ushWidth(0), m_ushHeight(0)
{}
CSizeWindow::CSizeWindow(unsigned short unWidth, unsigned short unHeight)
: m_ushWidth(unWidth), m_ushHeight(unHeight)
{}
bool CSizeWindow::Empty() const
{
return ((0 == m_ushWidth) && (0 == m_ushHeight));
}
void CSizeWindow::Clear()
{
m_ushWidth = m_ushHeight = 0;
}
bool CSizeWindow::operator==(const CSizeWindow &oSizeWindow) const
{
return ((m_ushWidth == oSizeWindow.m_ushWidth) && (m_ushHeight == oSizeWindow.m_ushHeight));
}
bool CSizeWindow::operator!=(const CSizeWindow &oSizeWindow) const
{
return ((m_ushWidth != oSizeWindow.m_ushWidth) || (m_ushHeight != oSizeWindow.m_ushHeight));
}
bool StatistickElement::operator<(const StatistickElement &oStatistickElement) const
{
return sValue < oStatistickElement.sValue;
}
void CTree::Clear()
{
m_arrChild.clear();
m_oNode.Clear();
}
void CTree::CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics)
{
if (!oTree.m_oNode.m_wsId.empty())
++mStatictics[StatistickElement{StatistickElement::IsId, L'#' + oTree.m_oNode.m_wsId}];
if (!oTree.m_oNode.m_wsStyle.empty())
++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_wsStyle}];
if (!oTree.m_oNode.m_wsStyle.empty())
++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_wsStyle}];
if (!oTree.m_arrChild.empty())
for (const CTree& oChildren : oTree.m_arrChild)
@ -98,7 +76,7 @@ namespace NSCSS
{L"deepskyblue", L"00BFFF"}, {L"dodgerblue", L"1E90FF"}, {L"cornflowerblue",L"6495ED"},
{L"mediumdlateblue", L"7B68EE"}, {L"royalblue", L"4169E1"}, {L"blue", L"0000FF"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"},
{L"mediumblue", L"0000CD"}, {L"darkblue", L"00008B"}, {L"navy", L"000080"},
{L"midnightblue", L"191970"},
{L"midnightblue", L"191970"}, {L"navyblue", L"A0B0E0"},
/* White tones */
{L"white", L"FFFFFF"}, {L"snow", L"FFFAFA"}, {L"honeydew", L"F0FFF0"},
{L"mintcream", L"F5FFFA"}, {L"azure", L"F0FFFF"}, {L"aliceblue", L"F0F8FF"},
@ -110,7 +88,7 @@ namespace NSCSS
{L"gainsboro", L"DCDCDC"}, {L"lightgray", L"D3D3D3"}, {L"silver", L"C0C0C0"},
{L"darkgray", L"A9A9A9"}, {L"gray", L"808080"}, {L"dimgray", L"696969"},
{L"lightslategray", L"778899"}, {L"slategray", L"708090"}, {L"darkslategray", L"2F4F4F"},
{L"black", L"000000"},
{L"black", L"000000"}, {L"grey", L"808080"},
/* Outdated */
{L"windowtext", L"000000"}, {L"transparent", L"000000"}
};

View File

@ -16,21 +16,6 @@ namespace NSCSS
ScalingDirectionY = 2
} ScalingDirection;
struct CSizeWindow
{
unsigned short m_ushWidth;
unsigned short m_ushHeight;
CSizeWindow();
CSizeWindow(unsigned short unWidth, unsigned short unHeight);
bool Empty() const;
void Clear();
bool operator==(const CSizeWindow& oSizeWindow) const;
bool operator!=(const CSizeWindow& oSizeWindow) const;
};
struct StatistickElement
{
enum TypeElement
@ -48,6 +33,8 @@ namespace NSCSS
NSCSS::CNode m_oNode;
std::vector<CTree> m_arrChild;
void Clear();
static void CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics);
};
@ -61,66 +48,69 @@ namespace NSCSS
{
typedef enum
{
B_CustomStyle = 0,
B_StyleId = 1,
B_Type = 2,
B_Default = 3,
B_CustomStyle,
B_StyleId,
B_Type,
B_Default,
B_Name = 4,
B_BasedOn = 5,
B_QFormat = 6,
B_Link = 7,
B_UnhideWhenUsed = 8,
B_UiPriority = 9,
B_Name,
B_BasedOn,
B_QFormat,
B_Link,
B_UnhideWhenUsed,
B_UiPriority,
B_SemiHidden
} BasicProperties;
typedef enum
{
P_Jc = 0,
P_Spacing = 1,
P_ContextualSpacing = 2,
P_Ind = 3,
P_OutlineLvl = 4,
P_Shd = 5,
P_Jc,
P_Spacing,
P_ContextualSpacing,
P_Ind,
P_OutlineLvl,
P_Shd,
// <pBdr>
P_TopBorder = 6,
P_LeftBorder = 7,
P_BottomBorder = 8,
P_RightBorder = 9,
P_TopBorder,
P_LeftBorder,
P_BottomBorder,
P_RightBorder,
// </pBdr>
P_KeepLines = 10,
P_KeepNext = 11,
P_KeepLines,
P_KeepNext,
} ParagraphProperties;
typedef enum
{
R_RFonts = 0,
R_Sz = 1,
R_B = 2,
R_I = 3,
R_Color = 4,
R_U = 5,
R_Highlight = 6,
R_SmallCaps = 7
R_RFonts ,
R_Sz,
R_B,
R_I,
R_Color,
R_U,
R_Highlight,
R_Shd,
R_SmallCaps,
R_Kern
} RunnerProperties;
typedef enum
{
T_TblInd = 0,
T_TblInd ,
// <tblCellMar>
T_CellTop = 1,
T_CellLeft = 2,
T_CellBottom = 3,
T_CellRight = 4,
T_CellTop,
T_CellLeft,
T_CellBottom,
T_CellRight,
// <tblCellMar>
// <tblBorders>
T_BorderTop = 5,
T_BorderLeft = 6,
T_BorderBottom = 7,
T_BorderRight = 8,
T_BorderInsideH = 9,
T_BorderInsideV = 10
T_BorderTop ,
T_BorderLeft,
T_BorderBottom,
T_BorderRight,
T_BorderInsideH,
T_BorderInsideV
// </tblBorders>
} TableProperties;
}

View File

@ -80,6 +80,52 @@ namespace NS_STATIC_FUNCTIONS
return arValues;
}
std::vector<std::wstring> ParseCSSPropertie(const std::wstring& wsInput)
{
std::vector<std::wstring> arResult;
std::wstring wsCurrent;
bool bInQuotes = false;
bool bInFunction = false;
int nParenDepth = 0;
for (wchar_t c : wsInput)
{
if (c == ' ' && !bInQuotes && !bInFunction)
{
if (!wsCurrent.empty())
{
arResult.push_back(wsCurrent);
wsCurrent.clear();
}
}
else if (c == '"' || c == '\'')
{
bInQuotes = !bInQuotes;
wsCurrent += c;
}
else if (c == '(')
{
bInFunction = true;
nParenDepth++;
wsCurrent += c;
}
else if (c == ')')
{
nParenDepth--;
if (nParenDepth == 0)
bInFunction = false;
wsCurrent += c;
}
else
wsCurrent += c;
}
if (!wsCurrent.empty())
arResult.push_back(wsCurrent);
return arResult;
}
std::vector<std::wstring> GetWordsW(const std::wstring& wsLine, bool bWithSigns, const std::wstring& wsDelimiters)
{
if (wsLine.empty())
@ -95,7 +141,9 @@ namespace NS_STATIC_FUNCTIONS
while (std::wstring::npos != unEnd)
{
arWords.emplace_back(wsLine.data() + unStart, unEnd - unStart + ((bWithSigns) ? 1 : 0));
if (unStart != unEnd)
arWords.emplace_back(wsLine.data() + unStart, unEnd - unStart + ((bWithSigns) ? 1 : 0));
unStart = wsLine.find_first_not_of(wsDelimiters, unEnd);
unEnd = wsLine.find_first_of(wsDelimiters, unStart);
}
@ -141,30 +189,17 @@ namespace NS_STATIC_FUNCTIONS
std::map<std::wstring, std::wstring> GetRules(const std::wstring& wsStyles)
{
if (wsStyles.empty())
return {};
std::wregex oCssPropertyRegex(L"([a-zA-Z-]+)\\s*:\\s*([^;\t\n\r\f\v]+)");
std::wsmatch oMatch;
std::wstring::const_iterator oSearchStart(wsStyles.cbegin());
std::map<std::wstring, std::wstring> mRules;
std::wstring::const_iterator oStartProperty = std::find_if_not(wsStyles.begin(), wsStyles.end(), std::iswspace);
std::wstring::const_iterator oEndProperty, oStartValue, oEndValue;
while (wsStyles.end() != oStartProperty)
while (std::regex_search(oSearchStart, wsStyles.cend(), oMatch, oCssPropertyRegex))
{
oEndProperty = std::find_if(oStartProperty, wsStyles.end(), [](const wchar_t &wcChar){ return L':' == wcChar;});
oStartValue = std::find_if_not(oEndProperty + 1, wsStyles.end(), std::iswspace);
if (wsStyles.end() == oEndProperty || wsStyles.end() == oStartValue)
break;
oEndValue = std::find_if(oStartValue, wsStyles.end(), [](const wchar_t &wcChar){ return L';' == wcChar;});
mRules.insert({std::wstring(oStartProperty, oEndProperty), std::wstring(oStartValue, oEndValue)});
if (wsStyles.end() == oEndValue)
break;
oStartProperty = std::find_if_not(oEndValue + 1, wsStyles.end(), std::iswspace);
mRules.insert(std::make_pair<std::wstring, std::wstring>(oMatch[1], oMatch[2]));
oSearchStart = oMatch.suffix().first;
}
return mRules;

View File

@ -20,6 +20,7 @@ namespace NSCSS
double ReadDouble(const std::wstring& wsValue);
std::vector<double> ReadDoubleValues(const std::wstring& wsValue);
std::vector<std::wstring> ParseCSSPropertie(const std::wstring& wsInput);
std::vector<std::wstring> GetWordsW(const std::wstring& wsLine, bool bWithSigns = false, const std::wstring& wsDelimiters = L" \n\r\t\f\v:;,!");
std::vector<unsigned short int> GetWeightSelector(const std::wstring& sSelector);
std::map<std::wstring, std::wstring> GetRules(const std::wstring& wsStyles);

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,8 @@ namespace NSCSS
{
namespace NSProperties
{
#define NEXT_LEVEL UINT_MAX, true
template<typename T>
class CValue
{
@ -21,6 +23,7 @@ namespace NSCSS
friend class CDigit;
friend class CColor;
friend class CEnum;
friend class CURL;
T m_oValue;
unsigned int m_unLevel;
@ -54,6 +57,11 @@ namespace NSCSS
}
}
static bool LevelIsSame(const CValue& oFirstValue, const CValue& oSecondValue)
{
return oFirstValue.m_unLevel == oSecondValue.m_unLevel;
}
bool operator==(const T& oValue) const { return m_oValue == oValue; }
bool operator>=(const T& oValue) const { return m_oValue >= oValue; }
bool operator<=(const T& oValue) const { return m_oValue <= oValue; }
@ -69,28 +77,33 @@ namespace NSCSS
return *this;
}
CValue& operator =(const T& oValue)
virtual CValue& operator =(const T& oValue)
{
//m_oValue = oValue.m_oValue;
return *this;
}
CValue& operator+=(const CValue& oValue)
virtual CValue& operator+=(const CValue& oValue)
{
if (m_unLevel > oValue.m_unLevel || (m_bImportant && !oValue.m_bImportant) || oValue.Empty())
return *this;
m_oValue = oValue.m_oValue;
m_unLevel = std::max(m_unLevel, oValue.m_unLevel);
m_bImportant = std::max(m_bImportant, oValue.m_bImportant);
m_unLevel = oValue.m_unLevel;
m_bImportant = oValue.m_bImportant;
return *this;
}
bool operator==(const CValue& oValue) const
virtual bool operator==(const CValue& oValue) const
{
return m_oValue == oValue.m_oValue;
}
virtual bool operator!=(const CValue& oValue) const
{
return m_oValue != oValue.m_oValue;
}
};
class CString : public CValue<std::wstring>
@ -124,13 +137,15 @@ namespace NSCSS
CDigit(double dValue, unsigned int unLevel, bool bImportant = false);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool SetValue(const CDigit& oValue);
bool SetValue(const double& dValue, unsigned int unLevel, bool bHardMode);
bool Empty() const override;
bool Zero() const;
void Clear() override;
void ConvertTo(UnitMeasure enUnitMeasure, double dPrevValue = 0.);
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
@ -144,6 +159,9 @@ namespace NSCSS
bool operator==(const double& oValue) const;
bool operator==(const CDigit& oDigit) const;
bool operator!=(const double& oValue) const;
bool operator!=(const CDigit& oDigit) const;
CDigit operator+(const CDigit& oDigit) const;
CDigit operator-(const CDigit& oDigit) const;
CDigit operator*(const CDigit& oDigit) const;
@ -169,50 +187,41 @@ namespace NSCSS
bool Empty() const;
bool operator==(const TRGB& oRGB) const;
bool operator!=(const TRGB& oRGB) const;
};
class CURL
{
public:
CURL();
bool Empty() const;
bool LinkToId() const;
void Clear();
bool SetValue(const std::wstring& wsValue);
std::wstring GetValue() const;
bool operator==(const CURL& oValue) const;
bool operator!=(const CURL& oValue) const;
private:
std::wstring m_wsValue;
};
typedef enum
{
ColorEmpty,
ColorNone,
ColorRGB,
ColorHEX,
ColorUrl
ColorUrl,
ColorContextStroke,
ColorContextFill
} ColorType;
class Q_DECL_EXPORT CColorValue
class CColor : public CValue<void*>
{
public:
CColorValue();
CColorValue(const CColorValue& oColorValue);
~CColorValue();
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
void SetRGB(const TRGB& oRGB);
void SetHEX(const std::wstring& wsValue);
void SetUrl(const std::wstring& wsValue);
void SetNone();
void Clear();
bool Empty() const;
ColorType m_enType;
void* m_pColor = NULL;
std::wstring GetColor() const;
bool operator==(const CColorValue& oColorValue) const;
CColorValue& operator= (const CColorValue& oColorValue);
};
class CColor : public CValue<CColorValue>
{
CDigit m_oOpacity;
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
static std::wstring CutURL(const std::wstring& wsValue);
void SetEmpty(unsigned int unLevel = 0);
public:
CColor();
@ -220,6 +229,8 @@ namespace NSCSS
bool SetOpacity(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true);
bool Empty() const override;
bool None() const;
bool Url() const;
void Clear() override;
ColorType GetType() const;
@ -229,7 +240,27 @@ namespace NSCSS
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
std::wstring EquateToColor(const std::vector<std::pair<TRGB, std::wstring>>& arColors) const;
TRGB ToRGB() const;
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
bool operator==(const CColor& oColor) const;
bool operator!=(const CColor& oColor) const;
CColor& operator =(const CColor& oColor);
CColor& operator+=(const CColor& oColor);
private:
CDigit m_oOpacity;
ColorType m_enType;
void SetEmpty(unsigned int unLevel = 0);
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
void SetRGB(const TRGB& oRGB);
void SetHEX(const std::wstring& wsValue);
void SetUrl(const std::wstring& wsValue);
void SetNone();
};
typedef enum
@ -277,7 +308,7 @@ namespace NSCSS
CEnum();
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
void SetMapping(const std::map<std::wstring, int>& mMap);
void SetMapping(const std::map<std::wstring, int>& mMap, int nDefaulvalue = -1);
bool Empty() const override;
void Clear() override;
@ -370,19 +401,18 @@ namespace NSCSS
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetBackground(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void InBorder();
const CColor& GetColor() const;
bool IsInBorder() const;
bool Empty() const;
void Clear();
bool Empty() const;
bool IsNone() const;
CBackground& operator =(const CBackground& oBackground);
CBackground& operator+=(const CBackground& oBackground);
bool operator==(const CBackground& oBackground) const;
private:
CColor m_oColor;
bool m_bInBorder;
};
class CTransform
@ -397,6 +427,11 @@ namespace NSCSS
bool SetMatrix(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetMatrix(const Aggplus::CMatrix &oMatrix);
void Translate(double dOffsetX, double dOffsetY);
void Scale(double dScaleX, double dScaleY);
void Rotate(double dValue);
void RotateAt(double dValue, double dX, double dY);
const CMatrix& GetMatrix() const;
bool Empty() const;
@ -411,14 +446,20 @@ namespace NSCSS
{
public:
CBorderSide();
CBorderSide(const CBorderSide& oBorderSide);
void Clear();
static void Equation(CBorderSide &oFirstBorderSide, CBorderSide &oSecondBorderSide);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void SetNone(unsigned int unLevel, bool bHardMode);
void Block();
void Unblock();
@ -429,9 +470,13 @@ namespace NSCSS
const CColor& GetColor() const;
bool Empty() const;
bool Zero() const;
bool Valid() const;
CBorderSide& operator+=(const CBorderSide& oBorderSide);
bool operator==(const CBorderSide& oBorderSide) const;
bool operator!=(const CBorderSide& oBorderSide) const;
CBorderSide& operator =(const CBorderSide& oBorderSide);
private:
CDigit m_oWidth;
CString m_oStyle;
@ -440,48 +485,71 @@ namespace NSCSS
bool m_bBlock;
};
typedef enum
{
Collapse,
Separate
} BorderCollapse;
class CBorder
{
public:
CBorder();
void Clear();
void ClearLeftSide();
void ClearTopSide();
void ClearRightSide();
void ClearBottomSide();
static void Equation(CBorder &oFirstBorder, CBorder &oSecondBorder);
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetCollapse(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Left Side
bool SetLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthLeftSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyleLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Top Side
bool SetTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthTopSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyleTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Right Side
bool SetRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthRightSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyleRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
//Bottom Side
bool SetBottomSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWidthBottomSide(const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetStyleBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColorBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void SetNone(unsigned int unLevel, bool bHardMode = false);
void Block();
void Unblock();
bool Empty() const;
bool Zero() const;
bool EqualSides() const;
const CEnum& GetCollapse() const;
const CBorderSide& GetLeftBorder() const;
const CBorderSide& GetTopBorder() const;
const CBorderSide& GetRightBorder() const;
@ -489,11 +557,15 @@ namespace NSCSS
CBorder& operator+=(const CBorder& oBorder);
bool operator==(const CBorder& oBorder) const;
bool operator!=(const CBorder& oBorder) const;
CBorder& operator =(const CBorder& oBorder);
private:
CBorderSide m_oLeft;
CBorderSide m_oTop;
CBorderSide m_oRight;
CBorderSide m_oBottom;
CEnum m_enCollapse;
};
class CTextDecorationLine
@ -513,6 +585,7 @@ namespace NSCSS
bool LineThrough() const;
CTextDecorationLine &operator+=(const CTextDecorationLine& oTextDecoration);
bool operator==(const CTextDecorationLine& oTextDecorationLine) const;
};
struct TTextDecoration
@ -522,6 +595,7 @@ namespace NSCSS
CColor m_oColor;
TTextDecoration& operator+=(const TTextDecoration& oTextDecoration);
bool operator==(const TTextDecoration& oTextDecoration) const;
};
class CText
@ -535,11 +609,13 @@ namespace NSCSS
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetDecoration(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
const CDigit& GetIndent() const;
const CString& GetAlign() const;
const TTextDecoration& GetDecoration() const;
const CColor& GetColor() const;
const CColor& GetHighlight() const;
bool Empty() const;
@ -554,6 +630,7 @@ namespace NSCSS
CDigit m_oIndent;
CString m_oAlign;
CColor m_oColor;
CColor m_oHighlight;
};
class CIndent
@ -561,33 +638,44 @@ namespace NSCSS
public:
CIndent();
void Clear();
static void Equation(CIndent &oFirstMargin, CIndent &oSecondMargin);
bool Equals() const;
void SetPermisson(bool bPermission);
bool AddValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddTop (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddRight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool AddBottom (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void UpdateAll(double dFontSize);
void UpdateLeft(double dFontSize);
void UpdateTop(double dFontSize);
void UpdateRight(double dFontSize);
void UpdateBottom(double dFontSize);
bool SetValues (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetTop (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetTop (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetRight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetRight (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetBottom (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetBottom (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetLeft (const double& dValue, unsigned int unLevel, bool bHardMode = false);
void UpdateAll (const double& dParentFontSize, const double& dCoreFontSize);
void UpdateTop (const double& dParentFontSize, const double& dCoreFontSize);
void UpdateRight (const double& dParentFontSize, const double& dCoreFontSize);
void UpdateBottom(const double& dParentFontSize, const double& dCoreFontSize);
void UpdateLeft (const double& dParentFontSize, const double& dCoreFontSize);
const CDigit& GetLeft () const;
const CDigit& GetTop () const;
const CDigit& GetRight () const;
const CDigit& GetBottom() const;
const CDigit& GetLeft () const;
bool Empty() const;
bool Zero() const;
CIndent& operator+=(const CIndent& oMargin);
bool operator==(const CIndent& oMargin) const;
CIndent& operator+=(const CIndent& oIndent);
bool operator==(const CIndent& oIndent) const;
bool operator!=(const CIndent& oIndent) const;
private:
bool AddValue(CDigit& oValue, const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetValues(const std::wstring& wsTopValue, const std::wstring& wsRightValue, const std::wstring& wsBottomValue, const std::wstring& wsLeftValue, unsigned int unLevel, bool bHardMode = false);
void UpdateSide(CDigit& oSide, const double& dParentFontSize, const double& dCoreFontSize);
CDigit m_oLeft;
CDigit m_oTop;
@ -606,6 +694,7 @@ namespace NSCSS
bool SetValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetSize (const double& dValue, unsigned int unLevel, bool bHardMode = false);
bool SetLineHeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetFamily (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetStretch (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
@ -613,8 +702,8 @@ namespace NSCSS
bool SetVariant (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetWeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
void UpdateSize(double dFontSize);
void UpdateLineHeight(double dFontSize);
void UpdateSize(const double& dParentFontSize, const double& dCoreFontSize);
void UpdateLineHeight(const double& dParentFontSize, const double& dCoreFontSize);
void Clear();
@ -623,6 +712,7 @@ namespace NSCSS
const CDigit& GetSize() const;
const CDigit& GetLineHeight() const;
CDigit& GetLineHeight();
const CString& GetFamily() const;
const CString& GetStretch() const;
const CString& GetStyle() const;
@ -642,8 +732,29 @@ namespace NSCSS
CString m_oStyle;
CString m_oVariant;
CString m_oWeight;
};
TTextDecoration m_oTextDecoration;
class CPage
{
public:
CPage();
bool SetMargin (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetFooter (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHeader (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
const CDigit& GetWidth() const;
const CDigit& GetHeight() const;
const CIndent& GetMargin() const;
const CDigit& GetFooter() const;
const CDigit& GetHeader() const;
private:
CDigit m_oWidth;
CDigit m_oHeight;
CIndent m_oMargin;
CDigit m_oFooter;
CDigit m_oHeader;
};
}
}

View File

@ -1,19 +1,20 @@
#include "CDocumentStyle.h"
#include <iostream>
#include <unordered_set>
#include <wchar.h>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <list>
#define DEFAULT_LINEHEIGHT 240
#define LINEHEIGHTSCALE 10 // Значение LineHeight в OOXML должно быть в 10 раз больше чем указано в стиле
#define LINEHEIGHTCOEF 24 // Используется когда необходимо перевести в twips значение
#define POINTCOEF 20 // Используется для конвертации в OOXML значение интервала между абзацами (Измерение в двадцатых долях от точки)
#define PAGEWIDTH (12240 / POINTCOEF)
#define PAGEHEIGHT (15840 / POINTCOEF)
#define DOUBLE_TO_INTW(dValue) std::to_wstring(static_cast<int>(dValue + 0.5))
#define VALUE_TO_INT(value, unit_measure) \
(NSCSS::UnitMeasure::None != value.GetUnitMeasure()) ? \
value.ToInt(unit_measure) : \
static_cast<int>(NSCSS::CUnitMeasureConverter::ConvertPx(value.ToDouble(), unit_measure, 96) + 0.5)
namespace NSCSS
{
@ -21,24 +22,55 @@ namespace NSCSS
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
{}
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
{
std::unordered_set<std::wstring> arInitialSet(arInitial.begin(), arInitial.end());
std::vector<std::wstring> arCommonElements1;
std::vector<std::wstring> arCommonElements2;
for (const std::wstring& wsValue : arFirst)
{
if (arInitialSet.count(wsValue) > 0)
arCommonElements1.push_back(wsValue);
}
for (const std::wstring& wsValue : arSecond)
{
if (arInitialSet.count(wsValue) > 0)
arCommonElements2.push_back(wsValue);
}
if (arCommonElements1.size() != arCommonElements2.size())
return false;
std::sort(arCommonElements1.begin(), arCommonElements1.end());
std::sort(arCommonElements2.begin(), arCommonElements2.end());
return arCommonElements1 == arCommonElements2;
}
bool CStyleUsed::operator==(const CStyleUsed &oUsedStyle) const
{
return (m_bIsPStyle == oUsedStyle.m_bIsPStyle) && (m_oStyle == oUsedStyle.m_oStyle);
return m_bIsPStyle == oUsedStyle.m_bIsPStyle &&
CheckArrays(Names_Standard_Styles, m_oStyle.GetParentsNamesSet(), oUsedStyle.m_oStyle.GetParentsNamesSet()) &&
m_oStyle == oUsedStyle.m_oStyle;
}
std::wstring CStyleUsed::getId()
{
return m_sId;
if (m_bIsPStyle)
return m_oStyle.GetId();
return m_oStyle.GetId() + L"-c";
}
void CStyleUsed::setId(const std::wstring &sId)
CDocumentStyle::CDocumentStyle() : m_arStandardStyles(Names_Standard_Styles)
{
m_sId = sId;
for (const std::wstring& oNameStandardStyle : Names_Standard_Styles)
m_arStandardStyles.push_back(oNameStandardStyle + L"-c");
}
CDocumentStyle::CDocumentStyle() : m_arStandardStyles({L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6", L"h1-c",
L"h2-c", L"h3-c", L"h4-c", L"h5-c", L"h6-c", L"p-c", L"p", L"div-c", L"div", L"a-c"}) {}
CDocumentStyle::~CDocumentStyle()
{
m_arStandardStyles. clear();
@ -157,6 +189,7 @@ namespace NSCSS
if (!oParentStyle.Empty())
{
oParentStyle.AddBasicProperties(BProperties::B_BasedOn, L"normal");
oParentStyle.AddBasicProperties(BProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")");
if (!bIsPStyle)
{
@ -271,250 +304,308 @@ namespace NSCSS
oElement.AddBasicProperties(BProperties::B_CustomStyle, L"1");
}
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
{
ConvertStyle(oStyle, oXmlElement, true);
if (oStyle.Empty() && oXmlElement.Empty())
if (!bIsLite)
ConvertStyle(oStyle, oXmlElement, true);
if (oStyle.Empty())
return;
oXmlElement.AddPropertiesInP(PProperties::P_Jc, oStyle.m_oText.GetAlign().ToWString());
const bool bInTable{oStyle.HaveThisParent(L"table")};
std::wstring wsTextAlign{oStyle.m_oText.GetAlign().ToWString()};
if (wsTextAlign.empty() && bInTable)
wsTextAlign = oStyle.m_oDisplay.GetHAlign().ToWString();
oXmlElement.AddPropertiesInP(PProperties::P_Jc, wsTextAlign);
std::wstring sInfValue;
sInfValue.reserve(64);
//TODO:: проверить Permission в Margin
if (!oStyle.m_oMargin.Empty() || !oStyle.m_oPadding.Empty() /*&& oStyle.m_oMargin.GetPermission()*/)
{
const double dLeftSide = oStyle.m_oMargin.GetLeft() .ToDouble(NSCSS::Twips) + oStyle.m_oPadding.GetLeft() .ToDouble(NSCSS::Twips);
const double dRightSide = oStyle.m_oMargin.GetRight().ToDouble(NSCSS::Twips) + oStyle.m_oPadding.GetRight().ToDouble(NSCSS::Twips);
if (!oStyle.m_oMargin.GetLeft().Empty() && !oStyle.m_oMargin.GetLeft().Zero())
sInfValue += L"w:left=\"" + std::to_wstring(oStyle.m_oMargin.GetLeft().ToInt(NSCSS::Twips)) + L"\" ";
sInfValue += L"w:left=\"" + DOUBLE_TO_INTW(dLeftSide * POINTCOEF) + L"\" ";
sInfValue += L"w:right=\"" + DOUBLE_TO_INTW(dRightSide * POINTCOEF) + L"\" ";
}
if (!oStyle.m_oMargin.GetRight().Empty() && !oStyle.m_oMargin.GetRight().Zero())
sInfValue += L"w:right=\"" + std::to_wstring(oStyle.m_oMargin.GetRight().ToInt(NSCSS::Twips)) + L"\" ";
const double dIndent = oStyle.m_oText.GetIndent().ToDouble(NSCSS::Twips);
if (0. != dIndent)
sInfValue += L"w:firstLine=\"" + DOUBLE_TO_INTW(dIndent) + L"\" ";
const int nIndent = oStyle.m_oText.GetIndent().ToInt(NSCSS::Twips);
if (0 != nIndent)
sInfValue += L"w:firstLine=\"" + std::to_wstring(nIndent) + L"\" ";
oXmlElement.AddPropertiesInP(PProperties::P_Ind, sInfValue);
std::wstring sSpacingValue;
sSpacingValue.reserve(128);
//TODO:: проверить Permission в Margin
if (!oStyle.m_oMargin.Empty() || !oStyle.m_oPadding.Empty()/*&& oStyle.m_oMargin.GetPermission()*/)
{
const double dSpacingBottom = oStyle.m_oMargin.GetBottom().ToDouble(NSCSS::Twips) + oStyle.m_oPadding.GetBottom().ToDouble(NSCSS::Twips);
const double dSpacingTop = oStyle.m_oMargin.GetTop() .ToDouble(NSCSS::Twips) + oStyle.m_oPadding.GetTop() .ToDouble(NSCSS::Twips);;
sSpacingValue += L" w:after=\"" + DOUBLE_TO_INTW(dSpacingBottom * POINTCOEF) + L"\" ";
sSpacingValue += L" w:before=\"" + DOUBLE_TO_INTW(dSpacingTop * POINTCOEF) + L"\" ";
}
else/* if (!oStyle.m_pBorder.Empty() || !oStyle.m_oMargin.GetPermission())*/
sSpacingValue += L"w:after=\"0\" w:before=\"0\"";
if (!oStyle.m_oMargin.GetTop().Empty() && !oStyle.m_oMargin.GetTop().Zero())
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"0\"";
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
sSpacingValue += L"w:before=\"0\" w:beforeAutospacing=\"0\"";
std::wstring wsLineHeight;
if (!oStyle.m_oFont.GetLineHeight().Empty())
{
double dLineHeight = oStyle.m_oFont.GetLineHeight().ToDouble(NSCSS::Twips, LINEHEIGHTCOEF) * LINEHEIGHTSCALE;
if (!oStyle.m_oMargin.GetBottom().Empty() && !oStyle.m_oMargin.GetBottom().Zero())
sSpacingValue += L" w:after=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetBottom(), NSCSS::Twips)) + L"\" w:afterAutospacing=\"0\"";
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
sSpacingValue += L" w:after=\"0\" w:afterAutospacing=\"0\"";
if (NSCSS::None == oStyle.m_oFont.GetLineHeight().GetUnitMeasure())
dLineHeight *= LINEHEIGHTCOEF;
if (0. != dLineHeight)
wsLineHeight = DOUBLE_TO_INTW(dLineHeight);
}
if (!wsLineHeight.empty())
if (!oStyle.m_oFont.GetLineHeight().Empty() && !oStyle.m_oFont.GetLineHeight().Zero())
{
sSpacingValue += L" w:line=\"" + wsLineHeight + L"\" w:lineRule=\"auto\"";
const std::wstring wsLine{std::to_wstring(oStyle.m_oFont.GetLineHeight().ToInt(NSCSS::Twips, DEFAULT_LINEHEIGHT))};
const std::wstring wsLineRule{(NSCSS::Percent == oStyle.m_oFont.GetLineHeight().GetUnitMeasure() ? L"auto" : L"atLeast")};
sSpacingValue += L" w:line=\"" + wsLine + L"\" w:lineRule=\"" + wsLineRule + L"\"";
}
// else if (!oStyle.m_oBorder.Empty())
// {
// sSpacingValue += L" w:line=\"" + std::to_wstring(static_cast<short int>(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Twips) * 2 * POINTCOEF + 0.5f)) + L"\" w:lineRule=\"auto\"";
// }
else if (!oStyle.m_oBorder.Empty())
sSpacingValue += L" w:line=\"240\" w:lineRule=\"auto\" ";
else if (oStyle.m_oFont.GetLineHeight().Zero() || bInTable)
sSpacingValue += L" w:lineRule=\"auto\" w:line=\"240\"";
if (!sSpacingValue.empty())
{
oXmlElement.AddPropertiesInP(PProperties::P_Spacing, sSpacingValue);
oXmlElement.AddPropertiesInP(PProperties::P_ContextualSpacing, L"true");
}
if (!oStyle.m_oBackground.Empty())
{
const std::wstring wsColor = oStyle.m_oBackground.GetColor().ToWString();
if (wsColor != L"ffffff")
oXmlElement.AddPropertiesInP(PProperties::P_Shd, wsColor);
}
if (!oStyle.m_oBackground.Empty() && !bInTable)
oXmlElement.AddPropertiesInP(PProperties::P_Shd, oStyle.m_oBackground.IsNone() ? L"auto" : oStyle.m_oBackground.GetColor().ToWString());
if (!oStyle.m_oBorder.Empty())
if (!oStyle.m_oBorder.Empty() && !bInTable)
{
if (oStyle.m_oBorder.EqualSides())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetLeftBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetLeftBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetLeftBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"0\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(PProperties::P_TopBorder, sBorder);
oXmlElement.AddPropertiesInP(PProperties::P_LeftBorder, sBorder);
oXmlElement.AddPropertiesInP(PProperties::P_BottomBorder, sBorder);
oXmlElement.AddPropertiesInP(PProperties::P_RightBorder, sBorder);
SetBorderStyle(oStyle, oXmlElement, PProperties::P_TopBorder);
SetBorderStyle(oStyle, oXmlElement, PProperties::P_LeftBorder);
SetBorderStyle(oStyle, oXmlElement, PProperties::P_BottomBorder);
SetBorderStyle(oStyle, oXmlElement, PProperties::P_RightBorder);
}
else
{
if (!oStyle.m_oBorder.GetTopBorder().Empty())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetTopBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetTopBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetTopBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(PProperties::P_TopBorder, sBorder);
}
SetBorderStyle(oStyle, oXmlElement, PProperties::P_TopBorder);
if (!oStyle.m_oBorder.GetRightBorder().Empty())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetRightBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetRightBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetRightBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(PProperties::P_RightBorder, sBorder);
}
SetBorderStyle(oStyle, oXmlElement, PProperties::P_RightBorder);
if (!oStyle.m_oBorder.GetBottomBorder().Empty())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetBottomBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetBottomBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetBottomBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(PProperties::P_BottomBorder, sBorder);
}
SetBorderStyle(oStyle, oXmlElement, PProperties::P_BottomBorder);
if (!oStyle.m_oBorder.GetLeftBorder().Empty())
{
const std::wstring sBorderColor = oStyle.m_oBorder.GetLeftBorder().GetColor().ToWString();
const std::wstring sBorderStyle = oStyle.m_oBorder.GetLeftBorder().GetStyle().ToWString();
const std::wstring sBorderWidth = oStyle.m_oBorder.GetLeftBorder().GetWidth().ToWString();
const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" +
sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\"";
oXmlElement.AddPropertiesInP(PProperties::P_LeftBorder, sBorder);
}
SetBorderStyle(oStyle, oXmlElement, PProperties::P_LeftBorder);
}
}
}
void CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
void CDocumentStyle::SetBorderStyle(const CCompiledStyle &oStyle, CXmlElement &oXmlElement, const PProperties &enBorderProperty)
{
ConvertStyle(oStyle, oXmlElement, false);
const NSCSS::NSProperties::CBorderSide* pBorder = NULL;
const NSCSS::NSProperties::CDigit* pPadding = NULL;
switch(enBorderProperty)
{
case PProperties::P_BottomBorder:
{
pBorder = &oStyle.m_oBorder.GetBottomBorder();
pPadding = &oStyle.m_oPadding.GetBottom();
break;
}
case PProperties::P_LeftBorder:
{
pBorder = &oStyle.m_oBorder.GetLeftBorder();
pPadding = &oStyle.m_oPadding.GetLeft();
break;
}
case PProperties::P_RightBorder:
{
pBorder = &oStyle.m_oBorder.GetRightBorder();
pPadding = &oStyle.m_oPadding.GetRight();
break;
}
case PProperties::P_TopBorder:
{
pBorder = &oStyle.m_oBorder.GetTopBorder();
pPadding = &oStyle.m_oPadding.GetTop();
break;
}
default:
return;
}
oXmlElement.AddPropertiesInP(enBorderProperty, CalculateBorderStyle(*pBorder, pPadding));
}
std::wstring CDocumentStyle::CalculateBorderStyle(const NSProperties::CBorderSide &oBorder, const NSProperties::CDigit *pPadding)
{
if (oBorder.Empty())
return L"";
std::wstring wsColor = oBorder.GetColor().ToWString();
std::wstring wsStyle = oBorder.GetStyle().ToWString();
int nWidth = static_cast<int>(std::round(oBorder.GetWidth().ToDouble(Point) * 8.));
if (L"double" == wsStyle)
nWidth /= 3; // в ooxml double граница формируется из трёх линий
if (nWidth <= 3)
nWidth = 2;
else if (nWidth <= 5)
nWidth = 4;
else if (nWidth <= 7)
nWidth = 6;
else if (nWidth <= 9)
nWidth = 8;
else if (nWidth <= 15)
nWidth = 12;
else if (nWidth <= 21)
nWidth = 18;
else if (nWidth <= 29)
nWidth = 24;
else if (nWidth <= 41)
nWidth = 36;
else
nWidth = 48;
if (wsColor.empty())
wsColor = L"auto";
if (wsStyle.empty())
wsStyle = L"single";
int nSpace{0};
if (NULL != pPadding && !pPadding->Empty() && !pPadding->Zero())
nSpace = pPadding->ToInt(NSCSS::Point);
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
}
void CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
{
if (!bIsLite)
ConvertStyle(oStyle, oXmlElement, false);
if (oStyle.Empty() && oXmlElement.Empty())
return;
if (!oStyle.m_oFont.GetSize().Empty())
oXmlElement.AddPropertiesInR(RProperties::R_Sz, DOUBLE_TO_INTW(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Twips)));
oXmlElement.AddPropertiesInR(RProperties::R_Sz, std::to_wstring(static_cast<int>(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Point) * 2. + 0.5))); // Значения шрифта увеличивает на 2
if (oStyle.m_oText.GetDecoration().m_oLine.Underline())
oXmlElement.AddPropertiesInR(RProperties::R_U, (!oStyle.m_oText.GetDecoration().m_oStyle.Empty()) ? oStyle.m_oText.GetDecoration().m_oStyle.ToWString() : L"single");
if (!oStyle.m_oBackground.GetColor().Empty() && !oStyle.m_oBackground.GetColor().None() && !oStyle.m_oBackground.GetColor().Url())
oXmlElement.AddPropertiesInR(RProperties::R_Shd, oStyle.m_oBackground.GetColor().ToWString());
const std::wstring wsHighlight{oStyle.m_oText.GetHighlight().EquateToColor({{{0, 0, 0}, L"black"}, {{0, 0, 255}, L"blue"}, {{0, 255, 255}, L"cyan"},
{{0, 255, 0}, L"green"}, {{255, 0, 255}, L"magenta"}, {{255, 0, 0}, L"red"},
{{255, 255, 0}, L"yellow"}, {{255, 255, 255}, L"white"}, {{0, 0, 139}, L"darkBlue"},
{{0, 139, 139}, L"darkCyan"}, {{0, 100, 0}, L"darkGreen"}, {{139, 0, 139}, L"darkMagenta"},
{{139, 0, 0}, L"darkRed"}, {{128, 128, 0}, L"darkYellow"},{{169, 169, 169}, L"darkGray"},
{{211, 211, 211}, L"lightGray"}})};
if (L"none" != wsHighlight)
oXmlElement.AddPropertiesInR(RProperties::R_Highlight, wsHighlight);
oXmlElement.AddPropertiesInR(RProperties::R_Highlight, oStyle.m_oBackground.GetColor().ToWString());
oXmlElement.AddPropertiesInR(RProperties::R_Color, oStyle.m_oText.GetColor().ToWString());
oXmlElement.AddPropertiesInR(RProperties::R_U, (oStyle.m_oText.GetDecoration().m_oLine.Underline()) ? L"underline" : L"");
std::wstring wsFontFamily{oStyle.m_oFont.GetFamily().ToWString()};
if (L"sans-serif" == wsFontFamily)
wsFontFamily = L"Arial";
else if (L"serif" == wsFontFamily)
wsFontFamily = L"Times New Roman";
oXmlElement.AddPropertiesInR(RProperties::R_RFonts, oStyle.m_oFont.GetFamily().ToWString());
oXmlElement.AddPropertiesInR(RProperties::R_I, oStyle.m_oFont.GetStyle().ToWString());
oXmlElement.AddPropertiesInR(RProperties::R_B, oStyle.m_oFont.GetWeight().ToWString());
oXmlElement.AddPropertiesInR(RProperties::R_SmallCaps, oStyle.m_oFont.GetVariant().ToWString());
}
void CDocumentStyle::WriteRStyle (const NSCSS::CCompiledStyle& oStyle)
bool CDocumentStyle::WriteRStyle(const NSCSS::CCompiledStyle& oStyle)
{
Clear();
if(oStyle.GetId().empty())
{
m_sId = L"normal";
return;
}
return false;
CStyleUsed structStyle(oStyle, false);
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
std::vector<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
if (oItem != m_arStyleUsed.end())
{
m_sId = (*oItem).getId();
return;
return true;
}
CXmlElement oXmlElement;
SetRStyle(oStyle, oXmlElement);
if (!oStyle.Empty() || !oXmlElement.Empty())
{
structStyle.setId(oXmlElement.GetStyleId());
m_arStyleUsed.push_back(structStyle);
m_sStyle += oXmlElement.GetRStyle();
}
}
void CDocumentStyle::WriteLitePStyle(const CCompiledStyle &oStyle)
{
if (oStyle.Empty())
return;
CXmlElement oXmlElement;
SetPStyle(oStyle, oXmlElement);
if (!oXmlElement.Empty())
m_sStyle += oXmlElement.GetPStyle(true);
}
void CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle)
{
if (oStyle.Empty())
return;
CXmlElement oXmlElement;
SetRStyle(oStyle, oXmlElement);
if (!oXmlElement.Empty())
m_sStyle += oXmlElement.GetRStyle(true);
if (oXmlElement.Empty())
return false;
m_arStyleUsed.push_back(structStyle);
m_sStyle += oXmlElement.GetRStyle();
return true;
}
void CDocumentStyle::WritePStyle (const NSCSS::CCompiledStyle& oStyle)
bool CDocumentStyle::WriteLitePStyle(const CCompiledStyle &oStyle)
{
Clear();
if (oStyle.Empty())
return false;
CXmlElement oXmlElement;
SetPStyle(oStyle, oXmlElement, true);
if (oXmlElement.Empty())
return false;
m_sStyle += oXmlElement.GetPStyle(true);
return true;
}
bool CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle)
{
Clear();
if (oStyle.Empty())
return false;
CXmlElement oXmlElement;
SetRStyle(oStyle, oXmlElement, true);
if (oXmlElement.Empty())
return false;
m_sStyle += oXmlElement.GetRStyle(true);
return true;
}
bool CDocumentStyle::WritePStyle(const NSCSS::CCompiledStyle& oStyle)
{
Clear();
if(oStyle.GetId().empty())
{
m_sId = L"normal";
return;
}
return false;
CStyleUsed structStyle(oStyle, true);
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
std::vector<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
if (oItem != m_arStyleUsed.end())
{
m_sId = (*oItem).getId();
return;
return true;
}
CXmlElement oXmlElement;
SetPStyle(oStyle, oXmlElement);
if (!oStyle.Empty() || !oXmlElement.Empty())
{
structStyle.setId(oXmlElement.GetStyleId());
m_arStyleUsed.push_back(structStyle);
m_sStyle += oXmlElement.GetPStyle();
}
if (oXmlElement.Empty())
return false;
m_arStyleUsed.push_back(structStyle);
m_sStyle += oXmlElement.GetPStyle();
return true;
}
}

View File

@ -12,7 +12,6 @@ namespace NSCSS
{
CCompiledStyle m_oStyle;
bool m_bIsPStyle;
std::wstring m_sId;
public:
CStyleUsed(const CCompiledStyle& oStyle, bool bIsPStyle);
@ -20,18 +19,19 @@ namespace NSCSS
bool operator==(const CStyleUsed& oUsedStyle) const;
std::wstring getId();
void setId(const std::wstring& sId);
};
static const std::vector<std::wstring> Names_Standard_Styles = {L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6",L"p", L"div"};
class CSSCALCULATOR_EXPORT CDocumentStyle
{
typedef NSConstValues::NSProperties::BasicProperties BProperties;
typedef NSConstValues::NSProperties::ParagraphProperties PProperties;
typedef NSConstValues::NSProperties::RunnerProperties RProperties;
std::list<std::wstring> m_arStandardStylesUsed;
std::list<std::wstring> m_arStandardStyles;
std::list<CStyleUsed> m_arStyleUsed;
std::vector<std::wstring> m_arStandardStylesUsed;
std::vector<std::wstring> m_arStandardStyles;
std::vector<CStyleUsed> m_arStyleUsed;
std::wstring m_sStyle;
std::wstring m_sId;
@ -40,17 +40,18 @@ namespace NSCSS
void CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
void ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
void SetBorderStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, const PProperties& enBorderProperty);
public:
CDocumentStyle();
~CDocumentStyle();
void WritePStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteRStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteLitePStyle(const NSCSS::CCompiledStyle& oStyle);
void WriteLiteRStyle(const NSCSS::CCompiledStyle& oStyle);
bool WritePStyle(const NSCSS::CCompiledStyle& oStyle);
bool WriteRStyle(const NSCSS::CCompiledStyle& oStyle);
bool WriteLitePStyle(const NSCSS::CCompiledStyle& oStyle);
bool WriteLiteRStyle(const NSCSS::CCompiledStyle& oStyle);
void SetStyle(const std::wstring& sStyle);
void SetId (const std::wstring& sId);
@ -59,6 +60,8 @@ namespace NSCSS
std::wstring GetIdAndClear();
void Clear();
static std::wstring CalculateBorderStyle(const NSCSS::NSProperties::CBorderSide& oBorder, const NSCSS::NSProperties::CDigit* pPadding = NULL);
};
}
#endif // CDOCUMENTSTYLE_H

View File

@ -27,7 +27,7 @@ CXmlElement::CXmlElement(const std::wstring& sNameDefaultElement)
bool CXmlElement::Empty() const
{
return m_mBasicValues.empty() && m_mPStyleValues.empty() && m_mRStyleValues.empty();
return m_mPStyleValues.empty() && m_mRStyleValues.empty() && GetBasedOn().empty();
}
void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
@ -35,7 +35,19 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
if (!Empty())
Clear();
if (sNameDefaultElement == L"li")
/* if (sNameDefaultElement == L"p")
{
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"paragraph");
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"p");
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Normal (Web)");
AddBasicProperties(CSSProperties::BasicProperties::B_BasedOn, L"normal");
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"99");
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_SemiHidden, L"true");
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
}
else */if (sNameDefaultElement == L"li")
{
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"paragraph");
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"li");
@ -55,7 +67,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1-c");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"0");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"480\"");
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
}
else if (sNameDefaultElement == L"h2")
{
@ -66,7 +78,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h2-c");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"1");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"400\"");
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
}
else if (sNameDefaultElement == L"h3")
{
@ -77,7 +89,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h3-c");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"2");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"360\"");
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
}
else if (sNameDefaultElement == L"h4")
{
@ -88,7 +100,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h4-c");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"3");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"320\"");
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
}
else if (sNameDefaultElement == L"h5")
{
@ -99,7 +111,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h5-c");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"4");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"280\"");
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
}
else if (sNameDefaultElement == L"h6")
@ -111,7 +123,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h6-c");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"5");
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"280\"");
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
}
else if (sNameDefaultElement == L"h1-c")
{
@ -122,9 +134,9 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"44");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"48");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Kern, L"36");
}
else if (sNameDefaultElement == L"h2-c")
{
@ -136,9 +148,8 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h2");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"33");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"36");
}
else if (sNameDefaultElement == L"h3-c")
{
@ -150,9 +161,8 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h3");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"26");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"27");
}
else if (sNameDefaultElement == L"h4-c")
{
@ -164,9 +174,8 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h4");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"24");
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"22");
}
else if (sNameDefaultElement == L"h5-c")
{
@ -178,9 +187,8 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h5");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"20");
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"18");
}
else if (sNameDefaultElement == L"h6-c")
{
@ -192,38 +200,16 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h6");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"15");
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
}
else if (sNameDefaultElement == L"p-c")
{
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"p-c");
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Paragraph character");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"p");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
}
else if (sNameDefaultElement == L"p")
{
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"paragraph");
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"p");
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Paragraph");
AddBasicProperties(CSSProperties::BasicProperties::B_BasedOn, L"normal");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"p-c");
}
else if (sNameDefaultElement == L"div-c")
/*else if (sNameDefaultElement == L"div-c")
{
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"div-c");
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Div character");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"div");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
}
else if (sNameDefaultElement == L"div")
{
@ -233,7 +219,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Div paragraph");
AddBasicProperties(CSSProperties::BasicProperties::B_BasedOn, L"normal");
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"div-c");
}
}*/
else if (sNameDefaultElement == L"a-c")
{
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
@ -242,9 +228,9 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"99");
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"24");
AddPropertiesInR(CSSProperties::RunnerProperties::R_Color, L"0000FF");
AddPropertiesInR(CSSProperties::RunnerProperties::R_U, L"single");
AddPropertiesInR(CSSProperties::RunnerProperties::R_RFonts, DEFAULTFONTNAME);
}
else if (sNameDefaultElement == L"a")
{
@ -312,7 +298,7 @@ CXmlElement& CXmlElement::operator=(const CXmlElement& oElement)
return *this;
}
bool CXmlElement::operator==(const CXmlElement &oElement)
bool CXmlElement::operator==(const CXmlElement &oElement) const
{
return m_mBasicValues == oElement.m_mBasicValues &&
m_mPStyleValues == oElement.m_mPStyleValues &&
@ -364,22 +350,22 @@ std::wstring CXmlElement::ConvertPStyle(bool bIsLite) const
case CSSProperties::ParagraphProperties::P_TopBorder:
{
sPBdr += L"<w:top" + oItem.second + L"/>";
sPBdr += L"<w:top " + oItem.second + L"/>";
break;
}
case CSSProperties::ParagraphProperties::P_LeftBorder:
{
sPBdr += L"<w:left" + oItem.second + L"/>";
sPBdr += L"<w:left " + oItem.second + L"/>";
break;
}
case CSSProperties::ParagraphProperties::P_BottomBorder:
{
sPBdr += L"<w:bottom" + oItem.second + L"/>";
sPBdr += L"<w:bottom " + oItem.second + L"/>";
break;
}
case CSSProperties::ParagraphProperties::P_RightBorder:
{
sPBdr += L"<w:right" + oItem.second + L"/>";
sPBdr += L"<w:right " + oItem.second + L"/>";
break;
}
case CSSProperties::ParagraphProperties::P_KeepLines:
@ -429,8 +415,8 @@ std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
}
case CSSProperties::RunnerProperties::R_Sz:
{
sRStyle += L"<w:sz w:val=\"" + oItem.second +
L"\"/>" + L"<w:szCs w:val=\"" + oItem.second + L"\"/>";
sRStyle += L"<w:sz w:val=\"" + oItem.second + L"\"/>" +
L"<w:szCs w:val=\"" + oItem.second + L"\"/>";
break;
}
case CSSProperties::RunnerProperties::R_B:
@ -462,11 +448,18 @@ std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
sRStyle += L"<w:u w:val=\"" + oItem.second + L"\"/>";
break;
}
// case CSSProperties::RunnerProperties::R_Highlight:
// {
// sRStyle += L"<w:highlight w:val=\"" + oItem.second + L"\"/>";
// break;
// }
case CSSProperties::RunnerProperties::R_Highlight:
{
if (!oItem.second.empty())
sRStyle += L"<w:highlight w:val=\"" + oItem.second + L"\"/>";
break;
}
case CSSProperties::RunnerProperties::R_Shd:
{
if (!oItem.second.empty())
sRStyle += L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" + oItem.second + L"\"/>";
break;
}
case CSSProperties::RunnerProperties::R_SmallCaps:
{
if (oItem.second == L"smallCaps")
@ -475,6 +468,11 @@ std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
sRStyle += L"<w:smallCaps w:val=\"false\"/>";
break;
}
case CSSProperties::RunnerProperties::R_Kern:
{
sRStyle += L"<w:kern w:val=\"" + oItem.second + L"\"/>";
break;
}
default:
break;
}
@ -519,7 +517,8 @@ std::wstring CXmlElement::ConvertBasicInfoStyle() const
}
case CSSProperties::BasicProperties::B_UnhideWhenUsed:
{
sBasicInfo += L"<w:unhideWhenUsed/>";
if (L"true" == oItem.second)
sBasicInfo += L"<w:unhideWhenUsed/>";
break;
}
case CSSProperties::BasicProperties::B_UiPriority:
@ -527,6 +526,12 @@ std::wstring CXmlElement::ConvertBasicInfoStyle() const
sBasicInfo += L"<w:uiPriority w:val=\"" + oItem.second + L"\"/>";
break;
}
case CSSProperties::BasicProperties::B_SemiHidden:
{
if (L"true" == oItem.second)
sBasicInfo += L"<w:semiHidden/>";
break;
}
default:
break;
}
@ -598,7 +603,7 @@ std::wstring CXmlElement::GetPStyle(bool bIsLite) const
{
if (bIsLite)
return ConvertPStyle(true);
return GetStyle(true, true, false);
}
@ -606,7 +611,7 @@ std::wstring CXmlElement::GetRStyle(bool bIsLite) const
{
if (bIsLite)
return ConvertRStyle(true);
return GetStyle(true, false, true);
}

View File

@ -47,7 +47,7 @@ public:
CXmlElement& operator+=(const CXmlElement& oElement);
CXmlElement& operator= (const CXmlElement& oelement);
bool operator== (const CXmlElement& oElement);
bool operator== (const CXmlElement& oElement) const;
};
#endif // CXMLELEMENT_H

View File

@ -5,7 +5,6 @@ sys.path.append('../../../../build_tools/scripts')
import config
import base
import os
import build
base_directory = os.getcwd()

View File

@ -11,7 +11,9 @@
#include "../../../DesktopEditor/common/File.h"
#include "../../../DesktopEditor/common/Directory.h"
#include "../../../DesktopEditor/common/StringBuilder.h"
#include "../../../DesktopEditor/xml/include/xmlutils.h"
#include "../../../UnicodeConverter/UnicodeConverter.h"
#include "../../../HtmlFile2/src/StringFinder.h"
static std::string nonbreaking_inline = "|a|abbr|acronym|b|bdo|big|cite|code|dfn|em|font|i|img|kbd|nobr|s|small|span|strike|strong|sub|sup|tt|";
static std::string empty_tags = "|area|base|basefont|bgsound|br|command|col|embed|event-source|frame|hr|image|img|input|keygen|link|menuitem|meta|param|source|spacer|track|wbr|";
@ -20,8 +22,27 @@ static std::string special_handling = "|html|body|";
static std::string no_entity_sub = ""; //"|style|";
static std::string treat_like_inline = "|p|";
static void prettyprint(GumboNode*, NSStringUtils::CStringBuilderA& oBuilder);
static std::string mhtTohtml(std::string& sFileContent);
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
"ul", "ol", "li","td","tr","table","thead","tbody","tfoot","th",
"br","form","input","button","section","nav","header","footer",
"main","figure","figcaption","strong","em","i", "b", "u","pre",
"code","blockquote","hr","script","link","meta","style","title",
"head","body","html","legend","optgroup","option","select","dl",
"dt","dd","time","data","abbr","address","area","base","bdi",
"bdo","cite","col","iframe","video","source","track","textarea",
"label","fieldset","colgroup","del","ins","details","summary",
"dialog","embed","kbd","map","mark","menu","meter","object",
"output","param","progress","q","samp","small","sub","sup","var",
"wbr","acronym","applet","article","aside","audio","basefont",
"bgsound","big","blink","canvas","caption","center","command",
"comment","datalist","dfn","dir","font","frame","frameset",
"hgroup","isindex","keygen","marquee","nobr","noembed","noframes",
"noscript","plaintext","rp","rt","ruby","s","strike","tt","xmp"};
static std::vector<std::string> unchecked_nodes_new = {"svg"};
static void prettyprint(GumboNode*, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode = true);
static std::string mhtTohtml(const std::string &sFileContent);
// Заменяет в строке s все символы s1 на s2
static void replace_all(std::string& s, const std::string& s1, const std::string& s2)
@ -34,70 +55,45 @@ static void replace_all(std::string& s, const std::string& s1, const std::string
}
}
static bool NodeIsUnprocessed(const std::string& wsTagName)
{
return "xml" == wsTagName;
}
static bool IsUnckeckedNodes(const std::string& sValue)
{
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
}
static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
{
// Распознование кодировки
if (bNeedConvert)
{
size_t posEncoding = sFileContent.find("charset=");
if (posEncoding == std::string::npos)
posEncoding = sFileContent.find("encoding=");
if (posEncoding != std::string::npos)
{
posEncoding = sFileContent.find("=", posEncoding) + 1;
char quoteSymbol = '\"';
if(sFileContent[posEncoding] == '\"' || sFileContent[posEncoding] == '\'')
{
quoteSymbol = sFileContent[posEncoding];
posEncoding += 1;
}
{ // Определение кодировки
std::string sEncoding = NSStringFinder::FindPropety(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
size_t posEnd = sFileContent.find(quoteSymbol, posEncoding);
if (std::string::npos != posEnd)
{
std::string sEncoding = sFileContent.substr(posEncoding, posEnd - posEncoding);
if (sEncoding != "utf-8" && sEncoding != "UTF-8")
{
NSUnicodeConverter::CUnicodeConverter oConverter;
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
}
}
if (sEncoding.empty())
sEncoding = NSStringFinder::FindPropety(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
{
NSUnicodeConverter::CUnicodeConverter oConverter;
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
}
}
// Избавление от <a/>
size_t posA = sFileContent.find("<a ");
while(posA != std::string::npos)
{
size_t nBegin = sFileContent.find('<', posA + 1);
size_t nEnd = sFileContent.find("/>", posA);
if(nEnd < nBegin)
sFileContent.replace(nEnd, 2, "></a>");
posA = sFileContent.find("<a ", nBegin);
}
// Избавление от <title/>
posA = sFileContent.find("<title/>");
while (posA != std::string::npos)
{
sFileContent.replace(posA, 8, "<title></title>");
posA = sFileContent.find("<title/>", posA);
}
// Избавление от <script/>
posA = sFileContent.find("<script");
while (posA != std::string::npos)
{
size_t nEnd = 0;
size_t nEnd1 = sFileContent.find("/>", posA);
size_t nEnd2 = sFileContent.find("</script>", posA);
if (nEnd1 != std::string::npos)
nEnd = nEnd1 + 2;
if (nEnd2 != std::string::npos && (nEnd == 0 || (nEnd > 0 && nEnd2 < nEnd)))
nEnd = nEnd2 + 9;
// Избавляемся от лишних символов до <...
boost::regex oRegex("<[a-zA-Z]");
boost::match_results<typename std::string::const_iterator> oResult;
sFileContent.erase(posA, nEnd - posA);
if (boost::regex_search(sFileContent, oResult, oRegex))
sFileContent.erase(0, oResult.position());
posA = sFileContent.find("<script", posA);
}
//Избавление от <a ... />
while (NSStringFinder::RemoveEmptyTag(sFileContent, "a"));
//Избавление от <title ... />
while (NSStringFinder::RemoveEmptyTag(sFileContent, "title"));
//Избавление от <script ... />
while (NSStringFinder::RemoveEmptyTag(sFileContent, "script"));
// Gumbo
GumboOptions options = kGumboDefaultOptions;
@ -120,7 +116,7 @@ static std::string Base64ToString(const std::string& sContent, const std::string
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
{
std::wstring sConvert;
if(!sCharset.empty() && sCharset != "utf-8" && sCharset != "UTF-8")
if(!sCharset.empty() && NSStringFinder::Equals<std::string>("utf-8", sCharset))
{
NSUnicodeConverter::CUnicodeConverter oConverter;
sConvert = oConverter.toUnicode(reinterpret_cast<char *>(pData), (unsigned)nDecodeLen, sCharset.data());
@ -208,174 +204,125 @@ static std::string QuotedPrintableDecode(const std::string& sContent, std::strin
return sRes.GetData();
}
static void ReadMht(std::string& sFileContent, size_t& nFound, size_t& nNextFound, const std::string& sBoundary,
std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
{
// Content
size_t nContentTag = sFileContent.find("\n\n", nFound);
if(nContentTag == std::string::npos || nContentTag > nNextFound)
{
nContentTag = sFileContent.find("\r\r", nFound);
if(nContentTag == std::string::npos || nContentTag > nNextFound)
{
nContentTag = sFileContent.find("\r\n\r\n", nFound);
if(nContentTag == std::string::npos || nContentTag > nNextFound)
{
nFound = nNextFound;
return;
}
else
nContentTag += 4;
}
else
nContentTag += 2;
}
else
nContentTag += 2;
size_t unContentPosition = 0, unCharsetBegin = 0, unCharsetEnd = std::string::npos;
NSStringFinder::TFoundedData<char> oData;
// Content-Type
size_t nTag = sFileContent.find("Content-Type: ", nFound);
if(nTag == std::string::npos || nTag > nContentTag)
oData = NSStringFinder::FindPropety(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
const std::string sContentType{oData.m_sValue};
if (sContentType.empty())
return;
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
{
nFound = nNextFound;
oRes.WriteString(mhtTohtml(sMhtContent.substr(oData.m_unEndPosition, sMhtContent.length() - oData.m_unEndPosition)));
return;
}
size_t nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
nTag += 14;
if(nTagEnd == std::string::npos || nTagEnd > nContentTag)
{
nFound = nNextFound;
return;
}
std::string sContentType = sFileContent.substr(nTag, nTagEnd - nTag);
if(sContentType == "multipart/alternative")
nContentTag = nFound;
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
unCharsetBegin = oData.m_unEndPosition;
// name
std::string sName;
nTag = sFileContent.find(" name=", nFound);
if(nTag != std::string::npos && nTag < nContentTag)
// std::string sName = NSStringFinder::FindPropety(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
// unContentPosition = std::max(unContentPosition, unLastPosition);
// Content-Location
oData = NSStringFinder::FindPropety(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
std::string sContentLocation{oData.m_sValue};
if (!oData.Empty())
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
// Content-ID
oData = NSStringFinder::FindPropety(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
std::string sContentID{oData.m_sValue};
if (!oData.Empty())
{
nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
nTag += 6;
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
sName = sFileContent.substr(nTag, nTagEnd - nTag);
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
NSStringFinder::CutInside<std::string>(sContentID, "<", ">");
}
if (sContentLocation.empty() && !sContentID.empty())
sContentLocation = "cid:" + sContentID;
// Content-Transfer-Encoding
oData = NSStringFinder::FindPropety(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
const std::string sContentEncoding{oData.m_sValue};
if (!oData.Empty())
{
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
}
// charset
std::string sCharset;
nTag = sFileContent.find("charset=", nFound);
if(nTag != std::string::npos && nTag < nContentTag)
{
nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
nTag += 8;
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
{
if(sFileContent[nTag] == '\"')
{
nTag++;
nTagEnd--;
}
sCharset = sFileContent.substr(nTag, nTagEnd - nTag);
}
}
std::string sCharset = "utf-8";
// Content-Location
std::string sContentLocation;
nTag = sFileContent.find("Content-Location: ", nFound);
if(nTag != std::string::npos && nTag < nContentTag)
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
{
nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
nTag += 18;
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
sContentLocation = sFileContent.substr(nTag, nTagEnd - nTag);
}
if (sContentLocation.empty())
{
// Content-ID
std::string sContentID;
nTag = sFileContent.find("Content-ID: <", nFound);
if(nTag != std::string::npos && nTag < nContentTag)
{
nTagEnd = sFileContent.find_first_of(">", nTag);
nTag += 13;
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
sContentID = sFileContent.substr(nTag, nTagEnd - nTag);
}
if (!sContentID.empty())
sContentLocation = "cid:" + sContentID;
}
// Content-Transfer-Encoding
std::string sContentEncoding;
nTag = sFileContent.find("Content-Transfer-Encoding: ", nFound);
if(nTag != std::string::npos && nTag < nContentTag)
{
nTagEnd = sFileContent.find_first_of(";\n\r", nTag);
nTag += 27;
if(nTagEnd != std::string::npos && nTagEnd < nContentTag)
sContentEncoding = sFileContent.substr(nTag, nTagEnd - nTag);
sCharset = NSStringFinder::FindPropety(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
NSStringFinder::CutInside<std::string>(sCharset, "\"");
}
// Content
nTagEnd = nNextFound - 2;
if(nTagEnd == std::string::npos || nTagEnd < nContentTag)
{
nFound = nNextFound;
return;
}
std::string sContent = sFileContent.substr(nContentTag, nTagEnd - nContentTag);
std::string sContent = sMhtContent.substr(unContentPosition, sMhtContent.length() - unContentPosition);
// Удаляем лишнее
sFileContent.erase(0, nNextFound);
nFound = sFileContent.find(sBoundary);
std::wstring sExtention = NSFile::GetFileExtention(UTF8_TO_U(sName));
std::transform(sExtention.begin(), sExtention.end(), sExtention.begin(), tolower);
// std::wstring sExtention = NSFile::GetFileExtention(UTF8_TO_U(sName));
// std::transform(sExtention.begin(), sExtention.end(), sExtention.begin(), tolower);
// Основной документ
if(sContentType == "multipart/alternative")
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
oRes.WriteString(mhtTohtml(sContent));
else if((sContentType.find("text") != std::string::npos && (sExtention.empty() || sExtention == L"htm" || sExtention == L"html" || sExtention
== L"xhtml" || sExtention == L"css")) || (sContentType == "application/octet-stream" && (sContentLocation.find("css") !=
std::string::npos)))
else if ((NSStringFinder::Find(sContentType, "text") /*&& (sExtention.empty() || NSStringFinder::EqualOf(sExtention, {L"htm", L"html", L"xhtml", L"css"}))*/)
|| (NSStringFinder::Equals(sContentType, "application/octet-stream") && NSStringFinder::Find(sContentLocation, "css")))
{
// Стили заключаются в тэг <style>
if(sContentType == "text/css" || sExtention == L"css" || sContentLocation.find("css") != std::string::npos)
const bool bAddTagStyle = NSStringFinder::Equals(sContentType, "text/css") /*|| NSStringFinder::Equals(sExtention, L"css")*/ || NSStringFinder::Find(sContentLocation, "css");
if (bAddTagStyle)
oRes.WriteString("<style>");
if(sContentEncoding == "Base64" || sContentEncoding == "base64")
oRes.WriteString(Base64ToString(sContent, sCharset));
else if(sContentEncoding == "8bit" || sContentEncoding == "7bit" || sContentEncoding.empty())
if (NSStringFinder::Equals(sContentEncoding, "base64"))
sContent = Base64ToString(sContent, sCharset);
else if (NSStringFinder::EqualOf(sContentEncoding, {"8bit", "7bit"}) || sContentEncoding.empty())
{
if (sCharset != "utf-8" && sCharset != "UTF-8" && !sCharset.empty())
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
{
NSUnicodeConverter::CUnicodeConverter oConverter;
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
}
oRes.WriteString(sContent);
}
else if(sContentEncoding == "quoted-printable" || sContentEncoding == "Quoted-Printable")
else if (NSStringFinder::Equals(sContentEncoding, "quoted-printable"))
{
sContent = QuotedPrintableDecode(sContent, sCharset);
if (sCharset != "utf-8" && sCharset != "UTF-8" && !sCharset.empty())
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
{
NSUnicodeConverter::CUnicodeConverter oConverter;
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
}
oRes.WriteString(sContent);
}
if(sContentType == "text/css" || sExtention == L"css" || sContentLocation.find("css") != std::string::npos)
if (NSStringFinder::Equals(sContentType, "text/html"))
sContent = U_TO_UTF8(htmlToXhtml(sContent, false));
oRes.WriteString(sContent);
if(bAddTagStyle)
oRes.WriteString("</style>");
}
// Картинки
else if((sContentType.find("image") != std::string::npos || sExtention == L"gif" || sContentType == "application/octet-stream") &&
(sContentEncoding == "Base64" || sContentEncoding == "base64"))
else if ((NSStringFinder::Find(sContentType, "image") /*|| NSStringFinder::Equals(sExtention, L"gif")*/ || NSStringFinder::Equals(sContentType, "application/octet-stream")) &&
NSStringFinder::Equals(sContentEncoding, "base64"))
{
if(sExtention == L"ico" || sContentType.find("ico") != std::string::npos)
sContentType = "image/jpg";
else if(sExtention == L"gif")
sContentType = "image/gif";
// if (NSStringFinder::Equals(sExtention, L"ico") || NSStringFinder::Find(sContentType, "ico"))
// sContentType = "image/jpg";
// else if(NSStringFinder::Equals(sExtention, L"gif"))
// sContentType = "image/gif";
int nSrcLen = (int)sContent.length();
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
BYTE* pData = new BYTE[nDecodeLen];
@ -385,50 +332,46 @@ static void ReadMht(std::string& sFileContent, size_t& nFound, size_t& nNextFoun
}
}
static std::string mhtTohtml(std::string& sFileContent)
static std::string mhtTohtml(const std::string& sFileContent)
{
std::map<std::string, std::string> sRes;
NSStringUtils::CStringBuilderA oRes;
// Поиск boundary
size_t nFound = sFileContent.find("boundary=");
if(nFound == std::string::npos)
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindPropety(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
size_t nFound{oData.m_unEndPosition};
std::string sBoundary{oData.m_sValue};
if (sBoundary.empty())
{
size_t nFoundEnd = sFileContent.length();
nFound = 0;
ReadMht(sFileContent, nFound, nFoundEnd, "no", sRes, oRes);
ReadMht(sFileContent.substr(nFound, nFoundEnd), sRes, oRes);
return oRes.GetData();
}
size_t nFoundEnd = sFileContent.find_first_of(";\n\r", nFound);
if(nFoundEnd == std::string::npos)
return "";
nFound += 9;
if(sFileContent[nFound] == '\"')
{
nFound++;
nFoundEnd--;
}
if(nFound > nFoundEnd)
return "";
std::string sBoundary = sFileContent.substr(nFound, nFoundEnd - nFound);
NSStringFinder::CutInside<std::string>(sBoundary, "\"");
size_t nFoundEnd{nFound};
sBoundary = "--" + sBoundary;
size_t nBoundaryLength = sBoundary.length();
// Удаляем лишнее
nFound = sFileContent.find(sBoundary, nFoundEnd);
sFileContent.erase(0, nFound);
nFound = sFileContent.find(sBoundary, nFound) + nBoundaryLength;
// Цикл по boundary
nFound = 0;
while(nFound != std::string::npos)
{
// Выход по --boundary--
if(sFileContent[nFound + nBoundaryLength + 1] == '-')
break;
nFoundEnd = sFileContent.find(sBoundary, nFound + nBoundaryLength);
if(nFoundEnd == std::string::npos)
break;
ReadMht(sFileContent, nFound, nFoundEnd, sBoundary, sRes, oRes);
ReadMht(sFileContent.substr(nFound, nFoundEnd - nFound), sRes, oRes);
nFound = sFileContent.find(sBoundary, nFoundEnd);
}
std::string sFile = oRes.GetData();
for(const std::pair<std::string, std::string>& item : sRes)
{
@ -440,10 +383,18 @@ static std::string mhtTohtml(std::string& sFileContent)
while(found != std::string::npos)
{
size_t fq = sFile.find_last_of("\"\'>=", found);
if (std::string::npos == fq)
break;
char ch = sFile[fq];
if(ch != '\"' && ch != '\'')
fq++;
size_t tq = sFile.find_first_of("\"\'<> ", found) + 1;
if (std::string::npos == tq)
break;
if(sFile[tq] != '\"' && sFile[tq] != '\'')
tq--;
if(ch != '>')
@ -456,6 +407,7 @@ static std::string mhtTohtml(std::string& sFileContent)
found = sFile.find(sName, tq);
}
}
return sFile;
}
@ -587,7 +539,7 @@ static void build_attributes(const GumboVector* attribs, bool no_entities, NSStr
}
}
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents)
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
{
std::string key = "|" + get_tag_name(node) + "|";
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
@ -618,7 +570,7 @@ static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA
contents.WriteString(val);
}
else if ((child->type == GUMBO_NODE_ELEMENT) || (child->type == GUMBO_NODE_TEMPLATE))
prettyprint(child, contents);
prettyprint(child, contents, bCheckValidNode);
else if (child->type == GUMBO_NODE_WHITESPACE)
{
if (keep_whitespace || is_inline || is_like_inline)
@ -633,23 +585,36 @@ static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA
}
}
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder)
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode)
{
// special case the document node
if (node->type == GUMBO_NODE_DOCUMENT)
{
build_doctype(node, oBuilder);
prettyprint_contents(node, oBuilder);
prettyprint_contents(node, oBuilder, bCheckValidNode);
return;
}
std::string tagname = get_tag_name(node);
if (NodeIsUnprocessed(tagname))
return;
if (bCheckValidNode)
bCheckValidNode = !IsUnckeckedNodes(tagname);
if (bCheckValidNode && html_tags.end() == std::find(html_tags.begin(), html_tags.end(), tagname))
{
prettyprint_contents(node, oBuilder, bCheckValidNode);
return;
}
std::string close = "";
std::string closeTag = "";
std::string tagname = get_tag_name(node);
std::string key = "|" + tagname + "|";
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
// determine closing tag type
if (is_empty_tag)
close = "/";
@ -665,7 +630,7 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
oBuilder.WriteString(close + ">");
// prettyprint your contents
prettyprint_contents(node, oBuilder);
prettyprint_contents(node, oBuilder, bCheckValidNode);
oBuilder.WriteString(closeTag);
}

View File

@ -2,3 +2,4 @@ emsdk/
hunspell/
deploy/
o
hunspell.data

View File

@ -14,6 +14,12 @@ def get_hunspell(stable_commit):
base.replaceInFile("./src/hunspell/csutil.cxx", "void free_utf_tbl() {", "void free_utf_tbl() { \n return;\n")
# bug fix, we need to keep this utf table
# free_utf_tbl doesnt delete anything so we can destroy hunspell object
# replace & add defines to easy control of time limits (CUSTOM_LIMIT)
default_tl_defines = "#define TIMELIMIT_GLOBAL (CLOCKS_PER_SEC / 4)\n#define TIMELIMIT_SUGGESTION (CLOCKS_PER_SEC / 10)\n#define TIMELIMIT (CLOCKS_PER_SEC / 20)\n"
custom_tl_defines_tl = "#define TIMELIMIT_GLOBAL CUSTOM_TIMELIMIT_GLOBAL\n#define TIMELIMIT_SUGGESTION CUSTOM_TIMELIMIT_SUGGESTION\n#define TIMELIMIT CUSTOM_TIMELIMIT\n"
tl_defines = "#ifndef CUSTOM_TIMELIMITS\n" + default_tl_defines + "#else\n" + custom_tl_defines_tl + "#endif\n"
base.replaceInFile("./src/hunspell/atypes.hxx", default_tl_defines, tl_defines)
os.chdir("../")

View File

@ -0,0 +1,163 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../../../../Common/3dParty/hunspell/hunspell/src/hunspell/hunspell.h"
#include "../../../../DesktopEditor/common/StringExt.h"
#include "../../../../DesktopEditor/common/Directory.h"
#include <iostream>
bool CheckCaret(std::vector<std::wstring>& words)
{
bool bIsCaret = false;
for (int i = 0, len = (int)words.size(); i < len; ++i)
{
if (words[i].find('\r') == (words[i].length() - 1))
{
words[i] = words[i].substr(0, words[i].length() - 1);
bIsCaret = true;
}
}
return bIsCaret;
}
std::wstring CheckWord(Hunhandle* pDic, const std::wstring& sWord, const bool& bIsCaret)
{
std::wstring sResult = sWord;
std::string sWordA = U_TO_UTF8(sWord);
int nSpellResult = Hunspell_spell(pDic, sWordA.c_str());
if (0 == nSpellResult)
{
char** pSuggest;
int nSuggestCount = Hunspell_suggest(pDic, &pSuggest, sWordA.c_str());
sResult += L" [";
for (int i = 0; i < nSuggestCount; ++i)
{
std::string sSuggestA(pSuggest[i], strlen(pSuggest[i]));
std::wstring sSuggest = UTF8_TO_U(sSuggestA);
sResult += sSuggest;
if (i != (nSuggestCount - 1))
sResult += (L", ");
}
if (0 < nSuggestCount)
Hunspell_free_list(pDic, &pSuggest, nSuggestCount);
sResult += L"]";
}
if (bIsCaret)
sResult += L"\r";
sResult += L"\n";
return sResult;
}
#if defined(_WIN32) || defined(_WIN64)
#define USE_WCHAR_ARGC
#endif
#ifdef USE_WCHAR_ARGC
std::wstring GetParam(wchar_t* arg)
{
return std::wstring(arg);
}
#else
std::wstring GetParam(char* arg)
{
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE *)arg, (LONG)strlen(arg));
}
#endif
#ifdef USE_WCHAR_ARGC
int wmain(int argc, wchar_t *argv[])
#else
int main(int argc, char *argv[])
#endif
{
std::wstring sSrcDir = NSFile::GetProcessDirectory() + L"/../src";
std::wstring sDstDir = NSFile::GetProcessDirectory() + L"/../dst";
std::wstring sDictionariesDir = NSFile::GetProcessDirectory() + L"/../../../../../../dictionaries";
if (argc > 1) sSrcDir = GetParam(argv[1]);
if (argc > 2) sDstDir = GetParam(argv[2]);
if (argc > 3) sDictionariesDir = GetParam(argv[3]);
std::vector<std::wstring> arSrcFiles = NSDirectory::GetFiles(sSrcDir);
for (int i = 0, len = (int)arSrcFiles.size(); i < len; ++i)
{
std::wstring sFileWords = arSrcFiles[i];
std::wstring sName = NSFile::GetFileName(sFileWords);
std::wstring::size_type sNamePos = sName.find(L".");
if (std::wstring::npos != sNamePos)
sName = sName.substr(0, sNamePos);
std::wstring sFileWordsContent = L"";
NSFile::CFileBinary::ReadAllTextUtf8(sFileWords, sFileWordsContent);
std::vector<std::wstring> arWords = NSStringExt::Split(sFileWordsContent, '\n');
bool bIsCaret = CheckCaret(arWords);
std::wstring sAff = sDictionariesDir + L"/" + sName + L"/" + sName + L".aff";
std::wstring sDic = sDictionariesDir + L"/" + sName + L"/" + sName + L".dic";
// skip check diffs if dictionary is not exists
if (!NSFile::CFileBinary::Exists(sAff) || !NSFile::CFileBinary::Exists(sDic))
continue;
std::string sAffA = U_TO_UTF8(sAff);
std::string sDicA = U_TO_UTF8(sDic);
Hunhandle* pDictionary = Hunspell_create(sAffA.c_str(), sDicA.c_str());
std::wstring sFileDst = sDstDir + L"/" + sName + L".txt";
std::wstring sResult = L"";
for (const std::wstring& word : arWords)
{
sResult += CheckWord(pDictionary, word, bIsCaret);
}
Hunspell_destroy(pDictionary);
NSFile::CFileBinary::SaveToFile(sFileDst, sResult, true);
std::cout << "[" << (i + 1) << " of " << (int)arSrcFiles.size() << "] " << U_TO_UTF8(sName) << std::endl;
}
return 0;
}

View File

@ -0,0 +1,48 @@
#-------------------------------------------------
#
# Project created by QtCreator 2015-07-21T18:28:42
#
#-------------------------------------------------
QT -= core gui
TARGET = dictionariestester
CONFIG += console
CONFIG -= app_bundle
DEFINES += KERNEL_USE_DYNAMIC_LIBRARY
TEMPLATE = app
CONFIG += hunspell_build_static
CORE_ROOT_DIR = $$PWD/../../../..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
include($$CORE_ROOT_DIR/Common/3dParty/hunspell/qt/hunspell.pri)
# custom time limits of hunspell in clocks (if before.py was executed)
# when increasing the limit for each case, it is important to consider that the total time will
# also increase, so it is good to increase the global limit. this works the same for the candidate limit with suggest limit
DEFINES += CUSTOM_TIMELIMITS
escape_bracket=
!core_windows:escape_bracket=\\
# total time limit per word for all cases. (default is CLOCKS_PER_SEC/4)
DEFINES += "CUSTOM_TIMELIMIT_GLOBAL=$${escape_bracket}(20*CLOCKS_PER_SEC$${escape_bracket})"
# total time limit per "1 case" - forgotten char, double char, moved char and so on for all candidates. (default is CLOCKS_PER_SEC/10)
DEFINES += "CUSTOM_TIMELIMIT_SUGGESTION=$${escape_bracket}(5*CLOCKS_PER_SEC$${escape_bracket})"
# time limit per candidate (default is CLOCKS_PER_SEC/20)
DEFINES += "CUSTOM_TIMELIMIT=$${escape_bracket}(CLOCKS_PER_SEC$${escape_bracket}\)"
ADD_DEPENDENCY(UnicodeConverter kernel)
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32
SOURCES += main.cpp
DESTDIR = $$CORE_BUILDS_BINARY_PATH

View File

@ -43,8 +43,7 @@ core_ios {
core_android {
INCLUDEPATH += $$PWD/android/build/include
ICU_LIBS_PATH = $$replace(CORE_BUILDS_PLATFORM_PREFIX, "android_", "")
LIBS += $$PWD/android/build/$$ICU_LIBS_PATH/libicuuc.a
LIBS += $$PWD/android/build/$$ICU_LIBS_PATH/libicudata.a
LIBS += $$PWD/android/build/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libicuuc.a
LIBS += $$PWD/android/build/$$CORE_BUILDS_PLATFORM_PREFIX_DST/libicudata.a
}

View File

@ -20,9 +20,9 @@ CONFIG_PREFIX=" --enable-extras=yes \
--enable-dyload=no \
--with-data-packaging=static"
CFLAGS="-O3 -D__STDC_INT64__ -fno-exceptions -fno-short-wchar -fno-short-enums -fembed-bitcode"
CFLAGS="-O3 -D__STDC_INT64__ -fno-exceptions -fno-short-wchar -fno-short-enums"
CXXFLAGS="${CFLAGS} -std=c++11 -fembed-bitcode"
CXXFLAGS="${CFLAGS} -std=c++11"
#will set value to 1
defines_config_set_1=(
@ -215,9 +215,9 @@ function build() {
export CXX="$(xcrun -find clang++)"
export CC="$(xcrun -find clang)"
export CFLAGS="-fembed-bitcode -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS $CFLAGS ${ADDITION_FLAG}"
export CXXFLAGS="${CXXFLAGS} -fembed-bitcode -stdlib=libc++ -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS ${ADDITION_FLAG}"
export LDFLAGS="-fembed-bitcode -stdlib=libc++ -L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip $IOS_MIN_VER -lstdc++ ${ADDITION_FLAG}"
export CFLAGS="-isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS $CFLAGS ${ADDITION_FLAG}"
export CXXFLAGS="${CXXFLAGS} -stdlib=libc++ -isysroot $SDKROOT -I$SDKROOT/usr/include/ -I./include/ -arch $ARCH $IOS_MIN_VER $ICU_FLAGS ${ADDITION_FLAG}"
export LDFLAGS="-stdlib=libc++ -L$SDKROOT/usr/lib/ -isysroot $SDKROOT -Wl,-dead_strip $IOS_MIN_VER -lstdc++ ${ADDITION_FLAG}"
mkdir -p ${BUILD_DIR}
cd ${BUILD_DIR}

View File

@ -1,991 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "../sys/windowsmediaphoto.h"
#include "../sys/strcodec.h"
#include "decode.h"
EXTERN_C Void freePredInfo(CWMImageStrCodec *);
EXTERN_C Int ReadWMIHeader(CWMImageInfo *, CWMIStrCodecParam *, CCoreParameters *);
EXTERN_C Int StrIODecInit(CWMImageStrCodec *);
EXTERN_C Int StrDecInit(CWMImageStrCodec *);
EXTERN_C Int readPackets(CWMImageStrCodec *);
EXTERN_C Int DecodeMacroblockDC(CWMImageStrCodec *, CCodingContext *, Int, Int);
EXTERN_C Int DecodeMacroblockLowpass(CWMImageStrCodec *, CCodingContext *, Int, Int);
EXTERN_C Int DecodeMacroblockHighpass(CWMImageStrCodec *, CCodingContext *, Int, Int);
EXTERN_C Void predDCACDec(CWMImageStrCodec *);
EXTERN_C Void predACDec(CWMImageStrCodec *);
EXTERN_C Void StrIODecTerm(CWMImageStrCodec *);
EXTERN_C Void FreeCodingContextDec(CWMImageStrCodec *);
EXTERN_C Int StrEncInit(CWMImageStrCodec *);
EXTERN_C Void StrIOEncTerm(CWMImageStrCodec *);
EXTERN_C Void FreeCodingContextEnc(CWMImageStrCodec *);
EXTERN_C Int encodeMB(CWMImageStrCodec *, Int, Int);
EXTERN_C Int writeIndexTableNull(CWMImageStrCodec *);
EXTERN_C Void writePacketHeader(BitIOInfo *, U8, U8);
EXTERN_C Int WriteWMIHeader(CWMImageStrCodec *);
EXTERN_C Int ReadImagePlaneHeader(CWMImageInfo *, CWMIStrCodecParam *, CCoreParameters *, SimpleBitIO *);
EXTERN_C Int WriteImagePlaneHeader(CWMImageStrCodec *);
EXTERN_C Int writeIndexTable(CWMImageStrCodec *);
EXTERN_C Int copyTo(struct WMPStream *, struct WMPStream *, size_t);
const static Bool bFlipV[O_MAX] = {FALSE, TRUE , FALSE, TRUE, TRUE , TRUE, FALSE, FALSE};
const static Bool bFlipH[O_MAX] = {FALSE, FALSE, TRUE , TRUE, FALSE, TRUE, FALSE, TRUE};
typedef struct CTileQPInfo
{
U8 dcMode;
U8 dcIndex[MAX_CHANNELS];
Bool bUseDC;
U8 lpNum;
Bool bUseDCAlpha;
U8 lpNumAlpha;
U8 lpMode[16];
U8 lpIndex[16][MAX_CHANNELS];
Bool bUseLP;
U8 hpNum;
Bool bUseLPAlpha;
U8 hpNumAlpha;
U8 hpMode[16];
U8 hpIndex[16][MAX_CHANNELS];
} CTileQPInfo;
Void transcodeQuantizer(BitIOInfo * pIO, U8 cIndex[MAX_CHANNELS], U8 cChMode, size_t cChannel)
{
if(cChMode > 2)
cChMode = 2;
if(cChannel > 1)
putBit16(pIO, cChMode, 2); // Channel mode
else
cChMode = 0;
putBit16(pIO, cIndex[0], 8); // Y
if(cChMode == 1) // MIXED
putBit16(pIO, cIndex[1], 8); // UV
else if(cChMode > 0){ // INDEPENDENT
size_t i;
for(i = 1; i < cChannel; i ++)
putBit16(pIO, cIndex[i], 8); // UV
}
}
Void transcodeQuantizers(BitIOInfo * pIO, U8 cIndex[16][MAX_CHANNELS], U8 cChMode[16], U32 cNum, size_t cChannel, Bool bCopy)
{
putBit16(pIO, bCopy == TRUE ? 1 : 0, 1);
if(bCopy == FALSE){
U32 i;
putBit16(pIO, cNum - 1, 4);
for(i = 0; i < cNum; i ++)
transcodeQuantizer(pIO, cIndex[i], cChMode[i], cChannel);
}
}
Void transcodeQuantizersAlpha(BitIOInfo * pIO, U8 cIndex[16][MAX_CHANNELS], U32 cNum, size_t iChannel, Bool bCopy)
{
putBit16(pIO, bCopy == TRUE ? 1 : 0, 1);
if(bCopy == FALSE){
U32 i;
putBit16(pIO, cNum - 1, 4);
for(i = 0; i < cNum; i ++)
putBit16(pIO, cIndex[i][iChannel], 8);
}
}
Void transcodeTileHeader(CWMImageStrCodec * pSC, CTileQPInfo * pTileQPInfo)
{
if(pSC->m_bCtxLeft && pSC->m_bCtxTop && pSC->m_bSecondary == FALSE){ // write packet headers
CCodingContext * pContext = &pSC->m_pCodingContext[pSC->cTileColumn];
CWMITile * pTile = pSC->pTile + pSC->cTileColumn;
U8 pID = (U8)((pSC->cTileRow * (pSC->WMISCP.cNumOfSliceMinus1V + 1) + pSC->cTileColumn) & 0x1F);
CWMImageStrCodec * pSCAlpha = (pSC->m_param.bAlphaChannel ? pSC->m_pNextSC : NULL);
const size_t iAlphaPos = pSC->m_param.cNumChannels;
writePacketHeader(pContext->m_pIODC, pSC->WMISCP.bfBitstreamFormat == SPATIAL ? 0 : 1, pID);
if (pSC->m_param.bTrimFlexbitsFlag && pSC->WMISCP.bfBitstreamFormat == SPATIAL)
putBit16(pContext->m_pIODC, pContext->m_iTrimFlexBits, 4);
if((pSC->m_param.uQPMode & 1) != 0) // not DC uniform
transcodeQuantizer(pContext->m_pIODC, pTileQPInfo->dcIndex, pTileQPInfo->dcMode, pSC->WMISCP.cChannel);
if(pSCAlpha != NULL && (pSCAlpha->m_param.uQPMode & 1) != 0) // not DC uniform
putBit16(pContext->m_pIODC, pTileQPInfo->dcIndex[iAlphaPos], 8);
if(pSC->WMISCP.bfBitstreamFormat == SPATIAL) {
if(pSC->WMISCP.sbSubband != SB_DC_ONLY){
if((pSC->m_param.uQPMode & 2) != 0) // not LP uniform
transcodeQuantizers(pContext->m_pIODC, pTileQPInfo->lpIndex, pTileQPInfo->lpMode, pTileQPInfo->lpNum, pSC->WMISCP.cChannel, pTileQPInfo->bUseDC);
if(pSCAlpha != NULL && (pSCAlpha->m_param.uQPMode & 2) != 0) // not LP uniform
transcodeQuantizersAlpha(pContext->m_pIODC, pTileQPInfo->lpIndex, pTileQPInfo->lpNumAlpha, iAlphaPos, pTileQPInfo->bUseDCAlpha);
if(pSC->WMISCP.sbSubband != SB_NO_HIGHPASS){
if((pSC->m_param.uQPMode & 4) != 0) // not HP uniform
transcodeQuantizers(pContext->m_pIODC, pTileQPInfo->hpIndex, pTileQPInfo->hpMode, pTileQPInfo->hpNum, pSC->WMISCP.cChannel, pTileQPInfo->bUseLP);
if(pSCAlpha != NULL && (pSCAlpha->m_param.uQPMode & 4) != 0) // not HP uniform
transcodeQuantizersAlpha(pContext->m_pIODC, pTileQPInfo->hpIndex, pTileQPInfo->hpNumAlpha, iAlphaPos, pTileQPInfo->bUseLPAlpha);
}
}
}
else{
if(pSC->WMISCP.sbSubband != SB_DC_ONLY){
writePacketHeader(pContext->m_pIOLP, 2, pID);
if((pSC->m_param.uQPMode & 2) != 0) // not LP uniform
transcodeQuantizers(pContext->m_pIOLP, pTileQPInfo->lpIndex, pTileQPInfo->lpMode, pTileQPInfo->lpNum, pSC->WMISCP.cChannel, pTileQPInfo->bUseDC);
if(pSCAlpha != NULL && (pSCAlpha->m_param.uQPMode & 2) != 0) // not LP uniform
transcodeQuantizersAlpha(pContext->m_pIOLP, pTileQPInfo->lpIndex, pTileQPInfo->lpNumAlpha, iAlphaPos, pTileQPInfo->bUseDCAlpha);
if(pSC->WMISCP.sbSubband != SB_NO_HIGHPASS){
writePacketHeader(pContext->m_pIOAC, 3, pID);
if((pSC->m_param.uQPMode & 4) != 0) // not HP uniform
transcodeQuantizers(pContext->m_pIOAC, pTileQPInfo->hpIndex, pTileQPInfo->hpMode, pTileQPInfo->hpNum, pSC->WMISCP.cChannel, pTileQPInfo->bUseLP);
if(pSCAlpha != NULL && (pSCAlpha->m_param.uQPMode & 4) != 0) // not HP uniform
transcodeQuantizersAlpha(pContext->m_pIOAC, pTileQPInfo->hpIndex, pTileQPInfo->hpNumAlpha, iAlphaPos, pTileQPInfo->bUseLPAlpha);
if(pSC->WMISCP.sbSubband != SB_NO_FLEXBITS){
writePacketHeader(pContext->m_pIOFL, 4, pID);
if (pSC->m_param.bTrimFlexbitsFlag)
putBit16(pContext->m_pIOFL, pContext->m_iTrimFlexBits, 4);
}
}
}
}
pTile->cBitsLP = (pTileQPInfo->bUseDC ? 0 : dquantBits(pTileQPInfo->lpNum));
pTile->cBitsHP = (pTileQPInfo->bUseLP ? 0 : dquantBits(pTileQPInfo->hpNum));
if(pSCAlpha != NULL){
pTile = pSCAlpha->pTile + pSC->cTileColumn;
pTile->cBitsLP = (pTileQPInfo->bUseDCAlpha ? 0 : dquantBits(pTileQPInfo->lpNumAlpha));
pTile->cBitsHP = (pTileQPInfo->bUseLPAlpha ? 0 : dquantBits(pTileQPInfo->hpNumAlpha));
}
}
}
Void transformDCBlock(PixelI * pOrg, PixelI * pDst, ORIENTATION oOrientation)
{
size_t i;
if(bFlipV[oOrientation])
for(i = 0; i < 16; i += 4)
pOrg[i + 1] = -pOrg[i + 1], pOrg[i + 3] = -pOrg[i + 3];
if(bFlipH[oOrientation])
for(i = 0; i < 4; i ++)
pOrg[i + 4] = -pOrg[i + 4], pOrg[i + 12] = -pOrg[i + 12];
if(oOrientation < O_RCW)
memcpy(pDst, pOrg, 16 * sizeof(PixelI));
else
for(i = 0; i < 16; i ++)
pDst[i] = pOrg[(i >> 2) + ((i & 3) << 2)];
}
Void transformDCBlock422(PixelI * pOrg, PixelI * pDst, ORIENTATION oOrientation)
{
assert(oOrientation < O_RCW);
if(bFlipV[oOrientation])
pOrg[1] = -pOrg[1], pOrg[3] = -pOrg[3], pOrg[4] = -pOrg[4], pOrg[5] = -pOrg[5], pOrg[7] = -pOrg[7];
if(bFlipH[oOrientation])
pOrg[2] = -pOrg[2], pOrg[3] = -pOrg[3], pOrg[6] = -pOrg[6], pOrg[7] = -pOrg[7];
if(bFlipV[oOrientation])
pDst[0] = pOrg[0], pDst[1] = pOrg[5], pDst[2] = pOrg[6], pDst[3] = pOrg[7], pDst[4] = pOrg[4], pDst[5] = pOrg[1], pDst[6] = pOrg[2], pDst[7] = pOrg[3];
else
memcpy(pDst, pOrg, 8 * sizeof(PixelI));
}
Void transformDCBlock420(PixelI * pOrg, PixelI * pDst, ORIENTATION oOrientation)
{
if(bFlipV[oOrientation])
pOrg[1] = -pOrg[1], pOrg[3] = -pOrg[3];
if(bFlipH[oOrientation])
pOrg[2] = -pOrg[2], pOrg[3] = -pOrg[3];
pDst[0] = pOrg[0], pDst[3] = pOrg[3];
if(oOrientation < O_RCW)
pDst[1] = pOrg[1], pDst[2] = pOrg[2];
else
pDst[1] = pOrg[2], pDst[2] = pOrg[1];
}
Void transformACBlocks(PixelI * pOrg, PixelI * pDst, ORIENTATION oOrientation)
{
PixelI * pO, * pD;
const Int * pT = dctIndex[0];
size_t i, j, k;
for(j = 0, pO = pOrg; j < 16; j ++, pO += 16){
if(bFlipV[oOrientation])
for(i = 0; i < 16; i += 4)
pO[pT[i + 1]] = -pO[pT[i + 1]], pO[pT[i + 3]] = -pO[pT[i + 3]];
if(bFlipH[oOrientation])
for(i = 0; i < 4; i ++)
pO[pT[i + 4]] = -pO[pT[i + 4]], pO[pT[i + 12]] = -pO[pT[i + 12]];
}
for(j = 0; j < 4; j ++)
for(i = 0; i < 4; i ++){
size_t ii = (bFlipV[oOrientation] ? 3 - i : i);
size_t jj = (bFlipH[oOrientation] ? 3 - j : j);
if(oOrientation < O_RCW)
memcpy(pDst + (jj * 4 + ii) * 16, pOrg + (j * 4 + i) * 16, 16 * sizeof(PixelI));
else{
pO = pOrg + (j * 4 + i) * 16;
pD = pDst + (ii * 4 + jj) * 16;
for(k = 1; k < 16; k ++)
pD[pT[k]] = pO[pT[(k >> 2) + ((k & 3) << 2)]];
}
}
}
Void transformACBlocks422(PixelI * pOrg, PixelI * pDst, ORIENTATION oOrientation)
{
PixelI * pO;
const Int * pT = dctIndex[0];
size_t i, j;
assert(oOrientation < O_RCW);
for(j = 0, pO = pOrg; j < 8; j ++, pO += 16){
if(bFlipV[oOrientation])
for(i = 0; i < 16; i += 4)
pO[pT[i + 1]] = -pO[pT[i + 1]], pO[pT[i + 3]] = -pO[pT[i + 3]];
if(bFlipH[oOrientation])
for(i = 0; i < 4; i ++)
pO[pT[i + 4]] = -pO[pT[i + 4]], pO[pT[i + 12]] = -pO[pT[i + 12]];
}
for(j = 0; j < 2; j ++)
for(i = 0; i < 4; i ++){
size_t ii = (bFlipV[oOrientation] ? 3 - i : i);
size_t jj = (bFlipH[oOrientation] ? 1 - j : j);
memcpy(pDst + (jj * 4 + ii) * 16, pOrg + (j * 4 + i) * 16, 16 * sizeof(PixelI));
}
}
Void transformACBlocks420(PixelI * pOrg, PixelI * pDst, ORIENTATION oOrientation)
{
PixelI * pO, * pD;
const Int * pT = dctIndex[0];
size_t i, j, k;
for(j = 0, pO = pOrg; j < 4; j ++, pO += 16){
if(bFlipV[oOrientation])
for(i = 0; i < 16; i += 4)
pO[pT[i + 1]] = -pO[pT[i + 1]], pO[pT[i + 3]] = -pO[pT[i + 3]];
if(bFlipH[oOrientation])
for(i = 0; i < 4; i ++)
pO[pT[i + 4]] = -pO[pT[i + 4]], pO[pT[i + 12]] = -pO[pT[i + 12]];
}
for(j = 0; j < 2; j ++)
for(i = 0; i < 2; i ++){
size_t ii = (bFlipV[oOrientation] ? 1 - i : i);
size_t jj = (bFlipH[oOrientation] ? 1 - j : j);
if(oOrientation < O_RCW)
memcpy(pDst + (jj * 2 + ii) * 16, pOrg + (j * 2 + i) * 16, 16 * sizeof(PixelI));
else{
pO = pOrg + (j * 2 + i) * 16;
pD = pDst + (ii * 2 + jj) * 16;
for(k = 1; k < 16; k ++)
pD[pT[k]] = pO[pT[(k >> 2) + ((k & 3) << 2)]];
}
}
}
Int getROI(CWMImageInfo * pII, CCoreParameters * pCore, CWMIStrCodecParam * pSCP, CWMTranscodingParam * pParam)
{
const ORIENTATION oO = pParam->oOrientation;
size_t iLeft, iTop, cWidth, cHeight, i, j;
size_t mbLeft, mbRight, mbTop, mbBottom;
size_t * iTile = (size_t *)malloc(MAX_TILES * sizeof(size_t));
if(iTile == NULL)
return ICERR_ERROR;
if(pParam->cLeftX + pParam->cWidth > pII->cWidth || pParam->cTopY + pParam->cHeight > pII->cHeight) // invalid region
return ICERR_ERROR;
cWidth = pParam->cWidth, cHeight = pParam->cHeight;
iLeft = pParam->cLeftX + pCore->cExtraPixelsLeft, iTop = pParam->cTopY + pCore->cExtraPixelsTop;
if(pSCP->olOverlap != OL_NONE && pParam->bIgnoreOverlap == FALSE){ // include pixels borrowed
size_t cBlurred = (pSCP->olOverlap == OL_TWO ? 10 : 2);
if(iLeft > cBlurred)
iLeft -= cBlurred, cWidth += cBlurred;
else
cWidth += iLeft, iLeft = 0;
if(iTop > cBlurred)
iTop -= cBlurred, cHeight += cBlurred;
else
cHeight += iTop, iTop = 0;
cWidth += cBlurred, cHeight += cBlurred;
if(iLeft + cWidth > pII->cWidth + pCore->cExtraPixelsLeft + pCore->cExtraPixelsRight)
cWidth = pII->cWidth + pCore->cExtraPixelsLeft + pCore->cExtraPixelsRight - iLeft;
if(iTop + cHeight > pII->cHeight + pCore->cExtraPixelsTop + pCore->cExtraPixelsBottom)
cHeight = pII->cHeight + pCore->cExtraPixelsTop + pCore->cExtraPixelsBottom - iTop;
}
mbTop = (iTop >> 4), mbLeft = (iLeft >> 4);
mbBottom = (iTop + cHeight + 15) >> 4, mbRight = (iLeft + cWidth + 15) >> 4;
pCore->cExtraPixelsLeft += pParam->cLeftX - (mbLeft << 4);
pCore->cExtraPixelsRight = ((mbRight - mbLeft) << 4) - pParam->cWidth - pCore->cExtraPixelsLeft;
pCore->cExtraPixelsTop += pParam->cTopY - (mbTop << 4);
pCore->cExtraPixelsBottom = ((mbBottom - mbTop) << 4) - pParam->cHeight - pCore->cExtraPixelsTop;
pII->cWidth = ((mbRight - mbLeft) << 4) - pCore->cExtraPixelsLeft - pCore->cExtraPixelsRight;
pII->cHeight = ((mbBottom - mbTop) << 4) - pCore->cExtraPixelsTop - pCore->cExtraPixelsBottom;
pParam->cLeftX = iLeft, pParam->cTopY = iTop;
pParam->cWidth = cWidth, pParam->cHeight = cHeight;
// extra pixels in transformed space
#define SWAP(a, b) i = a, a = b, b = i
if(oO == O_FLIPH || oO == O_FLIPVH || oO == O_RCW_FLIPV || oO == O_RCW_FLIPVH)
SWAP(pCore->cExtraPixelsLeft, pCore->cExtraPixelsRight);
if(oO == O_FLIPV || oO == O_FLIPVH || oO == O_RCW || oO == O_RCW_FLIPV)
SWAP(pCore->cExtraPixelsTop, pCore->cExtraPixelsBottom);
if(oO >= O_RCW){
SWAP(pCore->cExtraPixelsLeft, pCore->cExtraPixelsTop);
SWAP(pCore->cExtraPixelsRight, pCore->cExtraPixelsBottom);
}
// adjust tiling
for(i = 0, j = 0, iTile[0] = 0; i <= (size_t)pSCP->cNumOfSliceMinus1V; i ++)
if((size_t)pSCP->uiTileX[i] >= mbLeft && (size_t)pSCP->uiTileX[i] < mbRight){
if(j >= MAX_TILES)
j = MAX_TILES - 1;
iTile[j] = (size_t)pSCP->uiTileX[i] - mbLeft, j ++;
}
if(iTile[0] == 0)
for(i = 0, pSCP->cNumOfSliceMinus1V = (j == 0 ? 0 : (U32)(j - 1)); i < j; i ++)
pSCP->uiTileX[i] = (U32)iTile[i];
else
for(i = 1, pSCP->uiTileX[0] = 0, pSCP->cNumOfSliceMinus1V = (U32)j; i <= j; i ++)
pSCP->uiTileX[i] = (U32)iTile[i - 1];
if(oO == O_FLIPH || oO == O_FLIPVH || oO == O_RCW_FLIPV || oO == O_RCW_FLIPVH){ // reverse order
for(i = 0; i <= (size_t)pSCP->cNumOfSliceMinus1V; i ++)
iTile[i] = mbRight - mbLeft - (size_t)pSCP->uiTileX[i];
for(i = 1, pSCP->uiTileX[0] = 0; i <= (size_t)pSCP->cNumOfSliceMinus1V; i ++)
pSCP->uiTileX[i] = (U32)(iTile[(size_t)pSCP->cNumOfSliceMinus1V - i + 1]);
}
for(i = 0, j = 0, iTile[0] = 0; i <= (size_t)pSCP->cNumOfSliceMinus1H; i ++)
if(pSCP->uiTileY[i] >= mbTop && pSCP->uiTileY[i] < mbBottom){
if(j >= MAX_TILES)
j = MAX_TILES - 1;
iTile[j] = (size_t)pSCP->uiTileY[i] - mbTop, j ++;
}
if(iTile[0] == 0)
for(i = 0, pSCP->cNumOfSliceMinus1H = (j == 0 ? 0 : (U32)(j - 1)); i < j; i ++)
pSCP->uiTileY[i] = (U32)iTile[i];
else
for(i = 1, pSCP->uiTileY[0] = 0, pSCP->cNumOfSliceMinus1H = (U32)j; i <= j; i ++)
pSCP->uiTileY[i] = (U32)iTile[i - 1];
if(oO == O_FLIPV || oO == O_FLIPVH || oO == O_RCW || oO == O_RCW_FLIPV){ // reverse order
for(i = 0; i <= (size_t)pSCP->cNumOfSliceMinus1H; i ++)
iTile[i] = mbBottom - mbTop - (size_t)pSCP->uiTileY[i];
for(i = 1, pSCP->uiTileY[0] = 0; i <= (size_t)pSCP->cNumOfSliceMinus1H; i ++)
pSCP->uiTileY[i] = (U32)(iTile[(size_t)pSCP->cNumOfSliceMinus1H - i + 1]);
}
if(oO >= O_RCW){ // switch X & Y
for(i = 0; i <= (size_t)pSCP->cNumOfSliceMinus1V; i ++)
iTile[i] = (size_t)pSCP->uiTileX[i];
for(i = 0; i <= (size_t)pSCP->cNumOfSliceMinus1H; i ++)
pSCP->uiTileX[i] = pSCP->uiTileY[i];
for(i = 0; i <= (size_t)pSCP->cNumOfSliceMinus1V; i ++)
pSCP->uiTileY[i] = (U32)iTile[i];
i = (size_t)pSCP->cNumOfSliceMinus1H, pSCP->cNumOfSliceMinus1H = pSCP->cNumOfSliceMinus1V, pSCP->cNumOfSliceMinus1V = (U32)i;
}
free(iTile);
return ICERR_OK;
}
Bool isTileBoundary(U32 * pTilePos, U32 cTiles, U32 cMBs, U32 iPos)
{
U32 i;
for(i = 0; i < cTiles; i ++)
if(iPos == pTilePos[i] * 16)
break;
return ((i < cTiles || (iPos + 15) / 16 >= cMBs) ? TRUE : FALSE);
}
Bool isTileExtraction(CWMImageStrCodec * pSC, CWMTranscodingParam * pParam)
{
if(pParam->bIgnoreOverlap == FALSE && pSC->WMISCP.olOverlap == OL_NONE)
pParam->bIgnoreOverlap = TRUE;
if(pParam->bIgnoreOverlap == TRUE && pParam->oOrientation == O_NONE && pParam->bfBitstreamFormat == pSC->WMISCP.bfBitstreamFormat){
if(pParam->bfBitstreamFormat == SPATIAL && pParam->sbSubband != pSC->WMISCP.sbSubband)
return FALSE;
return (isTileBoundary(pSC->WMISCP.uiTileX, pSC->WMISCP.cNumOfSliceMinus1V + 1, (U32)pSC->cmbWidth, (U32)(pParam->cLeftX + pSC->m_param.cExtraPixelsLeft)) &&
isTileBoundary(pSC->WMISCP.uiTileY, pSC->WMISCP.cNumOfSliceMinus1H + 1, (U32)pSC->cmbHeight, (U32)(pParam->cTopY + pSC->m_param.cExtraPixelsTop)) &&
isTileBoundary(pSC->WMISCP.uiTileX, pSC->WMISCP.cNumOfSliceMinus1V + 1, (U32)pSC->cmbWidth, (U32)(pParam->cLeftX + pParam->cWidth + pSC->m_param.cExtraPixelsLeft)) &&
isTileBoundary(pSC->WMISCP.uiTileY, pSC->WMISCP.cNumOfSliceMinus1H + 1, (U32)pSC->cmbHeight, (U32)(pParam->cTopY + pParam->cHeight + pSC->m_param.cExtraPixelsTop)));
}
return FALSE;
}
Int WMPhotoTranscode(struct WMPStream * pStreamIn, struct WMPStream * pStreamOut, CWMTranscodingParam * pParam)
{
PixelI * pMBBuf, MBBufAlpha[256]; // shared buffer, decoder <=> encoder bridge
PixelI * pFrameBuf = NULL, * pFrameBufAlpha = NULL;
CWMIMBInfo * pMBInfo = NULL, * pMBInfoAlpha = NULL;
CWMImageStrCodec * pSCDec, * pSCEnc, * pSC;
CWMDecoderParameters aDecoderParam = {0};
U8 * pIOHeaderDec, * pIOHeaderEnc;
CCodingContext * pContext;
CTileQPInfo * pTileQPInfo = NULL;
ORIENTATION oO = pParam->oOrientation;
size_t iAlphaPos = 0;
size_t cUnit;
size_t i, j, mbLeft, mbRight, mbTop, mbBottom, mbWidth, mbHeight;
if(pStreamIn == NULL || pStreamOut == NULL || pParam == NULL)
return ICERR_ERROR;
// initialize decoder
if((pSCDec = (CWMImageStrCodec *)malloc(sizeof(CWMImageStrCodec))) == NULL)
return ICERR_ERROR;
memset(pSCDec, 0, sizeof(CWMImageStrCodec));
pSCDec->WMISCP.pWStream = pStreamIn;
if(ReadWMIHeader(&pSCDec->WMII, &pSCDec->WMISCP, &pSCDec->m_param) != ICERR_OK)
return ICERR_ERROR;
if(pSCDec->WMISCP.cfColorFormat == YUV_422 && oO >= O_RCW)
pParam->oOrientation = oO = O_NONE; // Can not rotate 422 in compressed domain!
pSCDec->cmbWidth = (pSCDec->WMII.cWidth + pSCDec->m_param.cExtraPixelsLeft + pSCDec->m_param.cExtraPixelsRight + 15) / 16;
pSCDec->cmbHeight = (pSCDec->WMII.cHeight + pSCDec->m_param.cExtraPixelsTop + pSCDec->m_param.cExtraPixelsBottom + 15) / 16;
pSCDec->m_param.cNumChannels = pSCDec->WMISCP.cChannel;
pSCDec->m_Dparam = &aDecoderParam;
pSCDec->m_Dparam->bSkipFlexbits = (pSCDec->WMISCP.sbSubband == SB_NO_FLEXBITS);
pSCDec->m_param.bTranscode = TRUE;
pParam->bIgnoreOverlap = isTileExtraction(pSCDec, pParam);
cUnit = (pSCDec->m_param.cfColorFormat == YUV_420 ? 384 : (pSCDec->m_param.cfColorFormat == YUV_422 ? 512 : 256 * pSCDec->m_param.cNumChannels));
if(cUnit > 256 * MAX_CHANNELS)
return ICERR_ERROR;
pSCDec->p1MBbuffer[0] = pMBBuf = (PixelI *)malloc(cUnit * sizeof(PixelI));
if(pMBBuf == NULL)
return ICERR_ERROR;
pSCDec->p1MBbuffer[1] = pSCDec->p1MBbuffer[0] + 256;
for(i = 2; i < pSCDec->m_param.cNumChannels; i ++)
pSCDec->p1MBbuffer[i] = pSCDec->p1MBbuffer[i - 1] + (pSCDec->m_param.cfColorFormat == YUV_420 ? 64 : (pSCDec->m_param.cfColorFormat == YUV_422 ? 128 : 256));
if(pSCDec->m_param.bAlphaChannel){ // alpha channel
SimpleBitIO SB = {0};
iAlphaPos = pSCDec->m_param.cNumChannels;
if((pSCDec->m_pNextSC = (CWMImageStrCodec *)malloc(sizeof(CWMImageStrCodec))) == NULL)
return ICERR_ERROR;
*pSCDec->m_pNextSC = *pSCDec;
pSCDec->m_pNextSC->p1MBbuffer[0] = MBBufAlpha;
pSCDec->m_pNextSC->WMISCP.cfColorFormat = pSCDec->m_pNextSC->WMII.cfColorFormat = pSCDec->m_pNextSC->m_param.cfColorFormat = Y_ONLY;
pSCDec->m_pNextSC->WMISCP.cChannel = pSCDec->m_pNextSC->m_param.cNumChannels = 1;
pSCDec->m_pNextSC->m_bSecondary = TRUE;
pSCDec->m_pNextSC->m_pNextSC = pSCDec;
// read plane header of second image plane
if(attach_SB(&SB, pSCDec->WMISCP.pWStream) != ICERR_OK)
return ICERR_ERROR;
ReadImagePlaneHeader(&pSCDec->m_pNextSC->WMII, &pSCDec->m_pNextSC->WMISCP, &pSCDec->m_pNextSC->m_param, &SB);
detach_SB(&SB);
if(StrDecInit(pSCDec->m_pNextSC) != ICERR_OK)
return ICERR_ERROR;
}
else
pParam->uAlphaMode = 0;
pIOHeaderDec = (U8 *)malloc((PACKETLENGTH * 4 - 1) + PACKETLENGTH * 4 + sizeof(BitIOInfo));
if(pIOHeaderDec == NULL)
return ICERR_ERROR;
memset(pIOHeaderDec, 0, (PACKETLENGTH * 4 - 1) + PACKETLENGTH * 4 + sizeof(BitIOInfo));
pSCDec->pIOHeader = (BitIOInfo *)((U8 *)ALIGNUP(pIOHeaderDec, PACKETLENGTH * 4) + PACKETLENGTH * 2);
if(StrIODecInit(pSCDec) != ICERR_OK)
return ICERR_ERROR;
if(StrDecInit(pSCDec) != ICERR_OK)
return ICERR_ERROR;
if(pSCDec->m_param.bAlphaChannel){ // alpha channel
if(StrDecInit(pSCDec->m_pNextSC) != ICERR_OK)
return ICERR_ERROR;
}
// initialize encoder
if((pSCEnc = (CWMImageStrCodec *)malloc(sizeof(CWMImageStrCodec))) == NULL)
return ICERR_ERROR;
memset(pSCEnc, 0, sizeof(CWMImageStrCodec));
pSCEnc->WMII = pSCDec->WMII;
pSCEnc->WMISCP = pSCDec->WMISCP;
pSCEnc->m_param = pSCDec->m_param;
pSCEnc->WMISCP.pWStream = pStreamOut;
pSCEnc->WMISCP.bfBitstreamFormat = pParam->bfBitstreamFormat;
// pSCEnc->m_param.cfColorFormat = pSCEnc->WMISCP.cfColorFormat = pParam->cfColorFormat;
pSCEnc->m_param.cfColorFormat = pSCEnc->WMISCP.cfColorFormat;
pSCEnc->m_param.cNumChannels = (pSCEnc->WMISCP.cfColorFormat == Y_ONLY ? 1 : (pSCEnc->WMISCP.cfColorFormat == YUV_444 ? 3 : pSCEnc->WMISCP.cChannel));
pSCEnc->m_param.bAlphaChannel = (pParam->uAlphaMode > 0);
pSCEnc->m_param.bTranscode = TRUE;
if(pParam->sbSubband >= SB_MAX)
pParam->sbSubband = SB_ALL;
if(pParam->sbSubband > pSCEnc->WMISCP.sbSubband)
pSCEnc->WMISCP.sbSubband = pParam->sbSubband;
pSCEnc->m_bSecondary = FALSE;
pIOHeaderEnc = (U8 *)malloc((PACKETLENGTH * 4 - 1) + PACKETLENGTH * 4 + sizeof(BitIOInfo));
if(pIOHeaderEnc == NULL)
return ICERR_ERROR;
memset(pIOHeaderEnc, 0, (PACKETLENGTH * 4 - 1) + PACKETLENGTH * 4 + sizeof(BitIOInfo));
pSCEnc->pIOHeader = (BitIOInfo *)((U8 *)ALIGNUP(pIOHeaderEnc, PACKETLENGTH * 4) + PACKETLENGTH * 2);
for(i = 0; i < pSCEnc->m_param.cNumChannels; i ++)
pSCEnc->pPlane[i] = pSCDec->p1MBbuffer[i];
for(i = 1; i < pSCDec->cNumBitIO * (pSCDec->WMISCP.cNumOfSliceMinus1H + 1); i ++){
if(pSCDec->pIndexTable[i] == 0 && i + 1 != pSCDec->cNumBitIO * (pSCDec->WMISCP.cNumOfSliceMinus1H + 1)) // empty packet
pSCDec->pIndexTable[i] = pSCDec->pIndexTable[i + 1];
if(pSCDec->pIndexTable[i] != 0 && pSCDec->pIndexTable[i] < pSCDec->pIndexTable[i - 1]) // out of order bitstream, can not do fast tile extraction!
pParam->bIgnoreOverlap = FALSE;
}
if(getROI(&pSCEnc->WMII, &pSCEnc->m_param, &pSCEnc->WMISCP, pParam) != ICERR_OK)
return ICERR_ERROR;
mbLeft = (pParam->cLeftX >> 4);
mbRight = ((pParam->cLeftX + pParam->cWidth + 15) >> 4);
mbTop = (pParam->cTopY >> 4);
mbBottom = ((pParam->cTopY + pParam->cHeight + 15) >> 4);
if(pSCDec->WMISCP.uiTileX[pSCDec->WMISCP.cNumOfSliceMinus1V] >= mbLeft && pSCDec->WMISCP.uiTileX[pSCDec->WMISCP.cNumOfSliceMinus1V] <= mbRight &&
pSCDec->WMISCP.uiTileY[pSCDec->WMISCP.cNumOfSliceMinus1H] >= mbTop && pSCDec->WMISCP.uiTileY[pSCDec->WMISCP.cNumOfSliceMinus1H] <= mbBottom)
pParam->bIgnoreOverlap = FALSE;
pSCEnc->bTileExtraction = pParam->bIgnoreOverlap;
mbWidth = pSCEnc->cmbWidth = mbRight - mbLeft;
mbHeight = pSCEnc->cmbHeight = mbBottom - mbTop;
if(oO >= O_RCW){
SWAP(pSCEnc->WMII.cWidth, pSCEnc->WMII.cHeight);
SWAP(pSCEnc->cmbWidth, pSCEnc->cmbHeight);
}
if(oO != O_NONE){
pFrameBuf = (PixelI *)malloc(pSCEnc->cmbWidth * pSCEnc->cmbHeight * cUnit * sizeof(PixelI));
if(pFrameBuf == NULL || (pSCEnc->cmbWidth * pSCEnc->cmbHeight * cUnit * sizeof(PixelI) < pSCEnc->cmbWidth * pSCEnc->cmbHeight * cUnit))
return ICERR_ERROR;
pMBInfo = (CWMIMBInfo *)malloc(pSCEnc->cmbWidth * pSCEnc->cmbHeight * sizeof(CWMIMBInfo));
if(pMBInfo == NULL || (pSCEnc->cmbWidth * pSCEnc->cmbHeight * sizeof(CWMIMBInfo) < pSCEnc->cmbWidth * pSCEnc->cmbHeight))
return ICERR_ERROR;
if(pParam->uAlphaMode > 0){ // alpha channel
pFrameBufAlpha = (PixelI *)malloc(pSCEnc->cmbWidth * pSCEnc->cmbHeight * 256 * sizeof(PixelI));
if(pFrameBufAlpha == NULL || (pSCEnc->cmbWidth * pSCEnc->cmbHeight * 256 * sizeof(PixelI) < pSCEnc->cmbWidth * pSCEnc->cmbHeight * 256))
return ICERR_ERROR;
pMBInfoAlpha = (CWMIMBInfo *)malloc(pSCEnc->cmbWidth * pSCEnc->cmbHeight * sizeof(CWMIMBInfo));
if(pMBInfoAlpha == NULL || (pSCEnc->cmbWidth * pSCEnc->cmbHeight * sizeof(CWMIMBInfo) < pSCEnc->cmbWidth * pSCEnc->cmbHeight))
return ICERR_ERROR;
}
}
if(oO < O_RCW && pSCEnc->WMII.oOrientation < O_RCW)
pSCEnc->WMII.oOrientation ^= oO;
else if(oO >= O_RCW && pSCEnc->WMII.oOrientation >= O_RCW){
pSCEnc->WMII.oOrientation ^= oO;
pSCEnc->WMII.oOrientation = (pSCEnc->WMII.oOrientation & 1) * 2 + (pSCEnc->WMII.oOrientation >> 1);
}
else if(oO >= O_RCW && pSCEnc->WMII.oOrientation < O_RCW)
pSCEnc->WMII.oOrientation = oO ^ ((pSCEnc->WMII.oOrientation & 1) * 2 + (pSCEnc->WMII.oOrientation >> 1));
else
pSCEnc->WMII.oOrientation ^= ((oO & 1) * 2 + (oO >> 1));
// pSCEnc->WMISCP.nExpBias += 128;
if(pParam->bIgnoreOverlap == TRUE){
attachISWrite(pSCEnc->pIOHeader, pSCEnc->WMISCP.pWStream);
pSCEnc->pTile = pSCDec->pTile;
if(pSCEnc->WMISCP.cNumOfSliceMinus1H + pSCEnc->WMISCP.cNumOfSliceMinus1V == 0 && pSCEnc->WMISCP.bfBitstreamFormat == SPATIAL)
pSCEnc->m_param.bIndexTable = FALSE;
WriteWMIHeader(pSCEnc);
}
else{
pTileQPInfo = (CTileQPInfo *)malloc((oO == O_NONE ? 1 : (pSCEnc->WMISCP.cNumOfSliceMinus1H + 1) * (pSCEnc->WMISCP.cNumOfSliceMinus1V + 1)) * sizeof( CTileQPInfo));
if(pTileQPInfo == NULL || ((oO == O_NONE ? 1 : (pSCEnc->WMISCP.cNumOfSliceMinus1H + 1) * (pSCEnc->WMISCP.cNumOfSliceMinus1V + 1)) * sizeof( CTileQPInfo) < (oO == O_NONE ? 1 : (pSCEnc->WMISCP.cNumOfSliceMinus1H + 1) * (pSCEnc->WMISCP.cNumOfSliceMinus1V + 1))))
return ICERR_ERROR;
if(StrEncInit(pSCEnc) != ICERR_OK)
return ICERR_ERROR;
}
if(pParam->uAlphaMode > 0){ // alpha channel
// pSCEnc->WMISCP.nExpBias -= 128;
if((pSCEnc->m_pNextSC = (CWMImageStrCodec *)malloc(sizeof(CWMImageStrCodec))) == NULL)
return ICERR_ERROR;
*pSCEnc->m_pNextSC = *pSCEnc;
pSCEnc->m_pNextSC->pPlane[0] = pSCDec->m_pNextSC->p1MBbuffer[0];
pSCEnc->m_pNextSC->WMISCP.cfColorFormat = pSCEnc->m_pNextSC->WMII.cfColorFormat = pSCEnc->m_pNextSC->m_param.cfColorFormat = Y_ONLY;
pSCEnc->m_pNextSC->WMISCP.cChannel = pSCEnc->m_pNextSC->m_param.cNumChannels = 1;
pSCEnc->m_pNextSC->m_bSecondary = TRUE;
pSCEnc->m_pNextSC->m_pNextSC = pSCEnc;
pSCEnc->m_pNextSC->m_param = pSCDec->m_pNextSC->m_param;
pSCEnc->m_param.bAlphaChannel = TRUE;
if(pParam->bIgnoreOverlap == TRUE)
pSCEnc->m_pNextSC->pTile = pSCDec->m_pNextSC->pTile;
else if(StrEncInit(pSCEnc->m_pNextSC) != ICERR_OK)
return ICERR_ERROR;
WriteImagePlaneHeader(pSCEnc->m_pNextSC);
}
if(pParam->bIgnoreOverlap == TRUE){
SUBBAND sbEnc = pSCEnc->WMISCP.sbSubband, sbDec = pSCDec->WMISCP.sbSubband;
size_t cfEnc = ((pSCEnc->WMISCP.bfBitstreamFormat == SPATIAL || sbEnc == SB_DC_ONLY) ? 1 : (sbEnc == SB_NO_HIGHPASS ? 2 : (sbEnc == SB_NO_FLEXBITS ? 3 : 4)));
size_t cfDec = ((pSCDec->WMISCP.bfBitstreamFormat == SPATIAL || sbDec == SB_DC_ONLY) ? 1 : (sbDec == SB_NO_HIGHPASS ? 2 : (sbDec == SB_NO_FLEXBITS ? 3 : 4)));
size_t k, l = 0;
pSCEnc->pIndexTable = (size_t *)malloc(sizeof(size_t) * (pSCEnc->WMISCP.cNumOfSliceMinus1H + 1) * (pSCEnc->WMISCP.cNumOfSliceMinus1V + 1) * cfEnc);
if(pSCEnc->pIndexTable == NULL || cfEnc > cfDec)
return ICERR_ERROR;
pSCEnc->cNumBitIO = cfEnc * (pSCEnc->WMISCP.cNumOfSliceMinus1V + 1);
for(j = 0; j <= pSCDec->WMISCP.cNumOfSliceMinus1H; j ++){
for(i = 0; i <= pSCDec->WMISCP.cNumOfSliceMinus1V; i ++)
if(pSCDec->WMISCP.uiTileX[i] >= mbLeft && pSCDec->WMISCP.uiTileX[i] < mbRight &&
pSCDec->WMISCP.uiTileY[j] >= mbTop && pSCDec->WMISCP.uiTileY[j] < mbBottom){
for(k = 0; k < cfEnc; k ++, l ++)
pSCEnc->pIndexTable[l] = pSCDec->pIndexTable[(j * (pSCDec->WMISCP.cNumOfSliceMinus1V + 1) + i) * cfDec + k + 1] - pSCDec->pIndexTable[(j * (pSCDec->WMISCP.cNumOfSliceMinus1V + 1) + i) * cfDec + k];
}
}
if(pSCEnc->WMISCP.cNumOfSliceMinus1H + pSCEnc->WMISCP.cNumOfSliceMinus1V == 0 && pSCEnc->WMISCP.bfBitstreamFormat == SPATIAL){
pSCEnc->m_param.bIndexTable = FALSE;
pSCEnc->cNumBitIO = 0;
writeIndexTableNull(pSCEnc);
}
else
writeIndexTable(pSCEnc);
detachISWrite(pSCEnc, pSCEnc->pIOHeader);
for(j = l = 0; j <= pSCDec->WMISCP.cNumOfSliceMinus1H; j ++){
for(i = 0; i <= pSCDec->WMISCP.cNumOfSliceMinus1V; i ++)
if(pSCDec->WMISCP.uiTileX[i] >= mbLeft && pSCDec->WMISCP.uiTileX[i] < mbRight &&
pSCDec->WMISCP.uiTileY[j] >= mbTop && pSCDec->WMISCP.uiTileY[j] < mbBottom){
for(k = 0; k < cfEnc; k ++){
pSCDec->WMISCP.pWStream->SetPos(pSCDec->WMISCP.pWStream, pSCDec->pIndexTable[(j * (pSCDec->WMISCP.cNumOfSliceMinus1V + 1) + i) * cfDec + k] + pSCDec->cHeaderSize);
copyTo(pSCDec->WMISCP.pWStream, pSCEnc->WMISCP.pWStream, pSCEnc->pIndexTable[l++]);
}
}
}
free(pSCEnc->pIndexTable);
}
else
writeIndexTableNull(pSCEnc);
for(pSCDec->cRow = 0; pSCDec->cRow < mbBottom && pParam->bIgnoreOverlap == FALSE; pSCDec->cRow ++){
for(pSCDec->cColumn = 0; pSCDec->cColumn < pSCDec->cmbWidth; pSCDec->cColumn ++){
Int cRow = (Int)pSCDec->cRow, cColumn = (Int)pSCDec->cColumn;
CWMITile * pTile;
memset(pMBBuf, 0, sizeof(PixelI) * cUnit);
if(pSCDec->m_param.bAlphaChannel){ // alpha channel
memset(pSCDec->m_pNextSC->p1MBbuffer[0], 0, sizeof(PixelI) * 256);
pSCDec->m_pNextSC->cRow = pSCDec->cRow;
pSCDec->m_pNextSC->cColumn = pSCDec->cColumn;
}
// decode
pSC = pSCDec;
for(i = (pSCDec->m_param.bAlphaChannel ? 2 : 1); i > 0; i --){
getTilePos(pSCDec, cColumn, cRow);
if(i == 2){
pSCDec->m_pNextSC->cTileColumn = pSCDec->cTileColumn;
pSCDec->m_pNextSC->cTileRow = pSCDec->cTileRow;
}
if(readPackets(pSCDec) != ICERR_OK)
return ICERR_ERROR;
pContext = &pSCDec->m_pCodingContext[pSCDec->cTileColumn];
if(DecodeMacroblockDC(pSCDec, pContext, cColumn, cRow) != ICERR_OK)
return ICERR_ERROR;
if(pSCDec->cSB > 1)
if(DecodeMacroblockLowpass(pSCDec, pContext, cColumn, cRow) != ICERR_OK)
return ICERR_ERROR;
predDCACDec(pSCDec);
if(pSCDec->cSB > 2)
if(DecodeMacroblockHighpass(pSCDec, pContext, cColumn, cRow) != ICERR_OK)
return ICERR_ERROR;
predACDec(pSCDec);
updatePredInfo(pSCDec, &pSCDec->MBInfo, cColumn, pSCDec->WMISCP.cfColorFormat);
pSCDec = pSCDec->m_pNextSC;
}
pSCDec = pSC;
if(pSCDec->cRow >= mbTop && pSCDec->cColumn >= mbLeft && pSCDec->cColumn < mbRight){
cRow = (Int)(pSCDec->cRow - mbTop);
if(bFlipV[oO])
cRow = (Int)mbHeight - cRow - 1;
cColumn = (Int)(pSCDec->cColumn - mbLeft);
if(bFlipH[oO])
cColumn = (Int)mbWidth - cColumn - 1;
pSCEnc->m_bCtxLeft = pSCEnc->m_bCtxTop = FALSE;
for(i = 0; i <= pSCEnc->WMISCP.cNumOfSliceMinus1H; i ++)
if(pSCEnc->WMISCP.uiTileY[i] == (U32)(oO < O_RCW ? cRow : cColumn)){
pSCEnc->cTileRow = i;
pSCEnc->m_bCtxTop = TRUE;
break;
}
for(i = 0; i <= pSCEnc->WMISCP.cNumOfSliceMinus1V; i ++)
if(pSCEnc->WMISCP.uiTileX[i] == (U32)(oO < O_RCW ? cColumn : cRow)){
pSCEnc->cTileColumn = i;
pSCEnc->m_bCtxLeft = TRUE;
break;
}
if(pSCEnc->m_bCtxLeft && pSCEnc->m_bCtxTop){ // a new tile, buffer tile DQuant info
CTileQPInfo * pTmp = pTileQPInfo;
pTile = pSCDec->pTile + pSCDec->cTileColumn;
if(oO != O_NONE)
pTmp += pSCEnc->cTileRow * (pSCEnc->WMISCP.cNumOfSliceMinus1V + 1) + pSCEnc->cTileColumn;
pTmp->dcMode = pTile->cChModeDC;
for(i = 0; i < pSCEnc->WMISCP.cChannel; i ++)
pTmp->dcIndex[i] = pTile->pQuantizerDC[i][0].iIndex;
if(pSCEnc->WMISCP.sbSubband != SB_DC_ONLY){
pTmp->bUseDC = pTile->bUseDC;
pTmp->lpNum = pTile->cNumQPLP;
if(pTmp->bUseDC == FALSE)
for(j = 0; j < pTmp->lpNum; j ++){
pTmp->lpMode[j] = pTile->cChModeLP[j];
for(i = 0; i < pSCEnc->WMISCP.cChannel; i ++)
pTmp->lpIndex[j][i] = pTile->pQuantizerLP[i][j].iIndex;
}
if(pSCEnc->WMISCP.sbSubband != SB_NO_HIGHPASS){
pTmp->bUseLP = pTile->bUseLP;
pTmp->hpNum = pTile->cNumQPHP;
if(pTmp->bUseLP == FALSE)
for(j = 0; j < pTmp->hpNum; j ++){
pTmp->hpMode[j] = pTile->cChModeHP[j];
for(i = 0; i < pSCEnc->WMISCP.cChannel; i ++)
pTmp->hpIndex[j][i] = pTile->pQuantizerHP[i][j].iIndex;
}
}
}
if(pParam->uAlphaMode > 0){
pTile = pSCDec->m_pNextSC->pTile + pSCDec->cTileColumn;
pTmp->dcIndex[iAlphaPos] = pTile->pQuantizerDC[0][0].iIndex;
if(pSCEnc->WMISCP.sbSubband != SB_DC_ONLY){
pTmp->bUseDCAlpha = pTile->bUseDC;
pTmp->lpNumAlpha = pTile->cNumQPLP;
if(pTmp->bUseDCAlpha == FALSE)
for(j = 0; j < pTmp->lpNumAlpha; j ++)
pTmp->lpIndex[j][iAlphaPos] = pTile->pQuantizerLP[0][j].iIndex;
if(pSCEnc->WMISCP.sbSubband != SB_NO_HIGHPASS){
pTmp->bUseLPAlpha = pTile->bUseLP;
pTmp->hpNumAlpha = pTile->cNumQPHP;
if(pTmp->bUseLPAlpha == FALSE)
for(j = 0; j < pTmp->hpNumAlpha; j ++)
pTmp->hpIndex[j][iAlphaPos] = pTile->pQuantizerHP[0][j].iIndex;
}
}
}
}
if(oO == O_NONE){
// encode
pSCEnc->cColumn = pSCDec->cColumn - mbLeft + 1;
pSCEnc->cRow = pSCDec->cRow + 1 - mbTop;
pSCEnc->MBInfo = pSCDec->MBInfo;
getTilePos(pSCEnc, cColumn, cRow);
if(pSCEnc->m_bCtxLeft && pSCEnc->m_bCtxTop)
transcodeTileHeader(pSCEnc, pTileQPInfo);
if(encodeMB(pSCEnc, cColumn, cRow) != ICERR_OK)
return ICERR_ERROR;
if(pParam->uAlphaMode > 0){
pSCEnc->m_pNextSC->cColumn = pSCDec->cColumn - mbLeft + 1;
pSCEnc->m_pNextSC->cRow = pSCDec->cRow + 1 - mbTop;
getTilePos(pSCEnc->m_pNextSC, cColumn, cRow);
pSCEnc->m_pNextSC->MBInfo = pSCDec->m_pNextSC->MBInfo;
if(encodeMB(pSCEnc->m_pNextSC, cColumn, cRow) != ICERR_OK)
return ICERR_ERROR;
}
}
else{
size_t cOff = (oO < O_RCW ? (size_t)cRow * mbWidth + (size_t)cColumn : (size_t)cRow + mbHeight * (size_t)cColumn);
pMBInfo[cOff] = pSCDec->MBInfo;
memcpy(&pFrameBuf[cOff * cUnit], pMBBuf, cUnit * sizeof(PixelI));
if(pParam->uAlphaMode > 0){
pMBInfoAlpha[cOff] = pSCDec->m_pNextSC->MBInfo;
memcpy(&pFrameBufAlpha[cOff * 256], MBBufAlpha, 256 * sizeof(PixelI));
}
}
}
}
advanceOneMBRow(pSCDec);
if(oO == O_NONE)
advanceOneMBRow(pSCEnc);
}
if(oO != O_NONE){
for(pSCEnc->cRow = 1; pSCEnc->cRow <= pSCEnc->cmbHeight; pSCEnc->cRow ++){
for(pSCEnc->cColumn = 1; pSCEnc->cColumn <= pSCEnc->cmbWidth; pSCEnc->cColumn ++){
Int cRow, cColumn;
size_t cOff = (pSCEnc->cRow - 1) * pSCEnc->cmbWidth + pSCEnc->cColumn - 1;
for(i = 0; i < ((pSCEnc->m_param.cfColorFormat == YUV_420 || pSCEnc->m_param.cfColorFormat == YUV_422) ? 1 : pSCEnc->m_param.cNumChannels); i ++){
transformDCBlock(pMBInfo[cOff].iBlockDC[i], pSCEnc->MBInfo.iBlockDC[i], oO);
transformACBlocks(pFrameBuf + cOff * cUnit + i * 256, pMBBuf + 256 * i, oO);
}
if(pSCEnc->WMISCP.cfColorFormat == YUV_420)
for(i = 0; i < 2; i ++){
transformDCBlock420(pMBInfo[cOff].iBlockDC[i + 1], pSCEnc->MBInfo.iBlockDC[i + 1], oO);
transformACBlocks420(pFrameBuf + cOff * cUnit + 256 + i * 64, pMBBuf + 256 + i * 64, oO);
}
else if(pSCEnc->WMISCP.cfColorFormat == YUV_422)
for(i = 0; i < 2; i ++){
transformDCBlock422(pMBInfo[cOff].iBlockDC[i + 1], pSCEnc->MBInfo.iBlockDC[i + 1], oO);
transformACBlocks422(pFrameBuf + cOff * cUnit + 256 + i * 128, pMBBuf + 256 + i * 128, oO);
}
pSCEnc->MBInfo.iQIndexLP = pMBInfo[cOff].iQIndexLP;
pSCEnc->MBInfo.iQIndexHP = pMBInfo[cOff].iQIndexHP;
cRow = (Int)pSCEnc->cRow - 1;
cColumn = (Int)pSCEnc->cColumn - 1;
getTilePos(pSCEnc, cColumn, cRow);
if(pSCEnc->m_bCtxLeft && pSCEnc->m_bCtxTop)
transcodeTileHeader(pSCEnc, pTileQPInfo + pSCEnc->cTileRow * (pSCEnc->WMISCP.cNumOfSliceMinus1V + 1) + pSCEnc->cTileColumn);
if(encodeMB(pSCEnc, cColumn, cRow) != ICERR_OK)
return ICERR_ERROR;
if(pParam->uAlphaMode > 0){
pSCEnc->m_pNextSC->cColumn = pSCEnc->cColumn;
pSCEnc->m_pNextSC->cRow = pSCEnc->cRow;
getTilePos(pSCEnc->m_pNextSC, cColumn, cRow);
pSCEnc->m_pNextSC->MBInfo = pSCDec->m_pNextSC->MBInfo;
transformDCBlock(pMBInfoAlpha[cOff].iBlockDC[0], pSCEnc->m_pNextSC->MBInfo.iBlockDC[0], oO);
transformACBlocks(pFrameBufAlpha + cOff * 256, MBBufAlpha, oO);
pSCEnc->m_pNextSC->MBInfo.iQIndexLP = pMBInfoAlpha[cOff].iQIndexLP;
pSCEnc->m_pNextSC->MBInfo.iQIndexHP = pMBInfoAlpha[cOff].iQIndexHP;
if(encodeMB(pSCEnc->m_pNextSC, cColumn, cRow) != ICERR_OK)
return ICERR_ERROR;
}
}
advanceOneMBRow(pSCEnc);
}
}
free(pMBBuf);
if(oO != O_NONE){
free(pFrameBuf);
free(pMBInfo);
if(pParam->uAlphaMode > 0){ // alpha channel
free(pFrameBufAlpha);
free(pMBInfoAlpha);
}
}
freePredInfo(pSCDec);
freeTileInfo(pSCDec);
StrIODecTerm(pSCDec);
FreeCodingContextDec(pSCDec);
if(pSCDec->m_param.bAlphaChannel)
free(pSCDec->m_pNextSC);
free(pSCDec);
free(pIOHeaderDec);
if(pParam->bIgnoreOverlap == FALSE){
freePredInfo(pSCEnc);
freeTileInfo(pSCEnc);
StrIOEncTerm(pSCEnc);
free(pTileQPInfo);
FreeCodingContextEnc(pSCEnc);
}
free(pSCEnc);
free(pIOHeaderEnc);
return ICERR_OK;
}

View File

@ -1,199 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
/******************************************************************************
Module Name:
decode.c
Abstract:
Defines the entry point for the console application.
Author:
Revision History:
*******************************************************************************/
#include "../sys/strcodec.h"
#include "decode.h"
#ifdef MEM_TRACE
#define TRACE_MALLOC 1
#define TRACE_NEW 0
#define TRACE_HEAP 0
#include "memtrace.h"
#endif
/******************************************************************
Free Adaptive Huffman Table
******************************************************************/
static Void CleanAH(CAdaptiveHuffman **ppAdHuff)
{
CAdaptiveHuffman *pAdHuff;
if (NULL != ppAdHuff) {
pAdHuff = *ppAdHuff;
if (NULL != pAdHuff) {
free(pAdHuff);
}
*ppAdHuff = NULL;
}
}
static Void CleanAHDec(CCodingContext * pSC)
{
Int kk;
for (kk = 0; kk < NUMVLCTABLES; kk++) {
CleanAH(&(pSC->m_pAHexpt[kk]));
}
CleanAH(&(pSC->m_pAdaptHuffCBPCY));
CleanAH(&(pSC->m_pAdaptHuffCBPCY1));
}
/*************************************************************************
Initialize an adaptive huffman table
*************************************************************************/
static Int InitializeAH(CAdaptiveHuffman **ppAdHuff, Int iSym)
{
Int iMemStatus = 0;
CAdaptiveHuffman *pAdHuff = Allocate(iSym, DECODER);
if (pAdHuff == NULL) {
iMemStatus = -1; // out of memory
goto ErrorExit;
}
//Adapt(pAdHuff, bFixedTables);
//InitHuffman(pAdHuff->m_pHuffman);
//if (ICERR_OK != initHuff(pAdHuff->m_pHuffman, 1, pAdHuff->m_pTable, NULL)) {
// goto ErrorExit;
//}
*ppAdHuff = pAdHuff;
return ICERR_OK;
ErrorExit:
if (pAdHuff) {
free(pAdHuff);
}
*ppAdHuff = NULL;
if (-1 == iMemStatus) {
printf("Insufficient memory to init decoder.\n");
}
return ICERR_ERROR;
}
/*************************************************************************
Context allocation
*************************************************************************/
Int AllocateCodingContextDec(CWMImageStrCodec *pSC, Int iNumContexts)
{
Int i, iCBPSize, k;
static const Int aAlphabet[] = {5,4,8,7,7, 12,6,6,12,6,6,7,7, 12,6,6,12,6,6,7,7};
if (iNumContexts > MAX_TILES || iNumContexts < 1) // only between 1 and MAX_TILES allowed
return ICERR_ERROR;
if (pSC == NULL)
return ICERR_ERROR;
pSC->m_pCodingContext = malloc (iNumContexts * sizeof (CCodingContext));
if (pSC->m_pCodingContext == NULL) {
pSC->cNumCodingContext = 0;
return ICERR_ERROR;
}
memset (pSC->m_pCodingContext, 0, iNumContexts * sizeof (CCodingContext));
pSC->cNumCodingContext = iNumContexts;
iCBPSize = (pSC->m_param.cfColorFormat == Y_ONLY || pSC->m_param.cfColorFormat == NCOMPONENT
|| pSC->m_param.cfColorFormat == CMYK) ? 5 : 9;
/** allocate / initialize members **/
for (i = 0; i < iNumContexts; i++) {
CCodingContext *pContext = &(pSC->m_pCodingContext[i]);
/** allocate adaptive Huffman encoder **/
if (InitializeAH(&pContext->m_pAdaptHuffCBPCY, iCBPSize) != ICERR_OK) {
return ICERR_ERROR;
}
if (InitializeAH(&pContext->m_pAdaptHuffCBPCY1, 5) != ICERR_OK) {
return ICERR_ERROR;
}
for(k = 0; k < NUMVLCTABLES; k ++){
if (InitializeAH(&pContext->m_pAHexpt[k], aAlphabet[k]) != ICERR_OK) {
return ICERR_ERROR;
}
}
ResetCodingContextDec(pContext);
}
return ICERR_OK;
}
/*************************************************************************
Context reset on encoder
*************************************************************************/
Void ResetCodingContextDec(CCodingContext *pContext)
{
Int k;
/** set flags **/
pContext->m_pAdaptHuffCBPCY->m_bInitialize = FALSE;
pContext->m_pAdaptHuffCBPCY1->m_bInitialize = FALSE;
for(k = 0; k < NUMVLCTABLES; k ++)
pContext->m_pAHexpt[k]->m_bInitialize = FALSE;
// reset VLC tables
AdaptLowpassDec (pContext);
AdaptHighpassDec (pContext);
// reset zigzag patterns, totals
InitZigzagScan(pContext);
// reset bit reduction and cbp models
ResetCodingContext(pContext);
}
/*************************************************************************
Context deletion
*************************************************************************/
Void FreeCodingContextDec(CWMImageStrCodec *pSC)
{
Int iContexts = (Int)(pSC->cNumCodingContext), i, k;
if (iContexts > 0 && pSC->m_pCodingContext) {
for (i = 0; i < iContexts; i++) {
CCodingContext *pContext = &(pSC->m_pCodingContext[i]);
CleanAH (&pContext->m_pAdaptHuffCBPCY);
CleanAH (&pContext->m_pAdaptHuffCBPCY1);
for (k = 0; k < NUMVLCTABLES; k++)
CleanAH (&pContext->m_pAHexpt[k]);
}
free (pSC->m_pCodingContext);
}
}

View File

@ -1,142 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_DECODE_H
#define WMI_DECODE_H
typedef struct CWMDecoderParameters {
/** ROI decode **/
Bool bDecodeFullFrame;
Bool bDecodeFullWidth;
/** thumbnail decode **/
Bool bSkipFlexbits;
size_t cThumbnailScale; // 1: cThumbnailScale thumbnail, only supports cThumbnailScale = 2^m for now
Bool bDecodeHP;
Bool bDecodeLP;
// Region of interest decoding
size_t cROILeftX;
size_t cROIRightX;
size_t cROITopY;
size_t cROIBottomY;
// table lookups for rotation and flip
size_t * pOffsetX;
size_t * pOffsetY;
} CWMDecoderParameters;
Void predCBPDec(CWMImageStrCodec *, CCodingContext *);
Void predDCACDec(CWMImageStrCodec *);
Void predACDec(CWMImageStrCodec *);
Int dequantizeMacroblock(CWMImageStrCodec *);
Int invTransformMacroblock(CWMImageStrCodec * pSC);
Int invTransformMacroblock_alteredOperators_hard(CWMImageStrCodec * pSC);
Int DecodeMacroblockDC(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
Int DecodeMacroblockLowpass(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
Int DecodeMacroblockHighpass(CWMImageStrCodec * pSC, CCodingContext *pContext, Int iMBX, Int iMBY);
Int AdaptLowpassDec(struct CCodingContext *);
Int AdaptHighpassDec(struct CCodingContext *);
Void ResetCodingContextDec(CCodingContext *pContext);
Void FreeCodingContextDec(struct CWMImageStrCodec *pSC);
/*************************************************************************/
// Inverse transform functions
// 2-point post filter for boundaries (only used in 420 UV DC subband)
Void strPost2(PixelI *, PixelI *);
// 2x2 post filter (only used in 420 UV DC subband)
Void strPost2x2(PixelI *, PixelI *, PixelI *, PixelI *);
/** 4-point post filter for boundaries **/
Void strPost4(PixelI *, PixelI *, PixelI *, PixelI *);
/** data allocation in working buffer (first stage) **/
/** Y, 444 U and V **/
/** 0 1 2 3 **/
/** 32 33 34 35 **/
/** 64 65 66 67 **/
/** 96 97 98 99 **/
/** 420 U and V **/
/** 0 2 4 6 **/
/** 64 66 68 70 **/
/** 128 130 132 134 **/
/** 192 194 196 198 **/
/** 4x4 inverse DCT for first stage **/
Void strIDCT4x4FirstStage(PixelI *);
Void strIDCT4x4Stage1(PixelI*);
Void strIDCT4x4FirstStage420UV(PixelI *);
/** 4x4 post filter for first stage **/
Void strPost4x4FirstStage(PixelI *);
Void strPost4x4Stage1Split(PixelI*, PixelI*, Int, Int, Bool);
Void strPost4x4Stage1(PixelI*, Int, Int, Bool);
Void strPost4x4Stage1Split_alternate(PixelI*, PixelI*, Int);
Void strPost4x4Stage1_alternate(PixelI*, Int);
//Void strPost4x4Stage1Split_420(PixelI*, PixelI*);
//Void strPost4x4Stage1_420(PixelI*);
Void strPost4x4FirstStage420UV(PixelI *);
/** data allocation in working buffer (second stage)**/
/** Y, 444 U and V **/
/** 0 4 8 12 **/
/** 128 132 136 140 **/
/** 256 260 264 268 **/
/** 384 388 392 396 **/
/** 420 U and V **/
/** 0 8 **/
/** 256 264 **/
/** 4x4 invesr DCT for second stage **/
//Void strIDCT4x4SecondStage(PixelI *);
Void strIDCT4x4Stage2(PixelI*);
Void strNormalizeDec(PixelI*, Bool);
Void strDCT2x2dnDec(PixelI *, PixelI *, PixelI *, PixelI *);
/** 4x4 post filter for second stage **/
Void strPost4x4SecondStage(PixelI *);
Void strPost4x4Stage2Split(PixelI*, PixelI*);
Void strPost4x4Stage2Split_alternate(PixelI*, PixelI*);
/** Huffman decode related defines **/
#define HUFFMAN_DECODE_ROOT_BITS_LOG 3
#define HUFFMAN_DECODE_ROOT_BITS (5)
Int getHuff(const short *pDecodeTable, BitIOInfo* pIO);
#endif // WMI_DECODE_H

View File

@ -1,287 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "../sys/windowsmediaphoto.h"
#include "../sys/strcodec.h"
Void smoothMB(PixelI * p1, PixelI * p0, PixelI * q0, PixelI * q1)
{
// p1 p0 | q0 q1
PixelI delta = ((((*q0 - *p0) << 2) + (*p1 - *q1)) >> 3);
*q0 -= delta;
*p0 += delta;
}
Void smooth(PixelI * p2, PixelI * p1, PixelI * p0, PixelI * q0, PixelI * q1, PixelI * q2)
{
// p2 p1 p0 | q0 q1 q2
PixelI delta = ((((*q0 - *p0) << 2) + (*p1 - *q1)) >> 3);
*q0 -= delta;
*p0 += delta;
*p1 = (*p1 >> 1) + ((*p0 + *p2) >> 2);
*q1 = (*q1 >> 1) + ((*q0 + *q2) >> 2);
}
Int initPostProc(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t mbWidth, size_t iNumChannels)
{
size_t i, j, k, l;
Bool b32bit = sizeof(int) == 4;
for(j = 0; j < iNumChannels; j ++){
for(i = 0; i < 2; i ++){
// 2 more are allocated to avoid boundary check
if(b32bit) // integer overlow/underflow check for 32-bit system
if((((mbWidth + 2) >> 16) * sizeof(struct tagPostProcInfo)) & 0xffff0000)
return ICERR_ERROR;
strPostProcInfo[j][i] = (struct tagPostProcInfo *)malloc((mbWidth + 2) * sizeof(struct tagPostProcInfo));
assert(strPostProcInfo[j][i] != NULL);
if(strPostProcInfo[j][i] == NULL){
return ICERR_ERROR;
}
strPostProcInfo[j][i] ++;
// initialize out-of-bound MBs as bumpy (no post at all) to avoid boundary check
// left boundary
strPostProcInfo[j][i][-1].ucMBTexture = 3;
for(l = 0; l < 4; l ++){
for(k = 0; k < 4; k ++){
strPostProcInfo[j][i][-1].ucBlockTexture[l][k] = 3;
}
}
// right boundary
strPostProcInfo[j][i][mbWidth] = strPostProcInfo[j][i][-1];
}
}
return ICERR_OK;
}
Void termPostProc(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t iNumChannels)
{
size_t i, j;
for(j = 0; j < iNumChannels; j ++){
for(i = 0; i < 2; i ++){
if(strPostProcInfo[j][i] != NULL){
free(strPostProcInfo[j][i] - 1);
}
}
}
}
Void slideOneMBRow(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t iNumChannels, size_t mbWidth, Bool top, Bool bottom)
{
size_t i, j;
struct tagPostProcInfo * bar;
for(i = 0; i < iNumChannels; i ++){
// swap previous row and current row
bar = strPostProcInfo[i][0];
strPostProcInfo[i][0] = strPostProcInfo[i][1];
strPostProcInfo[i][1] = bar;
if(top){ // if top row, previous row is out of boundary
for(j = 0; j < mbWidth; j ++){
strPostProcInfo[i][0][j] = strPostProcInfo[i][0][-1]; // set as bumpy
}
}
if(bottom){ // if bottom bottom row, set current row of MBs (out of boundary) as bumpy
for(j = 0; j < mbWidth; j ++){
strPostProcInfo[i][1][j] = strPostProcInfo[i][1][-1]; // set as bumpy
}
}
}
}
// get DC and texture infomation right before transform
Void updatePostProcInfo(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * pMB, size_t mbX, size_t cc)
{
size_t i, j;
struct tagPostProcInfo * pMBInfo = strPostProcInfo[cc][1] + mbX;
// DC of MB
pMBInfo->iMBDC = pMB[0];
// texture of MB
pMBInfo->ucMBTexture = 0; // smooth
for(i = 16; i < 256; i += 16){
if(pMB[i] != 0){
pMBInfo->ucMBTexture = 3; // bumpy
break;
}
}
// DCs of blocks not available yet, will collect after demacroblocking
// textures of blocks
for(j = 0; j < 4; j ++)
for(i = 0; i < 4; i ++){
PixelI * p = pMB + i * 64 + j * 16;
size_t k;
for(k = 1, pMBInfo->ucBlockTexture[j][i] = 0; k < 16; k ++){
if(p[k] != 0){
pMBInfo->ucBlockTexture[j][i] = 3;
break;
}
}
}
}
// demacroblock critirion: two MBs have same texture other than bumpy and DCs differ less than 1
#define DMB(a, b) (a->ucMBTexture + b->ucMBTexture == 0) && (abs(a->iMBDC - b->iMBDC) <= threshold)
// demacroblock and get DCs of blocks
Void postProcMB(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p0, PixelI * p1, size_t mbX, size_t cc, Int threshold)
{
/* 4 MBs involved, current MB is d, we have 4 2-pixel boundary segments */
/* | */
/* a | b */
/* - - + + */
/* c ! d */
/* ! */
struct tagPostProcInfo * pMBb = strPostProcInfo[cc][0] + mbX, * pMBa = pMBb - 1, * pMBd = strPostProcInfo[cc][1] + mbX, * pMBc = pMBd - 1;
// demacroblock segment --
if(DMB(pMBa, pMBc)){
smoothMB(p0 - 256 + 10 * 16, p0 - 256 + 11 * 16, p1 - 256 + 8 * 16, p1 - 256 + 9 * 16);
smoothMB(p0 - 256 + 14 * 16, p0 - 256 + 15 * 16, p1 - 256 + 12 * 16, p1 - 256 + 13 * 16);
}
// demacroblock segment ++
if(DMB(pMBb, pMBd)){
smoothMB(p0 + 2 * 16, p0 + 3 * 16, p1 + 0 * 16, p1 + 1 * 16);
smoothMB(p0 + 6 * 16, p0 + 7 * 16, p1 + 4 * 16, p1 + 5 * 16);
}
// demacroblock segment |
if(DMB(pMBa, pMBb)){
smoothMB(p0 - 256 + 10 * 16, p0 - 256 + 14 * 16, p0 + 2 * 16, p0 + 6 * 16);
smoothMB(p0 - 256 + 11 * 16, p0 - 256 + 15 * 16, p0 + 3 * 16, p0 + 7 * 16);
}
// demacroblock segment !
if(DMB(pMBc, pMBd)){
smoothMB(p1 - 256 + 8 * 16, p1 - 256 + 12 * 16, p1 + 0 * 16, p1 + 4 * 16);
smoothMB(p1 - 256 + 9 * 16, p1 - 256 + 13 * 16, p1 + 1 * 16, p1 + 5 * 16);
}
/* update DCs of blocks */
// MB d
pMBd->iBlockDC[0][0] = p1[0 * 16];
pMBd->iBlockDC[0][1] = p1[4 * 16];
pMBd->iBlockDC[1][0] = p1[1 * 16];
pMBd->iBlockDC[1][1] = p1[5 * 16];
// MB b
pMBb->iBlockDC[2][0] = p0[2 * 16];
pMBb->iBlockDC[2][1] = p0[6 * 16];
pMBb->iBlockDC[3][0] = p0[3 * 16];
pMBb->iBlockDC[3][1] = p0[7 * 16];
// MB c
pMBc->iBlockDC[0][2] = p1[ 8 * 16 - 256];
pMBc->iBlockDC[0][3] = p1[12 * 16 - 256];
pMBc->iBlockDC[1][2] = p1[ 9 * 16 - 256];
pMBc->iBlockDC[1][3] = p1[13 * 16 - 256];
// MB a
pMBa->iBlockDC[2][2] = p0[10 * 16 - 256];
pMBa->iBlockDC[2][3] = p0[14 * 16 - 256];
pMBa->iBlockDC[3][2] = p0[11 * 16 - 256];
pMBa->iBlockDC[3][3] = p0[15 * 16 - 256];
}
/* deblock and destair blocks */
/* 4 MBs involved, need to process 16 blocks of a */
/* | */
/* a | b */
/* - - - - */
/* c | d */
/* | */
Void postProcBlock(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p0, PixelI * p1, size_t mbX, size_t cc, Int threshold)
{
size_t i, j, k;
Int dc[5][5];
U8 texture[5][5];
struct tagPostProcInfo * pMBb = strPostProcInfo[cc][0] + mbX, * pMBa = pMBb - 1, * pMBd = strPostProcInfo[cc][1] + mbX, * pMBc = pMBd - 1;
PixelI * pc, * pt;
/* copy DC and Texture info, can be optimized out */
for(j = 0; j < 4; j ++){
// from MB a
for(i = 0; i < 4; i ++){
dc[j][i] = pMBa->iBlockDC[j][i];
texture[j][i] = pMBa->ucBlockTexture[j][i];
}
// 4 blocks from MB c
dc[4][j] = pMBc->iBlockDC[0][j];
texture[4][j] = pMBc->ucBlockTexture[0][j];
// 4 blocks from MB b
dc[j][4] = pMBb->iBlockDC[j][0];
texture[j][4] = pMBb->ucBlockTexture[j][0];
}
// 1 block from MB d
dc[4][4] = pMBd->iBlockDC[0][0];
texture[4][4] = pMBd->ucBlockTexture[0][0];
/* block boundaries */
/* | */
/* | */
/* --- */
for(j = 0; j < 4; j ++){
for(i = 0; i < 4; i ++){
pc = p0 - 256 + i * 64 + j * 16;
// deblock
if(texture[j][i] + texture[j + 1][i] < 3 && abs(dc[j][i] - dc[j + 1][i]) <= threshold){
// smooth horizontal boundary ----
pt = (j < 3 ? pc + 16 : p1 - 256 + i * 64);
for(k = 0; k < 4; k ++){
smooth(pc + idxCC[1][k], pc + idxCC[2][k], pc + idxCC[3][k], pt + idxCC[0][k], pt + idxCC[1][k], pt + idxCC[2][k]);
}
}
// two horizontally adjacent blocks have same texture and similiar DCs
if(texture[j][i] + texture[j][i + 1] < 3 && abs(dc[j][i] - dc[j][i + 1]) <= threshold){
// smooth vertical boundary |
pt = pc + 64;
for(k = 0; k < 4; k ++){
smooth(pc + idxCC[k][1], pc + idxCC[k][2], pc + idxCC[k][3], pt + idxCC[k][0], pt + idxCC[k][1], pt + idxCC[k][2]);
}
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,538 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "../sys/strcodec.h"
#define DEQUANT(iRaw, iQP) ((iRaw) * (iQP))
Void dequantizeBlock4x4(PixelI * pRec, Int * pOrg, const Int * pIndex, Int iQPLP)
{
Int i;
for(i = 1; i < 16; i ++)
pRec[pIndex[i]] = DEQUANT(pOrg[i], iQPLP);
}
Void dequantizeBlock2x2(PixelI * pRec, Int * pOrg, Int iQPLP)
{
pRec[32] = DEQUANT(pOrg[1], iQPLP);
pRec[16] = DEQUANT(pOrg[2], iQPLP);
pRec[48] = DEQUANT(pOrg[3], iQPLP);
}
Void dequantizeBlock4x2(PixelI * pRec, Int * pOrg, Int iQPLP)
{
pRec[ 64] = DEQUANT(pOrg[1], iQPLP);
pRec[ 16] = DEQUANT(pOrg[2], iQPLP);
pRec[ 80] = DEQUANT(pOrg[3], iQPLP);
pRec[ 32] = DEQUANT(pOrg[4], iQPLP);
pRec[ 96] = DEQUANT(pOrg[5], iQPLP);
pRec[ 48] = DEQUANT(pOrg[6], iQPLP);
pRec[112] = DEQUANT(pOrg[7], iQPLP);
}
Int dequantizeMacroblock(CWMImageStrCodec * pSC)
{
const COLORFORMAT cf = pSC->m_param.cfColorFormat;
CWMIMBInfo *pMBInfo = &pSC->MBInfo;
CWMITile * pTile = pSC->pTile + pSC->cTileColumn;
const size_t iChannels = pSC->m_param.cNumChannels;
size_t i;
for(i = 0; i < iChannels; i ++){
//dequantize DC
pSC->p1MBbuffer[i][0] = DEQUANT(pMBInfo->iBlockDC[i][0], pTile->pQuantizerDC[i]->iQP);
// dequantize LP
if(pSC->WMISCP.sbSubband != SB_DC_ONLY)
if(i == 0 || (cf != YUV_422 && cf != YUV_420))
dequantizeBlock4x4(pSC->p1MBbuffer[i] , pMBInfo->iBlockDC[i], dctIndex[2], pTile->pQuantizerLP[i][pMBInfo->iQIndexLP].iQP);
else if(cf == YUV_422)
dequantizeBlock4x2(pSC->p1MBbuffer[i], pMBInfo->iBlockDC[i], pTile->pQuantizerLP[i][pMBInfo->iQIndexLP].iQP);
else // 420
dequantizeBlock2x2(pSC->p1MBbuffer[i], pMBInfo->iBlockDC[i], pTile->pQuantizerLP[i][pMBInfo->iQIndexLP].iQP);
}
return ICERR_OK;
}
/* frequency domain inverse DCAC prediction */
Void predDCACDec(CWMImageStrCodec * pSC)
{
const COLORFORMAT cf = pSC->m_param.cfColorFormat;
const Int iChannels = (cf == YUV_420 || cf == YUV_422) ? 1 : (Int) pSC->m_param.cNumChannels;
CWMIMBInfo *pMBInfo = &(pSC->MBInfo);
size_t mbX = pSC->cColumn;// mbY = pSC->cRow;
Int iDCACPredMode = getDCACPredMode(pSC, mbX);
Int iDCPredMode = (iDCACPredMode & 0x3);
Int iADPredMode = (iDCACPredMode & 0xC);
PixelI * pOrg, * pRef;
Int ii;
for(ii = 0; ii < iChannels; ii ++){
pOrg = pMBInfo->iBlockDC[ii];//[dcBlkIdx + (i >> 4)]; // current DC block
/* DC prediction */
if(iDCPredMode == 1){ // predict DC from top
pOrg[0] += pSC->PredInfoPrevRow[ii][mbX].iDC;
}
else if(iDCPredMode == 0){ // predict DC from left
pOrg[0] += (pSC->PredInfo[ii] + mbX - 1)->iDC;
}
else if(iDCPredMode == 2){// predict DC from top&left
pOrg[0] += ((pSC->PredInfo[ii] + mbX - 1)->iDC + (pSC->PredInfoPrevRow[ii] + mbX)->iDC) >> 1;
}
/* AD prediction */
if(iADPredMode == 4){// predict AD from top
pRef = (pSC->PredInfoPrevRow[ii] + mbX)->piAD;
pOrg[4] += pRef[3], pOrg[8] += pRef[4], pOrg[12] += pRef[5];
}
else if(iADPredMode == 0){// predict AD from left
pRef = (pSC->PredInfo[ii] + mbX - 1)->piAD;
pOrg[1] += pRef[0], pOrg[2] += pRef[1], pOrg[3] += pRef[2];
}
}
if(cf == YUV_420){
for(ii = 1; ii < 3; ii ++){
pOrg = pMBInfo->iBlockDC[ii];//dcBlkIdx + ii]; // current DC block
/* DC prediction */
if(iDCPredMode == 1){ // predict DC from top
pOrg[0] += (pSC->PredInfoPrevRow[ii] + mbX)->iDC;
}
else if(iDCPredMode == 0){ // predict DC from left
pOrg[0] += (pSC->PredInfo[ii] + mbX - 1)->iDC;
}
else if(iDCPredMode == 2){ // predict DC from top&left
pOrg[0] += (((pSC->PredInfo[ii] + mbX - 1)->iDC + (pSC->PredInfoPrevRow[ii] + mbX)->iDC + 1) >> 1);
}
/* AD prediciton */
if(iADPredMode == 4){// predict AD from top
pOrg[2] += (pSC->PredInfoPrevRow[ii] + mbX)->piAD[1];
}
else if(iADPredMode == 0){// predict AD from left
pOrg[1] += (pSC->PredInfo[ii] + mbX - 1)->piAD[0];
}
}
}
else if(cf == YUV_422){
for(ii = 1; ii < 3; ii ++){
pOrg = pMBInfo->iBlockDC[ii];//[dcBlkIdx + ii]; // current DC block
/* DC prediciton */
if(iDCPredMode == 1){ // predict DC from top
pOrg[0] += (pSC->PredInfoPrevRow[ii] + mbX)->iDC;
}
else if(iDCPredMode == 0){ // predict DC from left
pOrg[0] += (pSC->PredInfo[ii] + mbX - 1)->iDC;
}
else if(iDCPredMode == 2){ // predict DC from top&left
pOrg[0] += (((pSC->PredInfo[ii] + mbX - 1)->iDC + (pSC->PredInfoPrevRow[ii] + mbX)->iDC + 1) >> 1);
}
/* AD prediction */
if(iADPredMode == 4){// predict AD from top
pOrg[4] += (pSC->PredInfoPrevRow[ii] + mbX)->piAD[4]; // AC of HT !!!
pOrg[2] += (pSC->PredInfoPrevRow[ii] + mbX)->piAD[3];
pOrg[6] += pOrg[2];
}
else if(iADPredMode == 0){// predict AD from left
pOrg[4] += (pSC->PredInfo[ii] + mbX - 1)->piAD[4]; // AC of HT !!!
pOrg[1] += (pSC->PredInfo[ii] + mbX - 1)->piAD[0];
pOrg[5] += (pSC->PredInfo[ii] + mbX - 1)->piAD[2];
}
else if(iDCPredMode == 1){
pOrg[6] += pOrg[2];
}
}
}
pMBInfo->iOrientation = 2 - getACPredMode(pMBInfo, cf);
}
/*************************************************************************
Frequency domain inverse AC prediction
*************************************************************************/
Void predACDec(CWMImageStrCodec * pSC)
{
const COLORFORMAT cf = pSC->m_param.cfColorFormat;
const Int iChannels = (cf == YUV_420 || cf == YUV_422) ? 1 : (Int) pSC->m_param.cNumChannels;
// size_t mbX = pSC->cColumn, mbY = pSC->cRow;
CWMIMBInfo *pMBInfo = &pSC->MBInfo;
Int iACPredMode = 2 - pMBInfo->iOrientation;
PixelI * pOrg, * pRef;
Int i, j;
/* AC prediction */
for(i = 0; i < iChannels; i++){
// prediction only happens inside MB
PixelI* pSrc = pSC->p1MBbuffer[i];//0 == i ? pSC->pY1 : (1 == i ? pSC->pU1 : pSC->pV1);
switch (iACPredMode)
{
case 1:
{
// predict from top
static U8 blkIdx[] = {1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15};
for (j = 0; j < sizeof(blkIdx) / sizeof(*blkIdx); ++j)
{
pOrg = pSrc + 16 * blkIdx[j];
pRef = pOrg - 16;
pOrg[ 2] += pRef[ 2];
pOrg[10] += pRef[10];
pOrg[ 9] += pRef[ 9];
}
break;
}
case 0:
// predict from left
for (j = 64; j < 256; j += 16)
{
pOrg = pSrc + j;
pRef = pOrg - 64;
pOrg[1] += pRef[1];
pOrg[5] += pRef[5];
pOrg[6] += pRef[6];
}
break;
default:
// no prediction
break;
}
}
if(cf == YUV_420){
for(i = 16; i <= 20; i += 4){
PixelI* pSrc = pSC->p1MBbuffer[(i >> 2) - 3];//16 == i ? pSC->pU1 : pSC->pV1;
switch (iACPredMode)
{
case 1:
{
// predict from top
for (j = 1; j <= 3; j += 2)
{
pOrg = pSrc + 16 * j;
pRef = pOrg - 16;
pOrg[ 2] += pRef[ 2];
pOrg[10] += pRef[10];
pOrg[ 9] += pRef[ 9];
}
break;
}
case 0:
// predict from left
for (j = 2; j <= 3; ++j)
{
pOrg = pSrc + 16 * j;
pRef = pOrg - 32;
pOrg[1] += pRef[1];
pOrg[5] += pRef[5];
pOrg[6] += pRef[6];
}
break;
default:
// no prediction
break;
}
}
}
else if(cf == YUV_422){
for(i = 16; i < 32; i += 8){
PixelI* pSrc = pSC->p1MBbuffer[(i >> 3) - 1];//16 == i ? pSC->pU1 : pSC->pV1;
switch (iACPredMode)
{
case 1:
{
// predict from top
for (j = 2; j < 8; j ++)
{
pOrg = pSrc + blkOffsetUV_422[j];
pRef = pOrg - 16;
pOrg[10] += pRef[10];
pOrg[ 2] += pRef[ 2];
pOrg[ 9] += pRef[ 9];
}
break;
}
case 0:
// predict from left
for (j = 1; j < 8; j += 2)
{
pOrg = pSrc + blkOffsetUV_422[j];
pRef = pOrg - 64;
pOrg[1] += pRef[1];
pOrg[5] += pRef[5];
pOrg[6] += pRef[6];
}
break;
default:
// no prediction
break;
}
}
}
}
/*************************************************************************
CBP
*************************************************************************/
static int NumOnes(int i)
{
int retval = 0;
static const int g_Count[] = { 0,1,1,2, 1,2,2,3, 1,2,2,3, 2,3,3,4 };
i = i & 0xffff;
while (i) {
retval += g_Count[i & 0xf];
i >>= 4;
}
return retval;
}
#define SATURATE32(x) if((unsigned int)(x + 16) >= 32) { if (x < 0) x = -16; else x = 15; }
/* CBP prediction for 16 x 16 MB */
/* block index */
/* 0 1 4 5 */
/* 2 3 6 7 */
/* 8 9 12 13 */
/* 10 11 14 15 */
static Int predCBPCDec(CWMImageStrCodec * pSC, Int iCBP, size_t mbX, size_t mbY, size_t c, CCBPModel *pModel)
{
Int iNOrig;
const int iNDiff = AVG_NDIFF;
size_t c1 = c ? 1 : 0;
UNREFERENCED_PARAMETER( mbY );
if (pModel->m_iState[c1] == 0) {
if(pSC->m_bCtxLeft) {
if (pSC->m_bCtxTop) {
iCBP ^= 1;
}
else {
Int iTopCBP = (pSC->PredInfoPrevRow[c] + mbX)->iCBP;
iCBP ^= (iTopCBP >> 10) & 1; // left: top(10) => 0
}
}
else {
Int iLeftCBP = (pSC->PredInfo[c] + mbX - 1)->iCBP;
iCBP ^= ((iLeftCBP >> 5) & 1); // left(5) => 0
}
iCBP ^= (0x02 & (iCBP << 1)); // 0 => 1
iCBP ^= (0x10 & (iCBP << 3)); // 1 => 4
iCBP ^= (0x20 & (iCBP << 1)); // 4 => 5
iCBP ^= ((iCBP & 0x33) << 2);
iCBP ^= ((iCBP & 0xcc) << 6);
iCBP ^= ((iCBP & 0x3300) << 2);
}
else if (pModel->m_iState[c1] == 2) {
iCBP ^= 0xffff;
}
iNOrig = NumOnes(iCBP);
pModel->m_iCount0[c1] += iNOrig - iNDiff;
SATURATE32(pModel->m_iCount0[c1]);
pModel->m_iCount1[c1] += 16 - iNOrig - iNDiff;
SATURATE32(pModel->m_iCount1[c1]);
if (pModel->m_iCount0[c1] < 0) {
if (pModel->m_iCount0[c1] < pModel->m_iCount1[c1]) {
pModel->m_iState[c1] = 1;
}
else {
pModel->m_iState[c1] = 2;
}
}
else if (pModel->m_iCount1[c1] < 0) {
pModel->m_iState[c1] = 2;
}
else {
pModel->m_iState[c1] = 0;
}
return iCBP;
}
static Int predCBPC420Dec(CWMImageStrCodec * pSC, Int iCBP, size_t mbX, size_t mbY, size_t c, CCBPModel *pModel)
{
Int iNOrig;
const int iNDiff = AVG_NDIFF;
UNREFERENCED_PARAMETER( mbY );
if (pModel->m_iState[1] == 0) {
if(pSC->m_bCtxLeft) {
if (pSC->m_bCtxTop) {
iCBP ^= 1;
}
else {
Int iTopCBP = (pSC->PredInfoPrevRow[c] + mbX)->iCBP;
iCBP ^= (iTopCBP >> 2) & 1; // left: top(2) => 0
}
}
else {
Int iLeftCBP = (pSC->PredInfo[c] + mbX - 1)->iCBP;
iCBP ^= ((iLeftCBP >> 1) & 1); // left(1) => 0
}
iCBP ^= (0x02 & (iCBP << 1)); // 0 => 1
iCBP ^= ((iCBP & 0x3) << 2); // [0 1] -> [2 3]
}
else if (pModel->m_iState[1] == 2) {
iCBP ^= 0xf;
}
iNOrig = NumOnes(iCBP) * 4;
pModel->m_iCount0[1] += iNOrig - iNDiff;
SATURATE32(pModel->m_iCount0[1]);
pModel->m_iCount1[1] += 16 - iNOrig - iNDiff;
SATURATE32(pModel->m_iCount1[1]);
if (pModel->m_iCount0[1] < 0) {
if (pModel->m_iCount0[1] < pModel->m_iCount1[1]) {
pModel->m_iState[1] = 1;
}
else {
pModel->m_iState[1] = 2;
}
}
else if (pModel->m_iCount1[1] < 0) {
pModel->m_iState[1] = 2;
}
else {
pModel->m_iState[1] = 0;
}
return iCBP;
}
static Int predCBPC422Dec(CWMImageStrCodec * pSC, Int iCBP, size_t mbX, size_t mbY, size_t c, CCBPModel *pModel)
{
Int iNOrig;
const int iNDiff = AVG_NDIFF;
UNREFERENCED_PARAMETER( mbY );
if (pModel->m_iState[1] == 0) {
if(pSC->m_bCtxLeft) {
if (pSC->m_bCtxTop) {
iCBP ^= 1;
}
else {
Int iTopCBP = (pSC->PredInfoPrevRow[c] + mbX)->iCBP;
iCBP ^= (iTopCBP >> 6) & 1; // left: top(6) => 0
}
}
else {
Int iLeftCBP = (pSC->PredInfo[c] + mbX - 1)->iCBP;
iCBP ^= ((iLeftCBP >> 1) & 1); // left(1) => 0
}
iCBP ^= (iCBP & 0x1) << 1; // [0]->[1]
iCBP ^= (iCBP & 0x3) << 2; // [0 1]->[2 3]
iCBP ^= (iCBP & 0xc) << 2; // [2 3]->[4 5]
iCBP ^= (iCBP & 0x30) << 2; // [4 5]->[6 7]
}
else if (pModel->m_iState[1] == 2) {
iCBP ^= 0xff;
}
iNOrig = NumOnes(iCBP) * 2;
pModel->m_iCount0[1] += iNOrig - iNDiff;
SATURATE32(pModel->m_iCount0[1]);
pModel->m_iCount1[1] += 16 - iNOrig - iNDiff;
SATURATE32(pModel->m_iCount1[1]);
if (pModel->m_iCount0[1] < 0) {
if (pModel->m_iCount0[1] < pModel->m_iCount1[1]) {
pModel->m_iState[1] = 1;
}
else {
pModel->m_iState[1] = 2;
}
}
else if (pModel->m_iCount1[1] < 0) {
pModel->m_iState[1] = 2;
}
else {
pModel->m_iState[1] = 0;
}
return iCBP;
}
/* Coded Block Pattern (CBP) prediction */
Void predCBPDec(CWMImageStrCodec *pSC, CCodingContext *pContext)
{
const COLORFORMAT cf = pSC->m_param.cfColorFormat;
const size_t iChannels = (cf == YUV_420 || cf == YUV_422) ? 1 : pSC->m_param.cNumChannels;
size_t i, mbX = pSC->cColumn, mbY = pSC->cRow;
CWMIMBInfo *pMBInfo = &(pSC->MBInfo);
for (i = 0; i < iChannels; i++) {
(pSC->PredInfo[i] + mbX)->iCBP = pMBInfo->iCBP[i] = predCBPCDec(pSC, pMBInfo->iDiffCBP[i], mbX, mbY, i, &pContext->m_aCBPModel); // Y Channel
}
if (cf == YUV_422){
(pSC->PredInfo[1] + mbX)->iCBP = pMBInfo->iCBP[1] = predCBPC422Dec(pSC, pMBInfo->iDiffCBP[1], mbX, mbY, 1, &pContext->m_aCBPModel);
(pSC->PredInfo[2] + mbX)->iCBP = pMBInfo->iCBP[2] = predCBPC422Dec(pSC, pMBInfo->iDiffCBP[2], mbX, mbY, 2, &pContext->m_aCBPModel);
}
else if (cf == YUV_420) {
(pSC->PredInfo[1] + mbX)->iCBP = pMBInfo->iCBP[1] = predCBPC420Dec(pSC, pMBInfo->iDiffCBP[1], mbX, mbY, 1, &pContext->m_aCBPModel);
(pSC->PredInfo[2] + mbX)->iCBP = pMBInfo->iCBP[2] = predCBPC420Dec(pSC, pMBInfo->iDiffCBP[2], mbX, mbY, 2, &pContext->m_aCBPModel);
}
//}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,143 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include <stdio.h>
#include <stdlib.h>
#include "encode.h"
#include "../sys/strcodec.h"
#include "../sys/common.h"
#ifdef MEM_TRACE
#define TRACE_MALLOC 1
#define TRACE_NEW 0
#define TRACE_HEAP 0
#include "memtrace.h"
#endif
/*************************************************************************
Context allocation
In theory it is possible to independently set uiTrimFlexBits for
each tile, but for now we assume only one user specified value is
used for the entire image
*************************************************************************/
Int AllocateCodingContextEnc(CWMImageStrCodec *pSC, Int iNumContexts, Int iTrimFlexBits)
{
Int i, iCBPSize, k;
static const Int aAlphabet[] = {5,4,8,7,7, 12,6,6,12,6,6,7,7, 12,6,6,12,6,6,7,7};
if (iTrimFlexBits < 0)
iTrimFlexBits = 0;
else if (iTrimFlexBits > 15)
iTrimFlexBits = 15;
pSC->m_param.bTrimFlexbitsFlag = (iTrimFlexBits > 0);
if (iNumContexts < 1 || iNumContexts > MAX_TILES) // only between 1 and 256 allowed
return ICERR_ERROR;
if (pSC == NULL)
return ICERR_ERROR;
pSC->m_pCodingContext = malloc (iNumContexts * sizeof (CCodingContext));
if (pSC->m_pCodingContext == NULL) {
pSC->cNumCodingContext = 0;
return ICERR_ERROR;
}
memset (pSC->m_pCodingContext, 0, iNumContexts * sizeof (CCodingContext));
pSC->cNumCodingContext = iNumContexts;
iCBPSize = (pSC->m_param.cfColorFormat == Y_ONLY || pSC->m_param.cfColorFormat == NCOMPONENT
|| pSC->m_param.cfColorFormat == CMYK) ? 5 : 9;
/** allocate / initialize members **/
for (i = 0; i < iNumContexts; i++) {
CCodingContext *pContext = &(pSC->m_pCodingContext[i]);
/** allocate adaptive Huffman encoder **/
pContext->m_pAdaptHuffCBPCY = Allocate (iCBPSize, ENCODER);
if(pContext->m_pAdaptHuffCBPCY == NULL) {
return ICERR_ERROR;
}
pContext->m_pAdaptHuffCBPCY1 = Allocate(5, ENCODER);
if(pContext->m_pAdaptHuffCBPCY1 == NULL){
return ICERR_ERROR;
}
for(k = 0; k < NUMVLCTABLES; k ++){
pContext->m_pAHexpt[k] = Allocate(aAlphabet[k], ENCODER);
if(pContext->m_pAHexpt[k] == NULL){
return ICERR_ERROR;
}
}
ResetCodingContextEnc(pContext);
pContext->m_iTrimFlexBits = iTrimFlexBits;
}
return ICERR_OK;
}
/*************************************************************************
Context reset on encoder
*************************************************************************/
Void ResetCodingContextEnc(CCodingContext *pContext)
{
Int k;
/** set flags **/
pContext->m_pAdaptHuffCBPCY->m_bInitialize = FALSE;
pContext->m_pAdaptHuffCBPCY1->m_bInitialize = FALSE;
for(k = 0; k < NUMVLCTABLES; k ++)
pContext->m_pAHexpt[k]->m_bInitialize = FALSE;
// reset VLC tables
AdaptLowpassEnc (pContext);
AdaptHighpassEnc (pContext);
// reset zigzag patterns, totals
InitZigzagScan(pContext);
// reset bit reduction and cbp models
ResetCodingContext(pContext);
}
/*************************************************************************
Context deletion
*************************************************************************/
Void FreeCodingContextEnc(CWMImageStrCodec *pSC)
{
Int iContexts = (Int)(pSC->cNumCodingContext), i, k;
if (iContexts > 0 && pSC->m_pCodingContext) {
for (i = 0; i < iContexts; i++) {
CCodingContext *pContext = &(pSC->m_pCodingContext[i]);
Clean (pContext->m_pAdaptHuffCBPCY);
Clean (pContext->m_pAdaptHuffCBPCY1);
for (k = 0; k < NUMVLCTABLES; k++)
Clean (pContext->m_pAHexpt[k]);
}
free (pSC->m_pCodingContext);
}
}

View File

@ -1,112 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_ENCODE_H
#define WMI_ENCODE_H
#include "../sys/strcodec.h"
/*************************************************************************
struct / class definitions
*************************************************************************/
Int EncodeMacroblockDC(CWMImageStrCodec*, CCodingContext *, Int, Int);
Int EncodeMacroblockLowpass(CWMImageStrCodec*, CCodingContext *, Int, Int);
Int EncodeMacroblockHighpass(CWMImageStrCodec*, CCodingContext *, Int, Int);
Int quantizeMacroblock(CWMImageStrCodec *);
Void transformMacroblock(CWMImageStrCodec *);
Void predMacroblockEnc(CWMImageStrCodec *);
Void AdaptLowpassEnc(CCodingContext *pContext);
Void AdaptHighpassEnc(CCodingContext *pContext);
Void ResetCodingContextEnc(CCodingContext *pContext);
Int AllocateCodingContextEnc(struct CWMImageStrCodec *pSC, Int iNumContexts, Int iTrimFlexBits);
Void FreeCodingContextEnc(struct CWMImageStrCodec *pSC);
Void predCBPEnc(CWMImageStrCodec *pSC, CCodingContext *pContext);
/*************************************************************************
Forward transform definitions
*************************************************************************/
/** 2-point pre filter for boundaries (only used in 420 UV DC subband) **/
Void strPre2(PixelI *, PixelI *);
/** 2x2 pre filter (only used in 420 UV DC subband) **/
Void strPre2x2(PixelI *, PixelI *, PixelI *, PixelI *);
/** 4-point pre filter for boundaries **/
Void strPre4(PixelI *, PixelI *, PixelI *, PixelI *);
/** data allocation in working buffer (first stage) **/
/** Y, 444 U and V **/
/** 0 1 2 3 **/
/** 32 33 34 35 **/
/** 64 65 66 67 **/
/** 96 97 98 99 **/
/** 420 U and V **/
/** 0 2 4 6 **/
/** 64 66 68 70 **/
/** 128 130 132 134 **/
/** 192 194 196 198 **/
/** 4x4 foward DCT for first stage **/
Void strDCT4x4FirstStage(PixelI *);
Void strDCT4x4FirstStage420UV(PixelI *);
Void strDCT4x4Stage1(PixelI*);
/** 4x4 pre filter for first stage **/
Void strPre4x4FirstStage(PixelI *);
Void strPre4x4FirstStage420UV(PixelI *);
Void strPre4x4Stage1Split(PixelI* p0, PixelI* p1, Int iOffset);
Void strPre4x4Stage1(PixelI* p, Int iOffset);
/** data allocation in working buffer (second stage)**/
/** Y, 444 U and V **/
/** 0 4 8 12 **/
/** 128 132 136 140 **/
/** 256 260 264 268 **/
/** 384 388 392 396 **/
/** 420 U and V **/
/** 0 8 **/
/** 256 264 **/
/** 4x4 foward DCT for second stage **/
Void strDCT4x4SecondStage(PixelI *);
Void strNormalizeEnc(PixelI *, Bool);
Void strDCT2x2dnEnc(PixelI *, PixelI *, PixelI *, PixelI *);
/** 4x4 pre filter for second stage **/
Void strPre4x4Stage2Split(PixelI* p0, PixelI* p1);
#endif // ENCODE_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,510 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "../sys/strcodec.h"
#include "encode.h"
I32 QUANT_Mulless(PixelI v, PixelI o, I32 r)
{
const I32 m = v >> 31;
assert(sizeof(PixelI) == sizeof(U32));
return ((((v ^ m) - m + o) >> r) ^ m) - m;
}
I32 MUL32HR(U32 a, U32 b, U32 r)
{
return (I32)((U32)((U64)a * b >> 32) >> r);
}
I32 QUANT(PixelI v, PixelI o, I32 man, I32 exp)
{
const I32 m = v >> 31;
assert(sizeof(PixelI) == sizeof(U32));
return (MUL32HR((v ^ m) - m + o, man, exp) ^ m) - m;
}
Int quantizeMacroblock(CWMImageStrCodec* pSC)
{
CWMITile * pTile = pSC->pTile + pSC->cTileColumn;
CWMIMBInfo * pMBInfo = &pSC->MBInfo;
const COLORFORMAT cf = pSC->m_param.cfColorFormat;
int iChannel, i, j;
if(/*pSC->m_param.bScaledArith && */pSC->m_param.bTranscode == FALSE)
for(iChannel = 0; iChannel < (int)pSC->m_param.cNumChannels; iChannel ++){
const Bool bUV = (iChannel > 0 && (cf == YUV_444 || cf == YUV_422 || cf == YUV_420));
const int iNumBlock = (bUV ? (cf == YUV_422 ? 8 : (cf == YUV_420 ? 4 : 16)) : 16);
const int * pOffset = (iNumBlock == 4 ? blkOffsetUV : (iNumBlock == 8 ? blkOffsetUV_422 : blkOffset));
CWMIQuantizer * pQPDC = pTile->pQuantizerDC[iChannel];
CWMIQuantizer * pQPLP = pTile->pQuantizerLP[iChannel] + pMBInfo->iQIndexLP;
CWMIQuantizer * pQPHP = pTile->pQuantizerHP[iChannel] + pMBInfo->iQIndexHP;
for(j = 0; j < iNumBlock; j ++){
PixelI * pData = pSC->pPlane[iChannel] + pOffset[j];
if(j == 0) // DC
pData[0] = (pQPDC->iMan == 0 ? QUANT_Mulless(pData[0], pQPDC->iOffset, pQPDC->iExp) : QUANT(pData[0], pQPDC->iOffset, pQPDC->iMan, pQPDC->iExp));
else if(pSC->WMISCP.sbSubband != SB_DC_ONLY) // LP
pData[0] = (pQPLP->iMan == 0 ? QUANT_Mulless(pData[0], pQPLP->iOffset, pQPLP->iExp) : QUANT(pData[0], pQPLP->iOffset, pQPLP->iMan, pQPLP->iExp));
// quantize HP
if(pSC->WMISCP.sbSubband != SB_DC_ONLY && pSC->WMISCP.sbSubband != SB_NO_HIGHPASS)
for(i = 1; i < 16; i ++)
pData[i] = (pQPHP->iMan == 0 ? QUANT_Mulless(pData[i], pQPHP->iOffset, pQPHP->iExp) : QUANT(pData[i], pQPHP->iOffset, pQPHP->iMan, pQPHP->iExp));
}
}
for(iChannel = 0; iChannel < (int)pSC->m_param.cNumChannels; iChannel ++){
I32 * pDC = pSC->MBInfo.iBlockDC[iChannel];
PixelI * pData = pSC->pPlane[iChannel];
if(iChannel > 0 && cf == YUV_422){
for(i = 0; i < 8; i ++){
pDC[i] = pData[blkOffsetUV_422[i]];
}
}
else if(iChannel > 0 && cf == YUV_420){
for(i = 0; i < 4; i ++){
pDC[i] = pData[blkOffsetUV[i]];
}
}
else{
for(i = 0; i < 16; i ++){
pDC[i] = pData[dctIndex[2][i]];
}
}
}
return 0;
}
/* frequency domain prediction */
Void predMacroblockEnc(CWMImageStrCodec * pSC)
{
const COLORFORMAT cf = pSC->m_param.cfColorFormat;
const Int iChannels = (cf == YUV_420 || cf == YUV_422) ? 1 : (Int) pSC->m_param.cNumChannels;
size_t mbX = pSC->cColumn - 1;// mbY = pSC->cRow - 1;
CWMIMBInfo *pMBInfo = &(pSC->MBInfo);
Int iDCACPredMode = getDCACPredMode(pSC, mbX);
Int iDCPredMode = (iDCACPredMode & 0x3);
Int iADPredMode = (iDCACPredMode & 0xC);
Int iACPredMode = getACPredMode(pMBInfo, cf);
PixelI * pOrg, * pRef;
Int i, j, k;
pMBInfo->iOrientation = 2 - iACPredMode;
/* keep necessary info for future prediction */
updatePredInfo(pSC, pMBInfo, mbX, cf);
for(i = 0; i < iChannels; i ++){
pOrg = pMBInfo->iBlockDC[i]; // current DC block
/* DC prediction */
if(iDCPredMode == 1){ // predict DC from top
pOrg[0] -= (pSC->PredInfoPrevRow[i] + mbX)->iDC;
}
else if(iDCPredMode == 0){ // predict DC from left
pOrg[0] -= (pSC->PredInfo[i] + mbX - 1)->iDC;
}
else if(iDCPredMode == 2){// predict DC from top&left
pOrg[0] -= ((pSC->PredInfo[i] + mbX - 1)->iDC + (pSC->PredInfoPrevRow[i] + mbX)->iDC) >> 1;
}
/* AD prediction */
if(iADPredMode == 4){// predict AD from top
pRef = (pSC->PredInfoPrevRow[i] + mbX)->piAD;
pOrg[4] -= pRef[3], pOrg[8] -= pRef[4], pOrg[12] -= pRef[5];
}
else if(iADPredMode == 0){// predict AD from left
pRef = (pSC->PredInfo[i] + mbX - 1)->piAD;
pOrg[1] -= pRef[0], pOrg[2] -= pRef[1], pOrg[3] -= pRef[2];
}
pOrg = pSC->pPlane[i];
/* AC prediction */
if(iACPredMode == 1){ // predict from top
for(k = 0; k <= 192; k += 64){
/* inside macroblock, in reverse order */
for(j = 48; j > 0; j -= 16){
pOrg[k + j + 10] -= pOrg[k + j + 10 - 16];
pOrg[k + j + 2] -= pOrg[k + j + 2 - 16];
pOrg[k + j + 9] -= pOrg[k + j + 9 - 16];
}
}
}
else if(iACPredMode == 0){ // predict from left
for(k = 0; k < 64; k += 16){
/* inside macroblock, in reverse order */
for(j = 192; j > 0; j -= 64){
pOrg[k + j + 5] -= pOrg[k + j + 5 - 64];
pOrg[k + j + 1] -= pOrg[k + j + 1 - 64];
pOrg[k + j + 6] -= pOrg[k + j + 6 - 64];
}
}
}
}
if(cf == YUV_420){
for(i = 1; i < 3; i ++){
pOrg = pMBInfo->iBlockDC[i]; // current DC block
/* DC prediciton */
if(iDCPredMode == 1){ // predict DC from top
pOrg[0] -= (pSC->PredInfoPrevRow[i] + mbX)->iDC;
}
else if(iDCPredMode == 0){ // predict DC from left
pOrg[0] -= (pSC->PredInfo[i] + mbX - 1)->iDC;
}
else if(iDCPredMode == 2){ // predict DC from top&left
pOrg[0] -= (((pSC->PredInfo[i] + mbX - 1)->iDC + (pSC->PredInfoPrevRow[i] + mbX)->iDC + 1) >> 1);
}
/* AD prediction */
if(iADPredMode == 4){// predict AD from top
pOrg[2] -= (pSC->PredInfoPrevRow[i] + mbX)->piAD[1];
}
else if(iADPredMode == 0){// predict AD from left
pOrg[1] -= (pSC->PredInfo[i] + mbX - 1)->piAD[0];
}
pOrg = pSC->pPlane[i];
/* AC prediction */
if(iACPredMode == 1){ // predict from top
for(j = 16; j <= 48; j += 32){
/* inside macroblock */
pOrg[j + 10] -= pOrg[j + 10 - 16];
pOrg[j + 2] -= pOrg[j + 2 - 16];
pOrg[j + 9] -= pOrg[j + 9 - 16];
}
}
else if(iACPredMode == 0){ // predict from left
for(j = 32; j <= 48; j += 16){
/* inside macroblock */
pOrg[j + 5] -= pOrg[j + 5 - 32];
pOrg[j + 1] -= pOrg[j + 1 - 32];
pOrg[j + 6] -= pOrg[j + 6 - 32];
}
}
}
}
else if(cf == YUV_422){
for(i = 1; i < 3; i ++){
pOrg = pMBInfo->iBlockDC[i]; // current DC block
/* DC prediciton */
if(iDCPredMode == 1){ // predict DC from top
pOrg[0] -= (pSC->PredInfoPrevRow[i] + mbX)->iDC;
}
else if(iDCPredMode == 0){ // predict DC from left
pOrg[0] -= (pSC->PredInfo[i] + mbX - 1)->iDC;
}
else if(iDCPredMode == 2){ // predict DC from top&left
pOrg[0] -= (((pSC->PredInfo[i] + mbX - 1)->iDC + (pSC->PredInfoPrevRow[i] + mbX)->iDC + 1) >> 1);
}
/* AD prediction */
if(iADPredMode == 4){// predict AD from top
pOrg[4] -= (pSC->PredInfoPrevRow[i] + mbX)->piAD[4]; // AC of HT !!!
pOrg[6] -= pOrg[2];
pOrg[2] -= (pSC->PredInfoPrevRow[i] + mbX)->piAD[3];
}
else if(iADPredMode == 0){// predict AD from left
pOrg[4] -= (pSC->PredInfo[i] + mbX - 1)->piAD[4]; // AC of HT !!!
pOrg[1] -= (pSC->PredInfo[i] + mbX - 1)->piAD[0];
pOrg[5] -= (pSC->PredInfo[i] + mbX - 1)->piAD[2];
}
else if(iDCPredMode == 1){
pOrg[6] -= pOrg[2];
}
pOrg = pSC->pPlane[i]; // current MB
/* AC prediction */
if(iACPredMode == 1){ // predict from top
for(j = 48; j > 0; j -= 16){
for(k = 0; k <= 64; k += 64){
/* inside macroblock */
pOrg[j + k + 10] -= pOrg[j + k + 10 - 16];
pOrg[j + k + 2] -= pOrg[j + k + 2 - 16];
pOrg[j + k + 9] -= pOrg[j + k + 9 - 16];
}
}
}
else if(iACPredMode == 0){ // predict from left
for(j = 64; j <= 112; j += 16){
/* inside macroblock */
pOrg[j + 5] -= pOrg[j + 5 - 64];
pOrg[j + 1] -= pOrg[j + 1 - 64];
pOrg[j + 6] -= pOrg[j + 6 - 64];
}
}
}
}
}
/* CBP prediction for 16 x 16 MB */
/* block index */
/* 0 1 4 5 */
/* 2 3 6 7 */
/* 8 9 12 13 */
/* 10 11 14 15 */
static int NumOnes(int i)
{
int retval = 0;
static const int g_Count[] = { 0,1,1,2, 1,2,2,3, 1,2,2,3, 2,3,3,4 };
i = i & 0xffff;
while (i) {
retval += g_Count[i & 0xf];
i >>= 4;
}
return retval;
}
#define SATURATE32(x) if((unsigned int)(x + 16) >= 32) { if (x < 0) x = -16; else x = 15; }
static Int predCBPCEnc(CWMImageStrCodec *pSC, Int iCBP, size_t mbX, size_t mbY, size_t c, CCBPModel *pModel)
{
Int iPredCBP = 0, iRetval = 0;
Int iNOrig = NumOnes(iCBP), iNDiff = AVG_NDIFF;//NumOnes(iPredCBP ^ iCBP);
UNREFERENCED_PARAMETER( mbY );
/* only top left block pattern is predicted from neighbour */
if(pSC->m_bCtxLeft) {
if (pSC->m_bCtxTop) {
iPredCBP = 1;
}
else {
Int iTopCBP = (pSC->PredInfoPrevRow[c] + mbX)->iCBP;
iPredCBP = (iTopCBP >> 10) & 1; // left: top(10) => 0
}
}
else {
Int iLeftCBP = (pSC->PredInfo[c] + mbX - 1)->iCBP;
iPredCBP = ((iLeftCBP >> 5) & 1); // left(5) => 0
}
iPredCBP |= (iCBP & 0x3300) << 2; // [8 9 12 13]->[10 11 14 15]
iPredCBP |= (iCBP & 0xcc) << 6; // [2 3 6 7]->[8 9 12 13]
iPredCBP |= (iCBP & 0x33) << 2; // [0 1 4 5]->[2 3 6 7]
iPredCBP |= (iCBP & 0x11) << 1; // [0 4]->[1 5]
iPredCBP |= (iCBP & 0x2) << 3; // [1]->[4]
if (c) c = 1;
if (pModel->m_iState[c] == 0) {
iRetval = iPredCBP ^ iCBP;
}
else if (pModel->m_iState[c] == 1) {
iRetval = iCBP;
}
else {
iRetval = iCBP ^ 0xffff;
}
pModel->m_iCount0[c] += iNOrig - iNDiff;
SATURATE32(pModel->m_iCount0[c]);
pModel->m_iCount1[c] += 16 - iNOrig - iNDiff;
SATURATE32(pModel->m_iCount1[c]);
if (pModel->m_iCount0[c] < 0) {
if (pModel->m_iCount0[c] < pModel->m_iCount1[c]) {
pModel->m_iState[c] = 1;
}
else {
pModel->m_iState[c] = 2;
}
}
else if (pModel->m_iCount1[c] < 0) {
pModel->m_iState[c] = 2;
}
else {
pModel->m_iState[c] = 0;
}
return iRetval;
}
static Int predCBPC420Enc(CWMImageStrCodec *pSC, Int iCBP, size_t mbX, size_t mbY, size_t c, CCBPModel *pModel)
{
Int iPredCBP = 0, iRetval = 0;
Int iNOrig = NumOnes(iCBP) * 4, iNDiff = AVG_NDIFF;//NumOnes(iPredCBP ^ iCBP);
UNREFERENCED_PARAMETER( mbY );
/* only top left block pattern is predicted from neighbour */
if(pSC->m_bCtxLeft) {
if (pSC->m_bCtxTop) {
iPredCBP = 1;
}
else {
Int iTopCBP = (pSC->PredInfoPrevRow[c] + mbX)->iCBP;
iPredCBP = (iTopCBP >> 2) & 1; // left: top(2) => 0
}
}
else {
Int iLeftCBP = (pSC->PredInfo[c] + mbX - 1)->iCBP;
iPredCBP = ((iLeftCBP >> 1) & 1); // left(1) => 0
}
iPredCBP |= (iCBP & 0x1) << 1; // [0]->[1]
iPredCBP |= (iCBP & 0x3) << 2; // [0 1]->[2 3]
if (pModel->m_iState[1] == 0) {
iRetval = iPredCBP ^ iCBP;
}
else if (pModel->m_iState[1] == 1) {
iRetval = iCBP;
}
else {
iRetval = iCBP ^ 0xf;
}
pModel->m_iCount0[1] += iNOrig - iNDiff;
SATURATE32(pModel->m_iCount0[1]);
pModel->m_iCount1[1] += 16 - iNOrig - iNDiff;
SATURATE32(pModel->m_iCount1[1]);
if (pModel->m_iCount0[1] < 0) {
if (pModel->m_iCount0[1] < pModel->m_iCount1[1]) {
pModel->m_iState[1] = 1;
}
else {
pModel->m_iState[1] = 2;
}
}
else if (pModel->m_iCount1[1] < 0) {
pModel->m_iState[1] = 2;
}
else {
pModel->m_iState[1] = 0;
}
return iRetval;
}
static Int predCBPC422Enc(CWMImageStrCodec *pSC, Int iCBP, size_t mbX, size_t mbY, size_t c, CCBPModel *pModel)
{
Int iPredCBP = 0, iRetval = 0;
Int iNOrig = NumOnes(iCBP) * 2, iNDiff = AVG_NDIFF;//NumOnes(iPredCBP ^ iCBP);
UNREFERENCED_PARAMETER( mbY );
/* only top left block pattern is predicted from neighbour */
if(pSC->m_bCtxLeft) {
if (pSC->m_bCtxTop) {
iPredCBP = 1;
}
else {
Int iTopCBP = (pSC->PredInfoPrevRow[c] + mbX)->iCBP;
iPredCBP = (iTopCBP >> 6) & 1; // left: top(6) => 0
}
}
else {
Int iLeftCBP = (pSC->PredInfo[c] + mbX - 1)->iCBP;
iPredCBP = ((iLeftCBP >> 1) & 1); // left(1) => 0
}
iPredCBP |= (iCBP & 0x1) << 1; // [0]->[1]
iPredCBP |= (iCBP & 0x3) << 2; // [0 1]->[2 3]
iPredCBP |= (iCBP & 0xc) << 2; // [2 3]->[4 5]
iPredCBP |= (iCBP & 0x30) << 2; // [4 5]->[6 7]
if (pModel->m_iState[1] == 0) {
iRetval = iPredCBP ^ iCBP;
}
else if (pModel->m_iState[1] == 1) {
iRetval = iCBP;
}
else {
iRetval = iCBP ^ 0xff;
}
pModel->m_iCount0[1] += iNOrig - iNDiff;
SATURATE32(pModel->m_iCount0[1]);
pModel->m_iCount1[1] += 16 - iNOrig - iNDiff;
SATURATE32(pModel->m_iCount1[1]);
if (pModel->m_iCount0[1] < 0) {
if (pModel->m_iCount0[1] < pModel->m_iCount1[1]) {
pModel->m_iState[1] = 1;
}
else {
pModel->m_iState[1] = 2;
}
}
else if (pModel->m_iCount1[1] < 0) {
pModel->m_iState[1] = 2;
}
else {
pModel->m_iState[1] = 0;
}
return iRetval;
}
Void predCBPEnc(CWMImageStrCodec* pSC, CCodingContext *pContext)
{
size_t mbX = pSC->cColumn - 1, mbY = pSC->cRow - 1;
CWMIMBInfo * pMBInfo = &(pSC->MBInfo);
int iChannel, i, j;
for(iChannel = 0; iChannel < (int)pSC->m_param.cNumChannels; iChannel ++){
const COLORFORMAT cf = pSC->m_param.cfColorFormat;
const Bool bUV = (iChannel > 0);
const int iNumBlock = (bUV ? (cf == YUV_422 ? 8 : (cf == YUV_420 ? 4 : 16)) : 16);
const int * pOffset = (iNumBlock == 4 ? blkOffsetUV : (iNumBlock == 8 ? blkOffsetUV_422 : blkOffset));
const Int threshold = (1 << pContext->m_aModelAC.m_iFlcBits[bUV ? 1 : 0]) - 1, threshold2 = threshold * 2 + 1;
Int iCBP = 0;
for(j = 0; j < iNumBlock; j ++){
PixelI * pData = pSC->pPlane[iChannel] + pOffset[j];
for(i = 1; i < 16; i ++){
if((unsigned int)(pData[i] + threshold) >= (unsigned int) threshold2){ // significant coeff
iCBP |= (1 << j); // update CBP
break;
}
}
}
pMBInfo->iCBP[iChannel] = (pSC->PredInfo[iChannel] + mbX)->iCBP = iCBP;
if(iNumBlock == 16){
pMBInfo->iDiffCBP[iChannel] = predCBPCEnc(pSC, pMBInfo->iCBP[iChannel], mbX, mbY, iChannel, &pContext->m_aCBPModel);
}
else if(iNumBlock == 8){
pSC->MBInfo.iDiffCBP[iChannel] = predCBPC422Enc(pSC, pMBInfo->iCBP[iChannel], mbX, mbY, iChannel, &pContext->m_aCBPModel);
}
else{
pSC->MBInfo.iDiffCBP[iChannel] = predCBPC420Enc(pSC, pMBInfo->iCBP[iChannel], mbX, mbY, iChannel, &pContext->m_aCBPModel);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,510 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "strcodec.h"
#ifdef MEM_TRACE
#define TRACE_MALLOC 1
#define TRACE_NEW 0
#define TRACE_HEAP 0
#include "memtrace.h"
#endif
// Huffman lookup tables
static const short g4HuffLookupTable[40] = {
19,19,19,19,27,27,27,27,10,10,10,10,10,10,10,10,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0 };
static const short g5HuffLookupTable[2][42] = {{
28,28,36,36,19,19,19,19,10,10,10,10,10,10,10,10,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0 },
{
11,11,11,11,19,19,19,19,27,27,27,27,35,35,35,35,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0 }};
static const short g6HuffLookupTable[4][44] = {{
13,29,44,44,19,19,19,19,34,34,34,34,34,34,34,34,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0 },
{
12,12,28,28,43,43,43,43,2,2,2,2,2,2,2,2,
18,18,18,18,18,18,18,18,34,34,34,34,34,34,34,34,
0,0,0,0,0,0,0,0,0,0,0,0 },
{
4,4,12,12,43,43,43,43,18,18,18,18,18,18,18,18,
26,26,26,26,26,26,26,26,34,34,34,34,34,34,34,34,
0,0,0,0,0,0,0,0,0,0,0,0 },
{
5,13,36,36,43,43,43,43,18,18,18,18,18,18,18,18,
25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
0,0,0,0,0,0,0,0,0,0,0,0 }};
static const short g7HuffLookupTable[2][46] = {{
45,53,36,36,27,27,27,27,2,2,2,2,2,2,2,2,
10,10,10,10,10,10,10,10,18,18,18,18,18,18,18,18,
0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{
-32736,37,28,28,19,19,19,19,10,10,10,10,10,10,10,10,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
5,6,0,0,0,0,0,0,0,0,0,0,0,0 }};
static const short g8HuffLookupTable[2][48] = {{
53,21,28,28,11,11,11,11,43,43,43,43,59,59,59,59,
2,2,2,2,2,2,2,2,34,34,34,34,34,34,34,34,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
{
52,52,20,20,3,3,3,3,11,11,11,11,27,27,27,27,
35,35,35,35,43,43,43,43,58,58,58,58,58,58,58,58,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }};
static const short g9HuffLookupTable[2][50] = {{
13,29,37,61,20,20,68,68,3,3,3,3,51,51,51,51,
41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0 },
{
-32736,53,28,28,11,11,11,11,19,19,19,19,43,43,43,43,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-32734,4,7,8,0,0,0,0,0,0,0,0,0,0,0,0,
0,0 }};
static const short g12HuffLookupTable[5][56] = {{
-32736,5,76,76,37,53,69,85,43,43,43,43,91,91,91,91,
57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,
-32734,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0 },
{
-32736,85,13,53,4,4,36,36,43,43,43,43,67,67,67,67,
75,75,75,75,91,91,91,91,58,58,58,58,58,58,58,58,
2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0 },
{
-32736,37,92,92,11,11,11,11,43,43,43,43,59,59,59,59,
67,67,67,67,75,75,75,75,2,2,2,2,2,2,2,2,
-32734,-32732,2,3,6,10,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0 },
{
-32736,29,37,69,3,3,3,3,43,43,43,43,59,59,59,59,
75,75,75,75,91,91,91,91,10,10,10,10,10,10,10,10,
-32734,10,2,6,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0 },
{
-32736,93,28,28,60,60,76,76,3,3,3,3,43,43,43,43,
9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-32734,-32732,-32730,2,4,8,6,10,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0 }};
/**********************************************************************
Allocation and dellocation
**********************************************************************/
Void Clean (CAdaptiveHuffman *pAdHuff)
{
if (pAdHuff == NULL)
return;
free (pAdHuff);
}
CAdaptiveHuffman *Allocate (Int iNSymbols, CODINGMODE cm)
{
CAdaptiveHuffman *pAdHuff = (CAdaptiveHuffman *) malloc (sizeof (CAdaptiveHuffman));
UNREFERENCED_PARAMETER(cm);
if (pAdHuff == NULL)
return NULL;
if (iNSymbols > 255 || iNSymbols <= 0)
goto ErrorExit;
memset (pAdHuff, 0, sizeof (CAdaptiveHuffman));
pAdHuff->m_iNSymbols = iNSymbols;
pAdHuff->m_pDelta = NULL;
pAdHuff->m_iDiscriminant = pAdHuff->m_iUpperBound = pAdHuff->m_iLowerBound = 0;
return pAdHuff;
ErrorExit:
Clean (pAdHuff);
return NULL;
}
/**********************************************************************
Adapt Huffman table
**********************************************************************/
// Alphabet size = 4
static const Int g_Index4Table[] = {
1,2,3,3
};
static const Int g4CodeTable[] = {
4,
1, 1,
1, 2,
0, 3,
1, 3
};
// Alphabet size = 5
static const Int g_Index5Table[] = {
1,2,3,4,4,
1,3,3,3,3
};
static const Int g5CodeTable[] = {
5,
1, 1,
1, 2,
1, 3,
0, 4,
1, 4,
5,
1, 1,
0, 3,
1, 3,
2, 3,
3, 3,
};
static const Int g5DeltaTable[] = { 0,-1,0,1,1 };
// Alphabet size = 6
static const Int g_Index6Table[] = {
1,5,3,5,2,4,
2,4,2,4,2,3,
4,4,2,2,2,3,
5,5,2,1,4,3,
};
static const Int g6CodeTable[] = {
6,
1, 1,
0, 5,
1, 3,
1, 5,
1, 2,
1, 4,
6,
1, 2,
0, 4,
2, 2,
1, 4,
3, 2,
1, 3,
6,
0, 4,
1, 4,
1, 2,
2, 2,
3, 2,
1, 3,
6,
0, 5,
1, 5,
1, 2,
1, 1,
1, 4,
1, 3
};
static const Int g6DeltaTable[] = {
-1, 1, 1, 1, 0, 1,
-2, 0, 0, 2, 0, 0,
-1,-1, 0, 1,-2, 0
};
// Alphabet size = 7
static const Int g_Index7Table[] = { 2,2,2,3,4,5,5,
1,2,3,4,5,6,6 };
static const Int g7CodeTable[] = {
7,
1, 2,
2, 2,
3, 2,
1, 3,
1, 4,
0, 5,
1, 5,
7,
1, 1,
1, 2,
1, 3,
1, 4,
1, 5,
0, 6,
1, 6
};
static const Int g7DeltaTable[] = { 1,0,-1,-1,-1,-1,-1 };
// Alphabet size = 8
static const Int g_Index8Table[] = { 2,3,5,4,2,3,5,3,
3,3,4,3,3,3,4,2};
static const Int g8CodeTable[] = {
8,
2, 2,
1, 3,
1, 5,
1, 4,
3, 2,
2, 3,
0, 5,
3, 3,
8,
1, 3,
2, 3,
1, 4,
3, 3,
4, 3,
5, 3,
0, 4,
3, 2
};
static const Int g8DeltaTable[] = { -1,0,1,1,-1,0,1,1 };
static const Int g_Index9Table[] = {
3,5,4,5,5,1,3,5,4,
1,3,3,4,6,3,5,7,7,
};
static const Int g9CodeTable[] = {
9,
2, 3,
0, 5,
2, 4,
1, 5,
2, 5,
1, 1,
3, 3,
3, 5,
3, 4,
9,
1, 1,
1, 3,
2, 3,
1, 4,
1, 6,
3, 3,
1, 5,
0, 7,
1, 7,
};
static const Int g9DeltaTable[] = { 2,2,1,1,-1,-2,-2,-2,-3 };
// Alphabet size = 12
static const Int g_Index12Table[] = { // index12 is the most critical symbol
5,6,7,7,5,3,5,1,5,4,5,3,
4,5,6,6,4,3,5,2,3,3,5,3,
2,3,7,7,5,3,7,3,3,3,7,4,
3,2,7,5,5,3,7,3,5,3,6,3,
3,1,7,4,7,3,8,4,7,4,8,5,
};
static const Int g12CodeTable[] = {
12,
1, 5,
1, 6,
0, 7,
1, 7,
4, 5,
2, 3,
5, 5,
1, 1,
6, 5,
1, 4,
7, 5,
3, 3,
12,
2, 4,
2, 5,
0, 6,
1, 6,
3, 4,
2, 3,
3, 5,
3, 2,
3, 3,
4, 3,
1, 5,
5, 3,
12,
3, 2,
1, 3,
0, 7,
1, 7,
1, 5,
2, 3,
2, 7,
3, 3,
4, 3,
5, 3,
3, 7,
1, 4,
12,
1, 3,
3, 2,
0, 7,
1, 5,
2, 5,
2, 3,
1, 7,
3, 3,
3, 5,
4, 3,
1, 6,
5, 3,
12,
2, 3,
1, 1,
1, 7,
1, 4,
2, 7,
3, 3,
0, 8,
2, 4,
3, 7,
3, 4,
1, 8,
1, 5
};
static const Int g12DeltaTable[] = {
1, 1, 1, 1, 1, 0, 0,-1, 2, 1, 0, 0,
2, 2,-1,-1,-1, 0,-2,-1, 0, 0,-2,-1,
-1, 1, 0, 2, 0, 0, 0, 0,-2, 0, 1, 1,
0, 1, 0, 1,-2, 0,-1,-1,-2,-1,-2,-2
};
/**********************************************************************
Adapt fixed length codes based on discriminant
**********************************************************************/
static const Int THRESHOLD = 8;
static const Int MEMORY = 8;
Void AdaptDiscriminant (CAdaptiveHuffman *pAdHuff)
{
Int iSym = pAdHuff->m_iNSymbols, t, dL, dH;
const Int *pCodes, *pDelta = NULL;
Bool bChange = FALSE;
static const Int gMaxTables[] = { 0,0,0,0, 1,2, 4,2, 2,2, 0,0,5 };
static const Int gSecondDisc[]= { 0,0,0,0, 0,0, 1,0, 0,0, 0,0,1 };
if (!pAdHuff->m_bInitialize) {
pAdHuff->m_bInitialize = 1;
pAdHuff->m_iDiscriminant = pAdHuff->m_iDiscriminant1 = 0;
pAdHuff->m_iTableIndex = gSecondDisc[iSym];//(gMaxTables[iSym] - 1) >> 1;
}
dL = dH = pAdHuff->m_iDiscriminant;
if (gSecondDisc[iSym]) {
dH = pAdHuff->m_iDiscriminant1;
}
if (dL < pAdHuff->m_iLowerBound) {
pAdHuff->m_iTableIndex--;
bChange = TRUE;
}
else if (dH > pAdHuff->m_iUpperBound) {
pAdHuff->m_iTableIndex++;
bChange = TRUE;
}
if (bChange) {
/** if initialization is fixed, we can exit on !bChange **/
pAdHuff->m_iDiscriminant = 0;
pAdHuff->m_iDiscriminant1 = 0;
}
{
if (pAdHuff->m_iDiscriminant < -THRESHOLD * MEMORY)
pAdHuff->m_iDiscriminant = -THRESHOLD * MEMORY;
else if (pAdHuff->m_iDiscriminant > THRESHOLD * MEMORY)
pAdHuff->m_iDiscriminant = THRESHOLD * MEMORY;
if (pAdHuff->m_iDiscriminant1 < -THRESHOLD * MEMORY)
pAdHuff->m_iDiscriminant1 = -THRESHOLD * MEMORY;
else if (pAdHuff->m_iDiscriminant1 > THRESHOLD * MEMORY)
pAdHuff->m_iDiscriminant1 = THRESHOLD * MEMORY;
}
t = pAdHuff->m_iTableIndex;
assert (t >= 0);
assert (t < gMaxTables[iSym]);
//pAdHuff->m_iDiscriminant >>= 1;
pAdHuff->m_iLowerBound = (t == 0) ? (-1 << 31) : -THRESHOLD;
pAdHuff->m_iUpperBound = (t == gMaxTables[iSym] - 1) ? (1 << 30) : THRESHOLD;
switch (iSym) {
case 4:
pCodes = g4CodeTable;
pAdHuff->m_hufDecTable = (short *) g4HuffLookupTable;
break;
case 5:
pCodes = g5CodeTable + (iSym * 2 + 1) * t;
pDelta = g5DeltaTable;
pAdHuff->m_hufDecTable = g5HuffLookupTable[t];
break;
case 6:
pCodes = g6CodeTable + (iSym * 2 + 1) * t;
pAdHuff->m_pDelta1 = g6DeltaTable + iSym * (t - (t + 1 == gMaxTables[iSym]));
pDelta = g6DeltaTable + (t - 1 + (t == 0)) * iSym;
pAdHuff->m_hufDecTable = g6HuffLookupTable[t];
break;
case 7:
pCodes = g7CodeTable + (iSym * 2 + 1) * t;
pDelta = g7DeltaTable;
pAdHuff->m_hufDecTable = g7HuffLookupTable[t];
break;
case 8:
//printf ("%d ", t);
pCodes = g8CodeTable;// + (iSym * 2 + 1) * t;
//pDelta = g8DeltaTable;
pAdHuff->m_hufDecTable = g8HuffLookupTable[0];
break;
case 9:
pCodes = g9CodeTable + (iSym * 2 + 1) * t;
pDelta = g9DeltaTable;
pAdHuff->m_hufDecTable = g9HuffLookupTable[t];
break;
case 12:
pCodes = g12CodeTable + (iSym * 2 + 1) * t;
pAdHuff->m_pDelta1 = g12DeltaTable + iSym * (t - (t + 1 == gMaxTables[iSym]));
pDelta = g12DeltaTable + (t - 1 + (t == 0)) * iSym;
pAdHuff->m_hufDecTable = g12HuffLookupTable[t];
break;
default:
assert (0); // undefined fixed length table
return;
}
pAdHuff->m_pTable = pCodes;
pAdHuff->m_pDelta = pDelta;
}

View File

@ -1,59 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#pragma once
//================================
// bitio functions
//================================
#define PACKETLENGTH (1U<<12) // 4kB
#define readIS_L1(pSC, pIO) readIS(pSC, pIO)
#define readIS_L2(pSC, pIO) (void)(pSC, pIO)
#define writeIS_L1(pSC, pIO) writeIS(pSC, pIO)
#define writeIS_L2(pSC, pIO) (void)(pSC, pIO)
//================================
// common defines
//================================
#define FORCE_INLINE
#define CDECL
#if __LP64__
#define UINTPTR_T unsigned long long
#define INTPTR_T long long
#else
#define UINTPTR_T unsigned int
#define INTPTR_T int
#endif
//================================
// quantization optimization
//================================
//#define RECIP_QUANT_OPT

View File

@ -1,131 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_COMMON_H
#define WMI_COMMON_H
/*************************************************************************
// Common typedef's
*************************************************************************/
typedef enum { ENCODER = 0, DECODER = 1 } CODINGMODE;
typedef enum tagBand
{
BAND_HEADER = 0,
BAND_DC = 1,
BAND_LP = 2,
BAND_AC = 3,
BAND_FL = 4
} BAND;
/*************************************************************************
struct / class definitions
*************************************************************************/
//#define SIGNATURE_BYTES 8 // Bytes for GDI+ signature
#define CODEC_VERSION 1
#define CODEC_SUBVERSION 0
#define CODEC_SUBVERSION_NEWSCALING_SOFT_TILES 1
#define CODEC_SUBVERSION_NEWSCALING_HARD_TILES 9
#define CONTEXTX 8
#define CTDC 5
#define NUMVLCTABLES 21 // CONTEXTX * 2 + CTDC
#define AVG_NDIFF 3
#define MAXTOTAL 32767 // 511 should be enough
/** Quantization related defines **/
#define SHIFTZERO 1 /* >= 0 */
#define QPFRACBITS 2 /* or 0 only supported */
/** adaptive huffman encoding / decoding struct **/
typedef struct CAdaptiveHuffman
{
Int m_iNSymbols;
const Int *m_pTable;
const Int *m_pDelta, *m_pDelta1;
Int m_iTableIndex;
const short *m_hufDecTable;
Bool m_bInitialize;
//Char m_pLabel[8]; // for debugging - label attached to constructor
Int m_iDiscriminant, m_iDiscriminant1;
Int m_iUpperBound;
Int m_iLowerBound;
} CAdaptiveHuffman;
/************************************************************************************
Context structures
************************************************************************************/
typedef struct CAdaptiveModel {
Int m_iFlcState[2];
Int m_iFlcBits[2];
BAND m_band;
} CAdaptiveModel;
typedef struct CCBPModel {
Int m_iCount0[2];
Int m_iCount1[2];
Int m_iState[2];
} CCBPModel;
/*************************************************************************
globals
*************************************************************************/
extern Int grgiZigzagInv4x4_lowpass[];
extern Int grgiZigzagInv4x4H[];
extern Int grgiZigzagInv4x4V[];
extern const Int gSignificantRunBin[];
extern const Int gSignificantRunFixedLength[];
static const Int cblkChromas[] = {0,4,8,16, 16,16,16, 0,0};
/*************************************************************************
function declarations
*************************************************************************/
// common utilities
Void Clean (CAdaptiveHuffman *pAdHuff);
CAdaptiveHuffman *Allocate (Int iNSymbols, CODINGMODE cm);
/* Timing functions */
void reset_timing(double *time);
void report_timing(const char *s, double time);
// static double timeperclock;
/** adaptive model functions **/
Void UpdateModelMB (COLORFORMAT cf, Int iChannels, Int iLaplacianMean[], CAdaptiveModel *m_pModel);
/** adaptive huffman encoder / decoder functions **/
Void Adapt (CAdaptiveHuffman *pAdHuff, Bool bFixedTables);
Void AdaptFixed (CAdaptiveHuffman *pAdHuff);
Void AdaptDiscriminant (CAdaptiveHuffman *pAdHuff);
#ifndef _PREFAST_
#pragma warning(disable:4068)
#endif
#endif // WMI_COMMON_H

View File

@ -1,183 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "strcodec.h"
// #include "xplatform_image.h"
#ifdef MEM_TRACE
#define TRACE_MALLOC 1
#define TRACE_NEW 0
#define TRACE_HEAP 0
#include "memtrace.h"
#endif
#include <stdlib.h>
#include <string.h>
#if !(defined(__ANSI__))
// Desktop
#include <windows.h>
#else
// ANSI
#include <time.h>
#endif
Int grgiZigzagInv4x4_lowpass [] = {
0, 1, 4, 5, 2, 8, 6, 9,
3, 12, 10, 7, 13, 11, 14, 15
};
Int grgiZigzagInv4x4H [] = {
0, 1, 4, 5, 2, 8, 6, 9,
3, 12, 10, 7, 13, 11, 14, 15
};
Int grgiZigzagInv4x4V [] = {
0, 4, 8, 5, 1, 12, 9, 6, 2, 13, 3, 15, 7, 10, 14, 11
};
const Int gSignificantRunBin[] = {
-1,-1,-1,-1,
2,2,2,
1,1,1,1,
0,0,0,0
};
const Int gSignificantRunFixedLength[] = {
0,0,1,1,3,
0,0,1,1,2,
0,0,0,0,1,
};
/*************************************************************************
UpdateModelMB : update adaptive model at end of macroblock
(for lowest resolution only)
*************************************************************************/
#define MODELWEIGHT 70//90
Void UpdateModelMB (COLORFORMAT cf, Int iChannels, Int iLaplacianMean[], CAdaptiveModel *pModel)
{
Int j;
static const Int aWeight0[3] = { 240/*DC*/, 12/*LP*/, 1 };
static const Int aWeight1[3][MAX_CHANNELS] = {
{ 0,240,120,80, 60,48,40,34, 30,27,24,22, 20,18,17,16 },
{ 0,12,6,4, 3,2,2,2, 2,1,1,1, 1,1,1,1 },
{ 0,16,8,5, 4,3,3,2, 2,2,2,1, 1,1,1,1 }
};
static const Int aWeight2[6] = { 120,37,2,/*420*/ 120,18,1/*422*/ };
iLaplacianMean[0] *= aWeight0[pModel->m_band - BAND_DC];
if (cf == YUV_420) {
iLaplacianMean[1] *= aWeight2[pModel->m_band - BAND_DC];
}
else if (cf == YUV_422) {
iLaplacianMean[1] *= aWeight2[3 + (pModel->m_band) - BAND_DC];
}
else {
iLaplacianMean[1] *= aWeight1[pModel->m_band - BAND_DC][iChannels - 1];
if (pModel->m_band == BAND_AC)
iLaplacianMean[1] >>= 4;
}
for (j = 0; j < 2; j++) {
Int iLM = iLaplacianMean[j];
Int iMS = pModel->m_iFlcState[j];
Int iDelta = (iLM - MODELWEIGHT) >> 2;
if (iDelta <= -8) {
iDelta += 4;
if (iDelta < -16)
iDelta = -16;
iMS += iDelta;
if (iMS < -8) {
if (pModel->m_iFlcBits[j] == 0)
iMS = -8;
else {
iMS = 0;
pModel->m_iFlcBits[j]--;
}
}
}
else if (iDelta >= 8) {
iDelta -= 4;
if (iDelta > 15)
iDelta = 15;
iMS += iDelta;
if (iMS > 8) {
if (pModel->m_iFlcBits[j] >= 15) {
pModel->m_iFlcBits[j] = 15;
iMS = 8;
}
else {
iMS = 0;
pModel->m_iFlcBits[j]++;
}
}
}
pModel->m_iFlcState[j] = iMS;
if (cf == Y_ONLY)
break;
}
}
Void ResetCodingContext(CCodingContext *pContext)
{
// reset bit reduction models
memset (&(pContext->m_aModelAC), 0, sizeof(CAdaptiveModel));
pContext->m_aModelAC.m_band = BAND_AC;
memset (&(pContext->m_aModelLP), 0, sizeof(CAdaptiveModel));
pContext->m_aModelLP.m_band = BAND_LP;
pContext->m_aModelLP.m_iFlcBits[0] = pContext->m_aModelLP.m_iFlcBits[1] = 4;
memset (&(pContext->m_aModelDC), 0, sizeof(CAdaptiveModel));
pContext->m_aModelDC.m_band = BAND_DC;
pContext->m_aModelDC.m_iFlcBits[0] = pContext->m_aModelDC.m_iFlcBits[1] = 8;
// reset CBP models
pContext->m_iCBPCountMax = pContext->m_iCBPCountZero = 1;
pContext->m_aCBPModel.m_iCount0[0] = pContext->m_aCBPModel.m_iCount0[1] = -4;
pContext->m_aCBPModel.m_iCount1[0] = pContext->m_aCBPModel.m_iCount1[1] = 4;
pContext->m_aCBPModel.m_iState[0] = pContext->m_aCBPModel.m_iState[1] = 0;
}
/*************************************************************************
Initialize zigzag scan parameters
*************************************************************************/
Void InitZigzagScan(CCodingContext * pContext)
{
if (NULL != pContext) {
Int i;
for (i=0; i<16; i++) {
pContext->m_aScanLowpass[i].uScan = grgiZigzagInv4x4_lowpass[i];
pContext->m_aScanHoriz[i].uScan = dctIndex[0][grgiZigzagInv4x4H[i]];
pContext->m_aScanVert[i].uScan = dctIndex[0][grgiZigzagInv4x4V[i]];
}
}
}

View File

@ -1,119 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef __PERFTIMER_H_
#define __PERFTIMER_H_
//***************************************************************************
// Description
//
// Performance timer API used to measure codec performance. The underlying
// implementation of this API may vary - from ANSI-C implementation via clock,
// Win32 implementation via QueryPerformanceCounter or GetProcessTimes. At
// present we only support one implementation of this PerfTimer "object".
// You choose the implementation by choosing which one of the many files
// to compile and link with your application.
//***************************************************************************
#define DISABLE_PERF_MEASUREMENT
#ifdef DISABLE_PERF_MEASUREMENT
#define PERFTIMER_ONLY(code)
#define PERFTIMER_NEW(fPerf, ppPerfTimer)
#define PERFTIMER_DELETE(fPerf, ppPerfTimer)
#define PERFTIMER_START(fPerf, pPerfTimer)
#define PERFTIMER_STOP(fPerf, pPerfTimer)
#define PERFTIMER_GETRESULTS(fPerf, pPerfTimer, pResults)
#define PERFTIMER_COPYSTARTTIME(fPerf, pDst, pSrc)
#define PERFTIMER_REPORT(fPerf, pCodec)
#else // DISABLE_PERF_MEASUREMENT
#define PERFTIMER_ONLY(code) code
#define PERFTIMER_NEW(fPerf, ppPerfTimer) if (fPerf) {Bool b = b = PerfTimerNew(ppPerfTimer); assert(b);};
#define PERFTIMER_DELETE(fPerf, pPerfTimer) if (fPerf) {PerfTimerDelete(pPerfTimer);};
#define PERFTIMER_START(fPerf, pPerfTimer) if (fPerf) {Bool b = b = PerfTimerStart(pPerfTimer); assert(b);};
#define PERFTIMER_STOP(fPerf, pPerfTimer) if (fPerf) {Bool b = b = PerfTimerStop(pPerfTimer); assert(b);};
#define PERFTIMER_GETRESULTS(fPerf, pPerfTimer, pResults) \
if (fPerf) {Bool b = b = PerfTimerGetResults((pPerfTimer), (pResults)); assert(b);};
#define PERFTIMER_COPYSTARTTIME(fPerf, pDst, pSrc) \
if (fPerf) {Bool b = b = PerfTimerCopyStartTime((pDst), (pSrc)); assert(b);};
#define PERFTIMER_REPORT(fPerf, pCodec) \
if (fPerf) {OutputPerfTimerReport(pCodec);};
#endif // DISABLE_PERF_MEASUREMENT
//***************************************************************************
// Data Types
//***************************************************************************
typedef unsigned long PERFTIMERTIME;
typedef struct PERFTIMERRESULTS
{
PERFTIMERTIME iElapsedTime; // In nanoseconds or CPU cycles
PERFTIMERTIME iTicksPerSecond; // Number of ticks per second (clock frequency)
PERFTIMERTIME iZeroTimeIntervals; // Number of zero-time intervals.
// Presence of zero-time intervals may indicate insufficient clock precision
} PERFTIMERRESULTS;
#define NANOSECONDS_PER_SECOND 1000000000
//***************************************************************************
// Data Declarations
//***************************************************************************
typedef enum
{
CS_UNINIT,
CS_RUNNING,
CS_STOPPED,
} CLOCKSTATE;
typedef struct PERFTIMERSTATE
{
CLOCKSTATE eState;
PERFTIMERTIME iElapsedTime;
PERFTIMERTIME iPrevStartTime;
PERFTIMERTIME iZeroTimeIntervals;
} PERFTIMERSTATE;
//***************************************************************************
// Functions and Macros
//***************************************************************************
#ifndef DISABLE_PERF_MEASUREMENT
bool PerfTimerNew(PERFTIMERSTATE **ppNewPerfTimer);
void PerfTimerDelete(PERFTIMERSTATE *pThisPerfTimer);
bool PerfTimerStart(PERFTIMERSTATE *pThisPerfTimer);
bool PerfTimerStop(PERFTIMERSTATE *pThisPerfTimer);
bool PerfTimerGetResults(PERFTIMERSTATE *pThisPerfTimer,
PERFTIMERRESULTS *pPerfTimerResults);
bool PerfTimerCopyStartTime(PERFTIMERSTATE *pDestPerfTimer,
PERFTIMERSTATE *pSrcPerfTimer);
#endif
#endif // __PERFTIMER_H_

View File

@ -1,306 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "strcodec.h"
#define ORIENT_WEIGHT 4
/* reciprocal (pMantissa, exponent) lookup table */
typedef struct tagQPManExp
{
int iMan;
int iExp;
} QPManExp;
static QPManExp gs_QPRecipTable[32] = {
{0x0, 0}, // 0, invalid
{0x0, 0}, // 1, lossless
{0x0, 1}, // 2
{0xaaaaaaab, 1},
{0x0, 2}, // 4
{0xcccccccd, 2},
{0xaaaaaaab, 2},
{0x92492493, 2},
{0x0, 3}, // 8
{0xe38e38e4, 3},
{0xcccccccd, 3},
{0xba2e8ba3, 3},
{0xaaaaaaab, 3},
{0x9d89d89e, 3},
{0x92492493, 3},
{0x88888889, 3},
{0x0, 4}, // 16
{0xf0f0f0f1, 4},
{0xe38e38e4, 4},
{0xd79435e6, 4},
{0xcccccccd, 4},
{0xc30c30c4, 4},
{0xba2e8ba3, 4},
{0xb21642c9, 4},
{0xaaaaaaab, 4},
{0xa3d70a3e, 4},
{0x9d89d89e, 4},
{0x97b425ee, 4},
{0x92492493, 4},
{0x8d3dcb09, 4},
{0x88888889, 4},
{0x84210843, 4},
};
/*************************************************************************
QPRemapping
*************************************************************************/
Void remapQP(CWMIQuantizer * pQP, I32 iShift, Bool bScaledArith)
{
U8 uiQPIndex = pQP->iIndex;
if(uiQPIndex == 0) // Lossless mode!
pQP->iQP = 1, pQP->iMan = pQP->iExp = pQP->iOffset = 0;
else if (!bScaledArith) {
I32 man = 0, exp = 0;
const I32 ciShift = SHIFTZERO - (SHIFTZERO + QPFRACBITS); // == -QPFRACBITS
if (pQP->iIndex < 32)
man = (pQP->iIndex + 3) >> 2, exp = ciShift + 2;
else if (pQP->iIndex < 48)
man = (16 + (pQP->iIndex & 0xf) + 1) >> 1, exp = ((pQP->iIndex >> 4) - 1) + 1 + ciShift;
else
man = 16 + (pQP->iIndex & 0xf), exp = ((pQP->iIndex >> 4) - 1) + ciShift;
pQP->iQP = man << exp;
pQP->iMan = gs_QPRecipTable[man].iMan;
pQP->iExp = gs_QPRecipTable[man].iExp + exp;
pQP->iOffset = ((pQP->iQP * 3 + 1) >> 3);
#if defined(WMP_OPT_QT)
pQP->f1_QP = 1.0f / pQP->iQP;
pQP->d1_QP = 1.0 / pQP->iQP;
#endif
}
else {
I32 man = 0, exp = 0;
if(pQP->iIndex < 16)
man = pQP->iIndex, exp = iShift;
else
man = 16 + (pQP->iIndex & 0xf), exp = ((pQP->iIndex >> 4) - 1) + iShift;
pQP->iQP = man << exp;
pQP->iMan = gs_QPRecipTable[man].iMan;
pQP->iExp = gs_QPRecipTable[man].iExp + exp;
pQP->iOffset = ((pQP->iQP * 3 + 1) >> 3);
#if defined(WMP_OPT_QT)
pQP->f1_QP = 1.0f / pQP->iQP;
pQP->d1_QP = 1.0 / pQP->iQP;
#endif
}
}
/* allocate PredInfo buffers */
Int allocatePredInfo(CWMImageStrCodec *pSC)
{
size_t i, j;
// COLORFORMAT cf = pSC->m_param.cfColorFormat;
const size_t mbWidth = pSC->cmbWidth;
const size_t iChannels = pSC->m_param.cNumChannels;
CWMIPredInfo* pMemory;
Bool b32Bit = sizeof(size_t) == 4;
if(b32Bit) // integer overlow/underflow check for 32-bit system
if(((mbWidth >> 16) * iChannels * 2 * sizeof(CWMIPredInfo)) & 0xffff0000)
return ICERR_ERROR;
pMemory = (CWMIPredInfo *)malloc(mbWidth * iChannels * 2 * sizeof(CWMIPredInfo));
if (pMemory == NULL)
return ICERR_ERROR;
pSC->pPredInfoMemory = pMemory;
for(i = 0; i < iChannels; i ++){
pSC->PredInfo[i] = pMemory;
pMemory += mbWidth;
pSC->PredInfoPrevRow[i] = pMemory;
pMemory += mbWidth;
for(j = 0; j < mbWidth; j ++){
pSC->PredInfo[i][j].piAD = pSC->PredInfo[i][j].iAD;
pSC->PredInfoPrevRow[i][j].piAD = pSC->PredInfoPrevRow[i][j].iAD;
}
}
return ICERR_OK;
}
/* clear PredInfo buffers */
Void freePredInfo(CWMImageStrCodec *pSC)
{
if (pSC->pPredInfoMemory)
free (pSC->pPredInfoMemory);
pSC->pPredInfoMemory = NULL;
}
/* get AC prediction mode: 0(from left) 1(from top) 2(none) */
Int getACPredMode(CWMIMBInfo * pMBInfo, COLORFORMAT cf)
{
//Int blkIdx = (cf == Y_ONLY ? 16 : (cf == YUV_420 ? 24 : (cf == YUV_422 ? 32 : 48)));
PixelI * pCoeffs = pMBInfo->iBlockDC[0];
Int StrH = abs(pCoeffs[1]) + abs(pCoeffs[2]) + abs(pCoeffs[3]);
Int StrV = abs(pCoeffs[4]) + abs(pCoeffs[8]) + abs(pCoeffs[12]);
if(cf != Y_ONLY && cf != NCOMPONENT){
PixelI * pCoeffsU = pMBInfo->iBlockDC[1];
PixelI * pCoeffsV = pMBInfo->iBlockDC[2];
StrH += abs(pCoeffsU[1]) + abs(pCoeffsV[1]);
if(cf == YUV_420){
StrV += abs(pCoeffsU[2]) + abs(pCoeffsV[2]);
}
else if (cf == YUV_422){
StrV += abs(pCoeffsU[2]) + abs(pCoeffsV[2]) + abs(pCoeffsU[6]) + abs(pCoeffsV[6]);
StrH += abs(pCoeffsU[5]) + abs(pCoeffsV[5]);
}
else { // YUV_444 or CMYK
StrV += abs(pCoeffsU[4]) + abs(pCoeffsV[4]);
}
}
return (StrH * ORIENT_WEIGHT < StrV ? 1 : (StrV * ORIENT_WEIGHT < StrH ? 0 : 2));
}
/* get DCAC prediction mode: 0(from left) 1(from top) 2(none) */
Int getDCACPredMode(CWMImageStrCodec *pSC, size_t mbX)
{
Int iDCMode, iADMode = 2; // DC: 0(left) 1(top) 2(mean) 3(no)
// AD: 0(left) 1(top) 2(no)
if(pSC->m_bCtxLeft && pSC->m_bCtxTop){ // topleft corner, no prediction
iDCMode = 3;
}
else if(pSC->m_bCtxLeft){
iDCMode = 1; // left column, predict from top
}
else if(pSC->m_bCtxTop){
iDCMode = 0; // top row, predict from left
}
else{
COLORFORMAT cf = pSC->m_param.cfColorFormat;
Int iL = pSC->PredInfo[0][mbX - 1].iDC, iT = pSC->PredInfoPrevRow[0][mbX].iDC, iTL = pSC->PredInfoPrevRow[0][mbX - 1].iDC;
Int StrH, StrV;
if(cf == Y_ONLY || cf == NCOMPONENT){ // CMYK uses YUV metric
StrH = abs(iTL - iL);
StrV = abs(iTL - iT);
}
else{
CWMIPredInfo * pTU = pSC->PredInfoPrevRow[1] + mbX, * pLU = pSC->PredInfo[1] + mbX - 1, * pTLU = pTU - 1;
CWMIPredInfo * pTV = pSC->PredInfoPrevRow[2] + mbX, * pLV = pSC->PredInfo[2] + mbX - 1, * pTLV = pTV - 1;
Int scale = (cf == YUV_420 ? 8 : (cf == YUV_422 ? 4 : 2));
StrH = abs(iTL - iL) * scale + abs(pTLU->iDC - pLU->iDC) + abs(pTLV->iDC - pLV->iDC);
StrV = abs(iTL - iT) * scale + abs(pTLU->iDC - pTU->iDC) + abs(pTLV->iDC - pTV->iDC);
}
iDCMode = (StrH * ORIENT_WEIGHT < StrV ? 1 : (StrV * ORIENT_WEIGHT < StrH ? 0 : 2));
}
if(iDCMode == 1 && pSC->MBInfo.iQIndexLP == pSC->PredInfoPrevRow[0][mbX].iQPIndex)
iADMode = 1;
if(iDCMode == 0 && pSC->MBInfo.iQIndexLP == pSC->PredInfo[0][mbX - 1].iQPIndex)
iADMode = 0;
return (iDCMode + (iADMode << 2));
}
Void copyAC(PixelI * src, PixelI * dst)
{
/* first row of ACs */
dst[0] = src[1];
dst[1] = src[2];
dst[2] = src[3];
/* first column of ACs */
dst[3] = src[4];
dst[4] = src[8];
dst[5] = src[12];
}
/* info of current MB to be saved for future prediction */
Void updatePredInfo(CWMImageStrCodec *pSC, CWMIMBInfo * pMBInfo, size_t mbX, COLORFORMAT cf)
{
CWMIPredInfo *pPredInfo;
PixelI * p;
Int i, iChannels = (cf == YUV_420 || cf == YUV_422) ? 1 : (Int) pSC->m_param.cNumChannels;
for(i = 0; i < iChannels; i ++){
pPredInfo = pSC->PredInfo[i] + mbX;
p = pMBInfo->iBlockDC[i];//[dcBlkIdx + i];
/* DC of DC block */
pPredInfo->iDC = p[0];
/* QP Index */
pPredInfo->iQPIndex = pMBInfo->iQIndexLP;
/* first row and first column of ACs of DC block */
copyAC(p, pPredInfo->piAD);
}
if(cf == YUV_420){ // 420 UV channels
for(i = 1U; i < 3U; i ++){
pPredInfo = pSC->PredInfo[i] + mbX;
p = pMBInfo->iBlockDC[i];//[dcBlkIdx + i];
/* DC of DC block */
pPredInfo->iDC = p[0];
/* QP Index */
pPredInfo->iQPIndex = pMBInfo->iQIndexLP;
/* first row and first column of ACs of DC block */
pPredInfo->piAD[0] = p[1];
pPredInfo->piAD[1] = p[2];
}
}
else if(cf == YUV_422){ // 420 UV channels
for(i = 1U; i < 3U; i ++){
pPredInfo = pSC->PredInfo[i] + mbX;
/* QP Index */
pPredInfo->iQPIndex = pMBInfo->iQIndexLP;
p = pMBInfo->iBlockDC[i];//[dcBlkIdx + i];
/* DC of DC block */
pPredInfo->iDC = p[0];
/* first row and first column of ACs of first DC block */
pPredInfo->piAD[0] = p[1];
pPredInfo->piAD[1] = p[2];
/* first row and first column of ACs of second DC block */
pPredInfo->piAD[2] = p[5];
pPredInfo->piAD[3] = p[6];
pPredInfo->piAD[4] = p[4]; //AC of 1D HT!!!
}
}
}

View File

@ -1,85 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "strTransform.h"
/** need to swap b and c **/
/** rounding behavior: [0 0 0 0] <-> [+ - - -]
[+ + + +] <-> [+3/4 - - -]
[- - - -] <-> [- - - -] **/
Void strDCT2x2dn(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
{
PixelI a, b, c, d, C, t;
a = *pa;
b = *pb;
C = *pc;
d = *pd;
a += d;
b -= C;
t = ((a - b) >> 1);
c = t - d;
d = t - C;
a -= d;
b += c;
*pa = a;
*pb = b;
*pc = c;
*pd = d;
}
Void strDCT2x2up(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
{
PixelI a, b, c, d, C, t;
a = *pa;
b = *pb;
C = *pc;
d = *pd;
a += d;
b -= C;
t = ((a - b + 1) >> 1);
c = t - d;
d = t - C;
a -= d;
b += c;
*pa = a;
*pb = b;
*pc = c;
*pd = d;
}
Void FOURBUTTERFLY_HARDCODED1(PixelI *p)
{
strDCT2x2dn(&p[0], &p[4], &p[8], &p[12]);
strDCT2x2dn(&p[1], &p[5], &p[9], &p[13]);
strDCT2x2dn(&p[2], &p[6], &p[10], &p[14]);
strDCT2x2dn(&p[3], &p[7], &p[11], &p[15]);
}

View File

@ -1,50 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_STRTRANSFORM_H
#define WMI_STRTRANSFORM_H
#include "windowsmediaphoto.h"
#define COMPUTE_CORNER_PRED_DIFF(a, b) (*(a) -= (b))
#define COMPUTE_CORNER_PRED_ADD(a, b) (*(a) += (b))
/** 2x2 foward DCT == 2x2 inverse DCT **/
Void strDCT2x2dn(PixelI *, PixelI *, PixelI *, PixelI *);
Void strDCT2x2up(PixelI *, PixelI *, PixelI *, PixelI *);
Void FOURBUTTERFLY_HARDCODED1(PixelI *p);
/** 2x2 dct of a group of 4**/
#define FOURBUTTERFLY(p, i00, i01, i02, i03, i10, i11, i12, i13,\
i20, i21, i22, i23, i30, i31, i32, i33) \
strDCT2x2dn(&p[i00], &p[i01], &p[i02], &p[i03]); \
strDCT2x2dn(&p[i10], &p[i11], &p[i12], &p[i13]); \
strDCT2x2dn(&p[i20], &p[i21], &p[i22], &p[i23]); \
strDCT2x2dn(&p[i30], &p[i31], &p[i32], &p[i33])
#endif // WMI_STRTRANSFORM_H

File diff suppressed because it is too large Load Diff

View File

@ -1,679 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#pragma once
#include <stddef.h>
#include "windowsmediaphoto.h"
#include "common.h"
#include "ansi.h"
//#include "xplatform_image.h"
// added for Xcode PK universal binary
#ifdef __ppc__
#define _BIG__ENDIAN_
#endif
//================================================================
#ifdef ENABLE_OPTIMIZATIONS
#if defined(WIN32) && !defined(_WIN64)
#define WMP_OPT_SSE2
#define WMP_OPT_CC_ENC
//#define WMP_OPT_TRFM_ENC
//#define WMP_OPT_QT
#define WMP_OPT_CC_DEC
#define WMP_OPT_TRFM_DEC
#define X86OPT_INLINE
#endif
#endif // ENABLE_OPTIMIZATIONS
//================================================================
//#ifdef WIN32
#if defined(WIN32) && !defined(UNDER_CE) // WIN32 seems to be defined always in VS2005 for ARM platform
#define PLATFORM_X86
#include "../x86/x86.h"
#endif
#ifndef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(P) { (P) = (P); }
#endif
#ifdef UNDER_CE
#define PLATFORM_WCE
#include "arm.h"
#endif
#ifdef __ANSI__
#define PLATFORM_ANSI
#include "ansi.h"
#endif
//================================================================
#ifdef PLATFORM_ANSI
typedef unsigned long long U64;
#else // PLATFORM_ANSI
typedef unsigned __int64 U64;
#endif // PLATFORM_ANSI
//================================================================
#define MARKERCOUNT (PACKETLENGTH * 2)
// The following macros depend on UINTPTR_T and INTPTR_T being properly defined
// so that they are equal to pointer width. Confirm and fail if our assumptions are wrong.
CT_ASSERT(sizeof(uintptr_t) == sizeof(void*), strcodec1);
CT_ASSERT(sizeof(intptr_t) == sizeof(void*), strcodec2);
// wrap around pointer, s=pow(2,n), p wraps aligned to s
#define WRAPPTR(p, s) ((void*)((uintptr_t)(p) & ~(uintptr_t)(s)))
// mask certain bit inside a pointer, simulate wrap around
#define MASKPTR(p, m) ((void*)((uintptr_t)(p) & (intptr_t)(m)))
// test for more than 1 packet data
#define PACKET1(ps, pc, s) (((intptr_t)(ps) ^ (intptr_t)(pc)) & ((uintptr_t)(s)))
// alternate pointer p between 2 values aligned to s, s=pow(2,n)
//#define ALTPTR(p, s) ((void*)((uintptr_t)(p) ^ (s)))
// align point, s=pow(2,n), p aligns to s
#define ALIGNUP(p, s) ((void*)(((uintptr_t)(p) + ((uintptr_t)(s) - 1)) & ~((uintptr_t)(s) - 1)))
#define ALIGNDOWN(p, s) ((void*)((uintptr_t)(p) & ~((uintptr_t)(s) - 1)))
//================================================================
// timer support
//================================================================
#define TraceResult(a)
//================================================================
typedef enum tagPacketType
{
PK_NULL = 0,
PK_DC = 1, PK_AD, PK_AC, PK_CP,
PK_MAX,
} PACKETTYPE;
typedef struct tagIOContext
{
U8 P0[PACKETLENGTH]; // packet circular buffer 0
U8 P1[PACKETLENGTH]; // packet circular buffer 1
union
{
U8 P2[PACKETLENGTH];
struct
{
U32 uiShadow; // shadow of P0[0]-P0[3]
U32 uiAccumulator; // 32bit acc as bit field cache
U32 cBitsUsed; // # of bits used of acc, [0,16)
U8* pbPacket; // packet pointer
U8* pbCurrent; // current pointer
struct WMPStream* pWS; // pointer to WMPStream
long offPacket; // byte offset into stream
//ULARGE_INTEGER u64Acc;
//========================================
// index packet, used for packet retrieval
//========================================
U32 cIndex; // current index for index packet
long offIndex; // byte offset into stream for index packet
}State;
}P2Info;
U8 P3[PACKETLENGTH]; // index packet buffer
} IOContext;
typedef struct tagMemReadState
{
U8* pbBuf;
size_t cbBuf;
size_t cbCur;
} MemReadState;
typedef struct tagBitIOInfo
{
U32 uiShadow; // shadow of first 4B of circular buffer
U32 uiAccumulator; // 32bit acc as bit field cache
U32 cBitsUsed; // # of bits used of acc, [0,16)
#ifdef ARMOPT_BITIO
U32 cBitsUnused; // # of bits remain unused in acc, [0,32]
#endif
I32 iMask; // mask used simulate pointer wrap around
U8* pbStart; // start pointer
#ifndef ARMOPT_BITIO
U8* pbCurrent; // current pointer
#else
U32* pbCurrent; // current pointer
#endif
struct WMPStream* pWS; // pointer to WMPStream
size_t offRef; // reference offset on IStream,
// for read, it moves along the stream
// for write, it stays at the attach point
} BitIOInfo;
//================================================================
typedef struct tagCWMIQuantizer {
U8 iIndex;
I32 iQP;
I32 iOffset;
I32 iMan;
I32 iExp;
#if defined(WMP_OPT_QT)
float f1_QP;
double d1_QP;
#endif
} CWMIQuantizer;
/* temporary bridge between old APIs and streaming APIs */
typedef struct tagCWMIMBInfo {
I32 iBlockDC[MAX_CHANNELS][16];
I32 iOrientation;
Int iCBP[MAX_CHANNELS];
Int iDiffCBP[MAX_CHANNELS];
U8 iQIndexLP; // 0 - 15
U8 iQIndexHP; // 0 - 15
} CWMIMBInfo;
struct CWMImageStrCodec;
typedef Int (*ImageDataProc)(struct CWMImageStrCodec*);
/** scan model **/
typedef struct CAdaptiveScan {
U32 uTotal;
U32 uScan;
} CAdaptiveScan;
/** Adaptive context model **/
typedef struct CCodingContext {
BitIOInfo * m_pIODC;
BitIOInfo * m_pIOLP;
BitIOInfo * m_pIOAC;
BitIOInfo * m_pIOFL;
/** adaptive huffman structs **/
CAdaptiveHuffman *m_pAdaptHuffCBPCY;
CAdaptiveHuffman *m_pAdaptHuffCBPCY1;
CAdaptiveHuffman *m_pAHexpt[NUMVLCTABLES];
/** 4x4 zigzag patterns */
CAdaptiveScan m_aScanLowpass[16];
CAdaptiveScan m_aScanHoriz[16];
CAdaptiveScan m_aScanVert[16];
/** Adaptive bit reduction model **/
CAdaptiveModel m_aModelAC;
CAdaptiveModel m_aModelLP;
CAdaptiveModel m_aModelDC;
/** Adaptive lowpass CBP model **/
Int m_iCBPCountZero;
Int m_iCBPCountMax;
/** Adaptive AC CBP model **/
CCBPModel m_aCBPModel;
/** Trim flex bits - externally set **/
Int m_iTrimFlexBits;
Bool m_bInROI; // inside ROI (for region decode and compressed domain cropping)?
} CCodingContext;
// Following stuff used to be in strPredQuant.h
/* circulant buffer for 2 MB rows: current row and previous row */
typedef struct tagCWMIPredInfo {
Int iQPIndex; // QP Index
Int iCBP; // coded block pattern
PixelI iDC; // DC of MB
PixelI iAD[6];
PixelI * piAD; // AC of DC block: [2] 420UV [4] 422UV [6] elsewhere
}CWMIPredInfo;
// the following is used on decode side while reading image info
typedef struct CWMImageStrCodecParameters {
size_t cVersion;
size_t cSubVersion;
COLORFORMAT cfColorFormat; // color format
Bool bRBSwapped; // blue and red shall be swapped in BGR555,565,101010
Bool bAlphaChannel; // alpha channel present
Bool bScaledArith; // lossless mode
Bool bIndexTable; // index table present
Bool bTrimFlexbitsFlag; // trimmed flexbits indicated in packet header
Bool bUseHardTileBoundaries; //default is soft tile boundaries
size_t cNumChannels;
size_t cExtraPixelsTop;
size_t cExtraPixelsLeft;
size_t cExtraPixelsBottom;
size_t cExtraPixelsRight;
Bool bTranscode; // transcoding flag
U32 uQPMode; // 0/1: no dquant/with dquant, first bit for DC, second bit for LP, third bit for HP
U8 uiQPIndexDC[MAX_CHANNELS];
U8 uiQPIndexLP[MAX_CHANNELS];
U8 uiQPIndexHP[MAX_CHANNELS];
}CCoreParameters;
typedef struct CWMITile
{
CWMIQuantizer * pQuantizerDC[MAX_CHANNELS];
CWMIQuantizer * pQuantizerLP[MAX_CHANNELS];
CWMIQuantizer * pQuantizerHP[MAX_CHANNELS];
U8 cNumQPLP;
U8 cNumQPHP;
U8 cBitsLP;
U8 cBitsHP;
Bool bUseDC;
Bool bUseLP;
U8 cChModeDC;
U8 cChModeLP[16];
U8 cChModeHP[16];
} CWMITile;
#ifdef ARMOPT_COLORCONVERSION_C
#include "ARM_InvColorConversion.h"
#endif
struct tagPostProcInfo{
Int iMBDC; // DC of MB
U8 ucMBTexture; // MB texture : 0(flat) 1(horizontal) 2(vertical) 3(bumpy)
Int iBlockDC[4][4]; // DC of block
U8 ucBlockTexture[4][4]; // block texture: 0(flat) 1(horizontal) 2(vertical) 3(bumpy)
};
typedef struct CWMImageStrCodec {
#ifdef ARMOPT_COLORCONVERSION_C
CWMImageStrInvCCParam InvCCParam;
#endif
size_t cbStruct;
CWMImageInfo WMII;
CWMIStrCodecParam WMISCP;
CWMImageBufferInfo WMIBI;
CWMIMBInfo MBInfo;
/** core parameters **/
CCoreParameters m_param;
struct CWMDecoderParameters *m_Dparam; // this is specified thru pointer because the same set of parameters may be used by multiple image planes
U8 cSB;
Bool m_bUVResolutionChange;
Bool bTileExtraction;
BitIOInfo * pIOHeader;
Bool bUseHardTileBoundaries; //default is soft tile boundaries
PixelI * pInterU;
PixelI * pInterV;
//============== tile related info begins here ===========
// index table
size_t *pIndexTable;
// current tile position
size_t cTileRow;
size_t cTileColumn;
// tile boundary
Bool m_bCtxLeft;
Bool m_bCtxTop;
Bool m_bResetRGITotals;
Bool m_bResetContext;
CWMITile * pTile;
// BitIOs
BitIOInfo ** m_ppBitIO;
size_t cNumBitIO;
size_t cHeaderSize;
// coding contexts
struct CCodingContext *m_pCodingContext;
size_t cNumCodingContext;
//============== tile related info ends here ===========
size_t cNumOfQPIndex; // number of QP indexes
U8 cBitsDQUANT; // number of bits to encode DQUANT
size_t cRow; // row for current macro block
size_t cColumn; // column for current macro block
size_t cmbWidth; // macro block/image width
size_t cmbHeight; // macro block/image height
size_t cbChannel; // byte/channel
size_t mbX, mbY;
size_t tileX, tileY;
Bool bVertTileBoundary, bHoriTileBoundary;
Bool bOneMBLeftVertTB, bOneMBRightVertTB; //Macroblock to the left and to the right of tile boundaries
PixelI iPredBefore[2][2];
PixelI iPredAfter[2][2];
//================================
// input data into
// macro block 3 of 2x2 working widow
//================================
ImageDataProc Load;
//ImageDataProc Load2;
ImageDataProc Transform;
ImageDataProc TransformCenter;
//================================
ImageDataProc Quantize;
//ImageDataProc QuantizeLuma;
//ImageDataProc QuantizeChroma;
//================================
// process and store data from
// macro block 0 of 2x2 working window
//================================
ImageDataProc ProcessTopLeft;
ImageDataProc ProcessTop;
ImageDataProc ProcessTopRight;
ImageDataProc ProcessLeft;
ImageDataProc ProcessCenter;
ImageDataProc ProcessRight;
ImageDataProc ProcessBottomLeft;
ImageDataProc ProcessBottom;
ImageDataProc ProcessBottomRight;
//================================
// 2 MB working window for encoder
//================================
PixelI *pPlane[MAX_CHANNELS];
//================================
// 2 rows of MB buffer
//================================
PixelI *a0MBbuffer[MAX_CHANNELS]; // pointer to start of previous MB row
PixelI *a1MBbuffer[MAX_CHANNELS]; // pointer to start of current MB row
PixelI *p0MBbuffer[MAX_CHANNELS]; // working pointer to start of previous row MB
PixelI *p1MBbuffer[MAX_CHANNELS]; // working pointer to start of current row MB
//================================
// downsampling buffer for UV
//================================
PixelI * pResU;
PixelI * pResV;
//================================
// circular buffer for 2 MB rows: current row and previous row
//================================
CWMIPredInfo *PredInfo[MAX_CHANNELS];
CWMIPredInfo *PredInfoPrevRow[MAX_CHANNELS];
CWMIPredInfo *pPredInfoMemory;
struct WMPStream ** ppWStream;
#ifdef _WINDOWS_
TCHAR **ppTempFile;
#else
char **ppTempFile;
#endif
// interleaved alpha support - linked structure for Alpha channel
struct CWMImageStrCodec *m_pNextSC;
Bool m_bSecondary;
//================================
// Perf Timers
//================================
#ifndef DISABLE_PERF_MEASUREMENT
Bool m_fMeasurePerf;
struct PERFTIMERSTATE *m_ptEndToEndPerf; // Measures from Init to Term, including I/O
struct PERFTIMERSTATE *m_ptEncDecPerf; // Measures time spent in ImageStrEncEncode/ImageStrDecDecode, excluding I/O
#endif // DISABLE_PERF_MEASUREMENT
// postproc information for 2 MB rows: 0(previous row) 1(current row)
struct tagPostProcInfo * pPostProcInfo[MAX_CHANNELS][2];
} CWMImageStrCodec;
//================================================================
ERR WMPAlloc(void** ppv, size_t cb);
ERR WMPFree(void** ppv);
//================================================================
Void initMRPtr(CWMImageStrCodec*);
Void advanceMRPtr(CWMImageStrCodec*);
Void swapMRPtr(CWMImageStrCodec*);
Int IDPEmpty(CWMImageStrCodec*);
//================================================================
extern const int dctIndex[3][16];
extern const int blkOffset[16];
extern const int blkOffsetUV[4];
extern const int blkOffsetUV_422[8];
extern const U8 idxCC[16][16];
extern const U8 idxCC_420[8][8];
extern const Char gGDISignature[];
//================================================================
Int allocatePredInfo(CWMImageStrCodec*);
Void freePredInfo(CWMImageStrCodec*);
Void advanceOneMBRow(CWMImageStrCodec*);
//================================================================
// bit I/O
//================================================================
Int allocateBitIOInfo(CWMImageStrCodec*);
Int setBitIOPointers(CWMImageStrCodec* pSC);
#ifndef ARMOPT_BITIO
U32 peekBit16(BitIOInfo* pIO, U32 cBits);
U32 flushBit16(BitIOInfo* pIO, U32 cBits);
U32 getBit16(BitIOInfo* pIO, U32 cBits);
U32 getBool16(BitIOInfo* pIO);
I32 getBit16s(BitIOInfo* pIO, U32 cBits);
U32 getBit32(BitIOInfo* pIO, U32 cBits);
U32 flushToByte(BitIOInfo* pIO);
#endif // ARMOPT_BITIO
Void putBit16z(BitIOInfo* pIO, U32 uiBits, U32 cBits);
Void putBit16(BitIOInfo* pIO, U32 uiBits, U32 cBits);
Void putBit32(BitIOInfo* pIO, U32 uiBits, U32 cBits);
Void fillToByte(BitIOInfo* pIO);
U32 getSizeRead(BitIOInfo* pIO);
U32 getSizeWrite(BitIOInfo* pIO);
U32 getPosRead(BitIOInfo* pIO);
// safe function, solely for the convenience of test code
#ifndef ARMOPT_BITIO
U32 getBit16_S(CWMImageStrCodec* pSC, BitIOInfo* pIO, U32 cBits);
#endif // ARMOPT_BITIO
//================================================================
// packet I/O
//================================================================
ERR attachISRead(BitIOInfo* pIO, struct WMPStream* pWS, CWMImageStrCodec* pSC);
ERR readIS(CWMImageStrCodec* pSC, BitIOInfo* pIO);
ERR detachISRead(CWMImageStrCodec* pSC, BitIOInfo* pIO);
ERR attachISWrite(BitIOInfo* pIO, struct WMPStream* pWS);
ERR writeIS(CWMImageStrCodec* pSC, BitIOInfo* pIO);
ERR detachISWrite(CWMImageStrCodec* pSC, BitIOInfo* pIO);
//================================================================
// post processing for decoder
//================================================================
Int initPostProc(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t mbWidth, size_t iNumChannels);
Void termPostProc(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t iNumChannels);
Void slideOneMBRow(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], size_t iNumChannels, size_t mbWidth, Bool top, Bool bottom);
Void updatePostProcInfo(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p, size_t mbX, size_t cc);
Void postProcMB(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p0, PixelI * p1, size_t mbX, size_t cc, Int threshold);
Void postProcBlock(struct tagPostProcInfo * strPostProcInfo[MAX_CHANNELS][2], PixelI * p0, PixelI * p1, size_t mbX, size_t cc, Int threshold);
//================================================================
// Simple BitIO access functions
//================================================================
typedef struct tagSimpleBitIO
{
struct WMPStream* pWS;
U32 cbRead;
U8 bAccumulator;
U32 cBitLeft;
} SimpleBitIO;
ERR attach_SB(SimpleBitIO* pSB, struct WMPStream* pWS);
U32 getBit32_SB(SimpleBitIO* pSB, U32 cBits);
Void flushToByte_SB(SimpleBitIO* pSB);
U32 getByteRead_SB(SimpleBitIO* pSB);
ERR detach_SB(SimpleBitIO* pSB);
//----------------------------------------------------------------
EXTERN_C Bool EOSWS_File(struct WMPStream* pWS);
EXTERN_C ERR ReadWS_File(struct WMPStream* pWS, void* pv, size_t cb);
EXTERN_C ERR WriteWS_File(struct WMPStream* pWS, const void* pv, size_t cb);
//EXTERN_C ERR GetLineWS_File(struct WMPStream* pWS, void* pv, size_t cb);
EXTERN_C ERR SetPosWS_File(struct WMPStream* pWS, size_t offPos);
EXTERN_C ERR GetPosWS_File(struct WMPStream* pWS, size_t* poffPos);
//----------------------------------------------------------------
EXTERN_C Bool EOSWS_Memory(struct WMPStream* pWS);
EXTERN_C ERR ReadWS_Memory(struct WMPStream* pWS, void* pv, size_t cb);
EXTERN_C ERR WriteWS_Memory(struct WMPStream* pWS, const void* pv, size_t cb);
//EXTERN_C ERR GetLineWS_Memory(struct WMPStream* pWS, void* pv, size_t cb);
EXTERN_C ERR SetPosWS_Memory(struct WMPStream* pWS, size_t offPos);
EXTERN_C ERR GetPosWS_Memory(struct WMPStream* pWS, size_t* poffPos);
//EXTERN_C ERR GetPtrWS_Memory(struct WMPStream* pWS, size_t align, U8** ppb);
//----------------------------------------------------------------
EXTERN_C Bool EOSWS_List(struct WMPStream* pWS);
EXTERN_C ERR ReadWS_List(struct WMPStream* pWS, void* pv, size_t cb);
EXTERN_C ERR WriteWS_List(struct WMPStream* pWS, const void* pv, size_t cb);
EXTERN_C ERR SetPosWS_List(struct WMPStream* pWS, size_t offPos);
EXTERN_C ERR GetPosWS_List(struct WMPStream* pWS, size_t* poffPos);
EXTERN_C ERR CreateWS_List(struct WMPStream** ppWS);
EXTERN_C ERR CloseWS_List(struct WMPStream** ppWS);
/********************************************************************/
// Stuff related to scale/spatial ordering
typedef struct PacketInfo
{
BAND m_iBand;
size_t m_iSize;
size_t m_iOffset;
struct PacketInfo *m_pNext;
} PacketInfo;
/********************************************************************/
/********************************************************************/
const static Int blkIdxByRow[4][4] = {{0, 1, 4, 5}, {2, 3, 6, 7}, {8, 9, 12, 13}, {10, 11, 14, 15}};
const static Int blkIdxByColumn[4][4] = {{0, 2, 8, 10}, {1, 3, 9, 11},{4, 6, 12, 14},{5, 7, 13, 15}};
Int getACPredMode(CWMIMBInfo *, COLORFORMAT);
Int getDCACPredMode(CWMImageStrCodec *, size_t);
Void updatePredInfo(CWMImageStrCodec* pSC, CWMIMBInfo *, size_t, COLORFORMAT);
Int AllocateCodingContextDec(struct CWMImageStrCodec *pSC, Int iNumContexts);
Void ResetCodingContext(CCodingContext *pContext);
Void getTilePos(CWMImageStrCodec* pSC, size_t mbX, size_t mbY);
Void InitZigzagScan(CCodingContext * pSC);
Int checkImageBuffer(CWMImageStrCodec *, size_t, size_t);
//U32 log2(U32);
//DQUANT stuff
EXTERN_C Void remapQP(CWMIQuantizer *, I32, Bool);
Int allocateTileInfo(CWMImageStrCodec *);
Void freeTileInfo(CWMImageStrCodec *);
Int allocateQuantizer(CWMIQuantizer * pQuantizer[MAX_CHANNELS], size_t, size_t);
Void freeQuantizer(CWMIQuantizer * pQuantizer[MAX_CHANNELS]);
Void setUniformQuantizer(CWMImageStrCodec *, size_t);
Void useDCQuantizer(CWMImageStrCodec *, size_t);
Void useLPQuantizer(CWMImageStrCodec *, size_t, size_t);
Void formatQuantizer(CWMIQuantizer * pQuantizer[MAX_CHANNELS], U8, size_t, size_t, Bool, Bool);
U8 dquantBits(U8);
#ifdef ARMOPT_BITIO
#define peekBit16 peekBits
#define flushBit16 flushBits
#define getBit16 getBits
#define getBit32 getBits
#define getBit16s getBitsS
#define getBool16(pIO) getBits(pIO, 1)
U32 peekBits(BitIOInfo* pIO, U32 cBits);
void flushBits(BitIOInfo* pIO, U32 cBits);
U32 getBits(BitIOInfo* pIO, U32 cBits);
U32 getBitsS(BitIOInfo* pIO, U32 cBits);
void flushToByte(BitIOInfo* pIO);
#endif // ARMOPT_BITIO
/*************************************************************************
Bitio defines
*************************************************************************/
#define PEEKBIT16(pIO, cBits) \
assert(0 <= (I32)cBits && cBits <= 16);\
return (pIO->uiAccumulator >> (32 - cBits/* - pIO->cBitsUsed*/));
#define FLUSHBIT16(pIO, cBits) \
assert(0 <= (I32)cBits && cBits <= 16);\
assert((pIO->iMask & 1) == 0);\
pIO->cBitsUsed += cBits;\
pIO->pbCurrent = MASKPTR(pIO->pbCurrent + ((pIO->cBitsUsed >> 3)/* & 2*/), pIO->iMask);\
pIO->cBitsUsed &= 16 - 1;\
pIO->uiAccumulator = LOAD16(pIO->pbCurrent) << pIO->cBitsUsed;\
return 0;
// pIO->uiAccumulator = LOAD16(pIO->pbCurrent) & ((U32)(-1) >> pIO->cBitsUsed);\
void OutputPerfTimerReport(CWMImageStrCodec *pState);

View File

@ -1,514 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef WMI_WINDOWSMEDIAPHOTO_H
#define WMI_WINDOWSMEDIAPHOTO_H
//================================================================
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(__cplusplus) && !defined(EXTERN_C)
#define EXTERN_C extern "C"
#elif !defined(EXTERN_C)// __cplusplus
#define EXTERN_C extern
#endif // __cplusplus
/********************************************************************************
Type definitions
********************************************************************************/
typedef int Bool;
typedef char Char;
typedef double Double;
typedef int Int;
typedef signed char I8;
typedef short I16; // 16 bit int
typedef int I32;
typedef long Long;
typedef unsigned char PixelC;
typedef int PixelI;
typedef unsigned int UInt;
typedef unsigned long ULong;
typedef unsigned char U8; // 8 bit uint
typedef unsigned short U16;
typedef unsigned int U32; // 32 bit uint
typedef void Void;
typedef void* CTXSTRCODEC;
#define REENTRANT_MODE 1
/*
DESCRIPTION OF COMPILER FLAG REENTRANT_MODE:
//#define REENTRANT_MODE 1
This compiler flag is related to the capability of banded decode
(decoding only one MB row of the source JPEG XR image at a time).
With REENTRANT_MODE defined, the decoder decodes one MB row on each call to
ImageStrDecDecode().
The decoder acts as if it can only write to the single MBRow whose pointer was passed to it.
This acts as a proof of concept that the API would work if you passed it a small buffer
on each call to ImageStrDecDecode().
The REENTRANT_MODE flag only works when the output image is in Orientations 0, 1
(vertically flipped) or 2 (horizontally flipped).
With REENTRANT_MODE defined, the function PKImageDecode_Copy_WMP()
decodes only as far as the pRect parameter indicates. The width of the rectangle must be the width
of the image, but on each call, this function will decode the image up to the end of the MB Row
which contains the i-th pixel row, where i = pRect->Y.
A target use of this version would be to have PKImageDecode_Copy_WMP() called in a loop, once for
each MB row. On each call, pRect would specify a 1-MB-Row-tall rectangle that is the width of the
image. The decoder state is preserved until the Decoder finishes decoding the image.
If, at a certain point, a request is made for a rectangle _above_ the last row decoded, then the
decoder instance is terminated and re-initiated, and decoding re-starts, going from the beginning
of the image to the end of the current rectangle.
***
We've chosen to uncomment-out this definition in this header file. An alternate method would be
to allow the user to define this in the PREPROCESSOR DEFINITIONS section of the properties page
for each of the following projects: CommonLib, DecodeLib, JXRDecApp and JXRGlueLib.
*/
/*************************************************************************
enums
*************************************************************************/
typedef enum {
ICERR_OK = 0, ICERR_ERROR = -1
} ERR_CODE;
typedef enum BITDEPTH {
BD_SHORT, BD_LONG,
/* add new BITDEPTH here */ BD_MAX
} BITDEPTH;
typedef enum BITDEPTH_BITS {
// regular ones
BD_1, //White is foreground
BD_8, BD_16, BD_16S, BD_16F, BD_32, BD_32S, BD_32F,
// irregular ones
BD_5, BD_10, BD_565,
/* add new BITDEPTH_BITS here */ BDB_MAX,
BD_1alt = 0xf, //Black is foreground
} BITDEPTH_BITS;
typedef enum OVERLAP {
OL_NONE = 0, OL_ONE, OL_TWO,
/* add new OVERLAP here */ OL_MAX
} OVERLAP;
typedef enum BITSTREAMFORMAT {
SPATIAL = 0, // spatial order
FREQUENCY, // frequency order
} BITSTREAMFORMAT;
typedef enum COLORFORMAT {
Y_ONLY = 0,
YUV_420 = 1,
YUV_422 = 2,
YUV_444 = 3,
CMYK = 4,
//CMYKDIRECT = 5,
NCOMPONENT = 6,
// these are external-only
CF_RGB = 7,
CF_RGBE = 8,
/* add new COLORFORMAT here */ CFT_MAX
} COLORFORMAT;
// rotation and flip
typedef enum ORIENTATION {
// CRW: Clock Wise 90% Rotation; FlipH: Flip Horizontally; FlipV: Flip Vertically
// Peform rotation FIRST!
// CRW FlipH FlipV
O_NONE = 0, // 0 0 0
O_FLIPV, // 0 0 1
O_FLIPH, // 0 1 0
O_FLIPVH, // 0 1 1
O_RCW, // 1 0 0
O_RCW_FLIPV, // 1 0 1
O_RCW_FLIPH, // 1 1 0
O_RCW_FLIPVH, // 1 1 1
/* add new ORIENTATION here */ O_MAX
} ORIENTATION;
typedef enum SUBBAND {
SB_ALL = 0, // keep all subbands
SB_NO_FLEXBITS, // skip flex bits
SB_NO_HIGHPASS, // skip highpass
SB_DC_ONLY, // skip lowpass and highpass, DC only
SB_ISOLATED, // not decodable
/* add new SUBBAND here */ SB_MAX
} SUBBAND;
enum { RAW = 0, BMP = 1, PPM = 2, TIF = 3, HDR = 4, IYUV = 5, YUV422 = 6, YUV444 = 7};
typedef enum {ERROR_FAIL = -1, SUCCESS_DONE, PRE_READ_HDR, PRE_SETUP, PRE_DECODE, POST_READ_HDR } WMIDecoderStatus;
#ifndef FALSE
#define FALSE 0
#endif // FALSE
#ifndef TRUE
#define TRUE 1
#endif // TRUE
#define MAX_CHANNELS 16
#define LOG_MAX_TILES 12
#define MAX_TILES (1 << LOG_MAX_TILES)
//================================================================
// Codec-specific constants
#define MB_WIDTH_PIXEL 16
#define MB_HEIGHT_PIXEL 16
#define BLK_WIDTH_PIXEL 4
#define BLK_HEIGHT_PIXEL 4
#define MB_WIDTH_BLK 4
#define MB_HEIGHT_BLK 4
// The codec operates most efficiently when the framebuffers for encoder input
// and decoder output are: 1) aligned on a particular boundary, and 2) the stride
// is also aligned to this boundary (so that each scanline is also aligned).
// This boundary is defined below.
#define FRAMEBUFFER_ALIGNMENT 128
//================================================================
#define WMP_errSuccess 0
#define WMP_errFail -1
#define WMP_errNotYetImplemented -2
#define WMP_errAbstractMethod -3
#define WMP_errOutOfMemory -101
#define WMP_errFileIO -102
#define WMP_errBufferOverflow -103
#define WMP_errInvalidParameter -104
#define WMP_errInvalidArgument -105
#define WMP_errUnsupportedFormat -106
#define WMP_errIncorrectCodecVersion -107
#define WMP_errIndexNotFound -108
#define WMP_errOutOfSequence -109
#define WMP_errNotInitialized -110
#define WMP_errMustBeMultipleOf16LinesUntilLastCall -111
#define WMP_errPlanarAlphaBandedEncRequiresTempFile -112
#define WMP_errAlphaModeCannotBeTranscoded -113
#define WMP_errIncorrectCodecSubVersion -114
//================================================================
typedef long ERR;
#define Failed(err) ((err)<0)
#define CRLF "\r\n"
#define CT_ASSERT(exp, uniq) typedef char __CT_ASSERT__##uniq[(exp) ? 1 : -1] // Caller must provide a unique tag, or this fails to compile under GCC
#if defined(_DEBUG) || defined(DBG)
#define Report(err, szExp, szFile, nLine) \
fprintf(stderr, "FAILED: %ld=%s" CRLF, (err), (szExp)); \
fprintf(stderr, " %s:%ld" CRLF, (szFile), (nLine)); \
#else
#define Report(err, szExp, szFile, lLine) err = err
#endif
#define Call(exp) \
if (Failed(err = (exp))) \
{ \
Report(err, #exp, __FILE__, (long)__LINE__); \
goto Cleanup; \
} \
else err = err
#define CallIgnoreError(errTmp, exp) \
if (Failed(errTmp = (exp))) \
{ \
Report(errTmp, #exp, __FILE__, (long)__LINE__); \
} \
else errTmp = errTmp
#define Test(exp, err) Call((exp) ? WMP_errSuccess : (err))
#define FailIf(exp, err) Call((exp) ? (err) : WMP_errSuccess)
//================================================================
// WMPStream interface
//================================================================
struct WMPStream
{
union
{
struct tagFile
{
FILE* pFile;
} file;
struct tagBuf
{
U8* pbBuf;
size_t cbBuf;
size_t cbCur;
size_t cbBufCount;
} buf;
void* pvObj;
} state;
Bool fMem;
ERR (*Close)(struct WMPStream** pme);
Bool (*EOS)(struct WMPStream* me);
ERR (*Read)(struct WMPStream* me, void* pv, size_t cb);
ERR (*Write)(struct WMPStream* me, const void* pv, size_t cb);
//ERR (*GetLine)(struct WMPStream* me, void* pv, size_t cb);
ERR (*SetPos)(struct WMPStream* me, size_t offPos);
ERR (*GetPos)(struct WMPStream* me, size_t* poffPos);
};
EXTERN_C ERR CreateWS_File(struct WMPStream** ppWS, const char* szFilename, const char* szMode);
EXTERN_C ERR CloseWS_File(struct WMPStream** ppWS);
EXTERN_C ERR CreateWS_Memory(struct WMPStream** ppWS, void* pv, size_t cb);
EXTERN_C ERR CloseWS_Memory(struct WMPStream** ppWS);
//================================================================
// Enc/Dec data structure
//================================================================
typedef struct tagCWMImageInfo {
size_t cWidth;
size_t cHeight;
COLORFORMAT cfColorFormat;
BITDEPTH_BITS bdBitDepth;
size_t cBitsPerUnit;
size_t cLeadingPadding; // number of leading padding
Bool bRGB; // true: RGB; false: BGR
U8 cChromaCenteringX; // Relative location of Chroma w.r.t Luma
U8 cChromaCenteringY; // Relative location of Chroma w.r.t Luma
// Region of interest decoding
size_t cROILeftX;
size_t cROIWidth;
size_t cROITopY;
size_t cROIHeight;
// thumbnail decode
Bool bSkipFlexbits;
size_t cThumbnailWidth;
size_t cThumbnailHeight;
// image orientation
ORIENTATION oOrientation;
// post processing
U8 cPostProcStrength; // 0(none) 1(light) 2(medium) 3(strong) 4(very strong)
// user buffer is always padded to whole MB
Bool fPaddedUserBuffer;
} CWMImageInfo;
typedef struct tagCWMIStrCodecParam {
Bool bVerbose;
// for macroblock quantization (DQUANT)
U8 uiDefaultQPIndex;
U8 uiDefaultQPIndexYLP;
U8 uiDefaultQPIndexYHP;
U8 uiDefaultQPIndexU;
U8 uiDefaultQPIndexULP;
U8 uiDefaultQPIndexUHP;
U8 uiDefaultQPIndexV;
U8 uiDefaultQPIndexVLP;
U8 uiDefaultQPIndexVHP;
U8 uiDefaultQPIndexAlpha;
COLORFORMAT cfColorFormat;
BITDEPTH bdBitDepth;
OVERLAP olOverlap;
BITSTREAMFORMAT bfBitstreamFormat;
size_t cChannel; // number of color channels including alpha
U8 uAlphaMode; // 0:no alpha 1: alpha only else: something + alpha
SUBBAND sbSubband; // which subbands to keep
U8 uiTrimFlexBits;
struct WMPStream* pWStream;
size_t cbStream;
// tiling info
U32 cNumOfSliceMinus1V; // # of vertical slices
U32 uiTileX[MAX_TILES]; // width in MB of each veritical slice
U32 cNumOfSliceMinus1H; // # of horizontal slices
U32 uiTileY[MAX_TILES]; // height in MB of each horizontal slice
//32f and 32s conversion parameters
U8 nLenMantissaOrShift;
I8 nExpBias;
Bool bBlackWhite;
Bool bUseHardTileBoundaries; //default is soft tile boundaries
Bool bProgressiveMode; //default is sequential mode
Bool bYUVData; //default is cfColorFormat data
Bool bUnscaledArith; //force unscaled arithmetic
// Perf measurement
Bool fMeasurePerf;
} CWMIStrCodecParam;
typedef struct tagCWMImageBufferInfo {
void* pv; // pointer to scanline buffer
size_t cLine; // count of scanlines
size_t cbStride; // count of BYTE for stride
#ifdef REENTRANT_MODE
unsigned int uiFirstMBRow; // Current First MB Row being decoded
unsigned int uiLastMBRow; // Current Last MB Row being decoded
size_t cLinesDecoded; // Number of lines decoded and returned in low-mem mode
#endif // REENTRANT_MODE
} CWMImageBufferInfo;
/****************************************************************/
/* Encode API */
/****************************************************************/
EXTERN_C Int ImageStrEncInit(
CWMImageInfo* pII,
CWMIStrCodecParam *pSCP,
CTXSTRCODEC* pctxSC);
EXTERN_C Int ImageStrEncEncode(
CTXSTRCODEC ctxSC,
const CWMImageBufferInfo* pBI);
EXTERN_C Int ImageStrEncTerm(
CTXSTRCODEC ctxSC);
/****************************************************************/
/* Decode API */
/****************************************************************/
struct CWMImageStrCodec;
EXTERN_C Int ImageStrDecGetInfo(
CWMImageInfo* pII,
CWMIStrCodecParam *pSCP);
EXTERN_C Int ImageStrDecInit(
CWMImageInfo* pII,
CWMIStrCodecParam *pSCP,
CTXSTRCODEC* pctxSC);
EXTERN_C Int ImageStrDecDecode(
CTXSTRCODEC ctxSC,
const CWMImageBufferInfo* pBI
#ifdef REENTRANT_MODE
, size_t *pcDecodedLines
#endif
);
EXTERN_C Int ImageStrDecTerm(
CTXSTRCODEC ctxSC);
EXTERN_C Int WMPhotoValidate(
CWMImageInfo * pII,
CWMIStrCodecParam * pSCP);
/****************************************************************/
/* Transcoding API */
/****************************************************************/
typedef struct tagCWMTranscodingParam {
size_t cLeftX;
size_t cWidth;
size_t cTopY;
size_t cHeight; // interested region
BITSTREAMFORMAT bfBitstreamFormat; // desired bitstream format
// COLORFORMAT cfColorFormat; // desired color format
U8 uAlphaMode; // 0:no alpha 1: alpha only else: something + alpha
SUBBAND sbSubband; // which subbands to keep
ORIENTATION oOrientation; // flip / right angle rotation
Bool bIgnoreOverlap;
} CWMTranscodingParam;
EXTERN_C Int WMPhotoTranscode(
struct WMPStream* pStreamDec, // input bitstrean
struct WMPStream* pStreamEnc, // output bitstream
CWMTranscodingParam* pParam // transcoding parameters
);
typedef struct tagCWMDetilingParam {
size_t cWidth;
size_t cHeight; // image size
size_t cChannel; // # of channels
OVERLAP olOverlap; // overlap
BITDEPTH_BITS bdBitdepth; // bit depth
// tiling info
U32 cNumOfSliceMinus1V; // # of vertical slices
U32 uiTileX[MAX_TILES]; // position in MB of each veritical slice
U32 cNumOfSliceMinus1H; // # of horizontal slices
U32 uiTileY[MAX_TILES]; // position in MB of each horizontal slice
// image info
void * pImage;
size_t cbStride;
} CWMDetilingParam;
EXTERN_C Int WMPhotoDetile(
CWMDetilingParam * pParam // detiling parameters
);
#endif // WMI_WINDOWSMEDIAPHOTO_H

View File

@ -1,83 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef XPLATFORM_IMAGE_H
#define XPLATFORM_IMAGE_H
#ifdef __ANSI__
// ANSI
#define FORCE_INLINE
#define CDECL
#define UINTPTR_T unsigned int
#define INTPTR_T int
#define DECLSPEC_ALIGN(bytes)
#endif // __ANSI__
//#if defined(WIN32)
#if defined(WIN32) && !defined(UNDER_CE) // WIN32 seems to be defined always in VS2005 for ARM platform
// x86
//#define CDECL __cdecl
#define DECLSPEC_ALIGN(bytes) __declspec(align(bytes))
#endif // x86
#if defined(_ARM_) || defined(UNDER_CE)
// ARM, WinCE
#define FORCE_INLINE inline
#define CDECL
#define UINTPTR_T unsigned int
#define INTPTR_T int
#define DECLSPEC_ALIGN(bytes)
// parser
#define FULL_PATH_CONFIG_FILE_ENCODE "\\ConfigFile_encode.txt"
#define FULL_PATH_CONFIG_FILE_DECODE "\\ConfigFile_decode.txt"
#define MAX_ARGC 14
#define MaxCharReadCount 10
#define MAX_FNAME 256
#define DELIMITER "filelist:"
#define CODEC_ENCODE "encode"
#define CODEC_DECODE "decode"
#define PHOTON "ptn"
#define OUTRAW "raw"
#define OUTBMP "bmp"
#define OUTPPM "ppm"
#define OUTTIF "tif"
#define OUTHDR "hdr"
#define OUTIYUV "iyuv"
#define OUTYUV422 "yuv422"
#define OUTYUV444 "yuv444"
int XPLATparser(char *pcARGV[], char *pcCodec);
void freeXPLATparser(int iARGC, char *pcARGV[]);
// WinCE intrinsic
#include <Cmnintrin.h>
#endif // ARM, WinCE
#endif // XPLATFORM_IMAGE_H

View File

@ -1,83 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#ifndef XPLATFORM_IMAGE_H
#define XPLATFORM_IMAGE_H
#ifdef __ANSI__
// ANSI
#define FORCE_INLINE
#define CDECL
#define UINTPTR_T unsigned int
#define INTPTR_T int
#define DECLSPEC_ALIGN(bytes)
#endif // __ANSI__
//#if defined(WIN32)
#if defined(WIN32) && !defined(UNDER_CE) // WIN32 seems to be defined always in VS2005 for ARM platform
// x86
//#define CDECL __cdecl
#define DECLSPEC_ALIGN(bytes) __declspec(align(bytes))
#endif // x86
#if defined(_ARM_) || defined(UNDER_CE)
// ARM, WinCE
#define FORCE_INLINE inline
#define CDECL
#define UINTPTR_T unsigned int
#define INTPTR_T int
#define DECLSPEC_ALIGN(bytes)
// parser
#define FULL_PATH_CONFIG_FILE_ENCODE "\\ConfigFile_encode.txt"
#define FULL_PATH_CONFIG_FILE_DECODE "\\ConfigFile_decode.txt"
#define MAX_ARGC 14
#define MaxCharReadCount 10
#define MAX_FNAME 256
#define DELIMITER "filelist:"
#define CODEC_ENCODE "encode"
#define CODEC_DECODE "decode"
#define PHOTON "ptn"
#define OUTRAW "raw"
#define OUTBMP "bmp"
#define OUTPPM "ppm"
#define OUTTIF "tif"
#define OUTHDR "hdr"
#define OUTIYUV "iyuv"
#define OUTYUV422 "yuv422"
#define OUTYUV444 "yuv444"
int XPLATparser(char *pcARGV[], char *pcCodec);
void freeXPLATparser(int iARGC, char *pcARGV[]);
// WinCE intrinsic
#include <Cmnintrin.h>
#endif // ARM, WinCE
#endif // XPLATFORM_IMAGE_H

View File

@ -1,193 +0,0 @@
/*
* Copyright (C) 2000 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef GUID_DEFINED
#define GUID_DEFINED
#ifdef __WIDL__
typedef struct
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
byte Data4[ 8 ];
} GUID;
#else
typedef struct _GUID
{
#ifdef WINE_USE_LONG
unsigned long Data1;
#else
unsigned int Data1;
#endif
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[ 8 ];
} GUID;
#endif
/* Macros for __uuidof emulation */
#ifdef __cplusplus
# if defined(__MINGW32__)
# define __WINE_UUID_ATTR __attribute__((selectany))
# elif defined(__GNUC__)
# define __WINE_UUID_ATTR __attribute__((visibility("hidden"),weak))
# endif
#endif
#ifdef __WINE_UUID_ATTR
extern "C++" {
template<typename T> struct __wine_uuidof;
template<typename T> struct __wine_uuidof_type {
typedef __wine_uuidof<T> inst;
};
template<typename T> struct __wine_uuidof_type<T *> {
typedef __wine_uuidof<T> inst;
};
template<typename T> struct __wine_uuidof_type<T * const> {
typedef __wine_uuidof<T> inst;
};
}
#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
extern "C++" { \
template<> struct __wine_uuidof<type> { \
static const GUID uuid; \
}; \
__WINE_UUID_ATTR const GUID __wine_uuidof<type>::uuid = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}; \
}
#define __uuidof(type) __wine_uuidof_type<__typeof__(type)>::inst::uuid
#else /* __WINE_UUID_ATTR */
#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
#endif /* __WINE_UUID_ATTR */
#endif
#undef DEFINE_GUID
#ifndef DECLSPEC_HIDDEN
# if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__CYGWIN__)
# define DECLSPEC_HIDDEN __attribute__((visibility ("hidden")))
# else
# define DECLSPEC_HIDDEN
# endif
#endif
#ifdef INITGUID
#ifdef __cplusplus
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
EXTERN_C const GUID name DECLSPEC_HIDDEN; \
EXTERN_C const GUID name = \
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#else
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
const GUID name DECLSPEC_HIDDEN; \
const GUID name = \
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#endif
#else
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
EXTERN_C const GUID name DECLSPEC_HIDDEN
#endif
#define DEFINE_OLEGUID(name, l, w1, w2) \
DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
#ifndef _GUIDDEF_H_
#define _GUIDDEF_H_
#ifndef __LPGUID_DEFINED__
#define __LPGUID_DEFINED__
typedef GUID *LPGUID;
#endif
#ifndef __LPCGUID_DEFINED__
#define __LPCGUID_DEFINED__
typedef const GUID *LPCGUID;
#endif
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
typedef GUID IID,*LPIID;
typedef GUID CLSID,*LPCLSID;
typedef GUID FMTID,*LPFMTID;
#define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
#define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
#define IsEqualFMTID(rfmtid1, rfmtid2) IsEqualGUID(rfmtid1, rfmtid2)
#define IID_NULL GUID_NULL
#define CLSID_NULL GUID_NULL
#define FMTID_NULL GUID_NULL
#ifdef __midl_proxy
#define __MIDL_CONST
#else
#define __MIDL_CONST const
#endif
#endif /* ndef __IID_DEFINED__ */
#ifdef __cplusplus
#define REFGUID const GUID &
#define REFCLSID const CLSID &
#define REFIID const IID &
#define REFFMTID const FMTID &
#else
#define REFGUID const GUID* __MIDL_CONST
#define REFCLSID const CLSID* __MIDL_CONST
#define REFIID const IID* __MIDL_CONST
#define REFFMTID const FMTID* __MIDL_CONST
#endif
#ifdef __cplusplus
#define IsEqualGUID(rguid1, rguid2) (!memcmp(&(rguid1), &(rguid2), sizeof(GUID)))
inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
{
return (((unsigned int *)&rguid1)[0] == ((unsigned int *)&rguid2)[0] &&
((unsigned int *)&rguid1)[1] == ((unsigned int *)&rguid2)[1] &&
((unsigned int *)&rguid1)[2] == ((unsigned int *)&rguid2)[2] &&
((unsigned int *)&rguid1)[3] == ((unsigned int *)&rguid2)[3]);
}
#else
#define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
#define InlineIsEqualGUID(rguid1, rguid2) \
(((unsigned int *)rguid1)[0] == ((unsigned int *)rguid2)[0] && \
((unsigned int *)rguid1)[1] == ((unsigned int *)rguid2)[1] && \
((unsigned int *)rguid1)[2] == ((unsigned int *)rguid2)[2] && \
((unsigned int *)rguid1)[3] == ((unsigned int *)rguid2)[3])
#endif
#ifdef __cplusplus
#include <string.h>
inline bool operator==(const GUID& guidOne, const GUID& guidOther)
{
return !memcmp(&guidOne,&guidOther,sizeof(GUID));
}
inline bool operator!=(const GUID& guidOne, const GUID& guidOther)
{
return !(guidOne == guidOther);
}
#endif
#endif /* _GUIDDEF_H_ */

View File

@ -1,929 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include <stdlib.h>
#include <ctype.h>
#define INITGUID
#include "JXRGlue.h"
//================================================================
const PKIID IID_PKImageScanEncode = 1;
const PKIID IID_PKImageFrameEncode = 2;
const PKIID IID_PKImageUnsupported = 100;
const PKIID IID_PKImageWmpEncode = 101;
const PKIID IID_PKImageWmpDecode = 201;
//================================================================
// Misc supporting functions
//================================================================
ERR PKAlloc(void** ppv, size_t cb)
{
*ppv = calloc(1, cb);
return *ppv ? WMP_errSuccess : WMP_errOutOfMemory;
}
ERR PKFree(void** ppv)
{
if (ppv)
{
free(*ppv);
*ppv = NULL;
}
return WMP_errSuccess;
}
ERR PKAllocAligned(void** ppv, size_t cb, size_t iAlign)
{
U8 *pOrigPtr;
U8 *pReturnedPtr;
size_t iAlignmentCorrection;
const size_t c_cbBlockSize = cb + sizeof(void*) + iAlign - 1;
*ppv = NULL;
pOrigPtr = calloc(1, c_cbBlockSize);
if (NULL == pOrigPtr)
return WMP_errOutOfMemory;
iAlignmentCorrection = iAlign - ((size_t)pOrigPtr % iAlign);
if (iAlignmentCorrection < sizeof(void*))
// Alignment correction won't leave us enough space to store pOrigPtr - advance to next block
iAlignmentCorrection += iAlign;
assert(iAlignmentCorrection >= sizeof(void*)); // Alignment correction must have space for pOrigPtr
assert(iAlignmentCorrection + cb <= c_cbBlockSize); // Don't exceed right edge of memory block
pReturnedPtr = pOrigPtr + iAlignmentCorrection;
*(void**)(pReturnedPtr - sizeof(void*)) = pOrigPtr;
assert(0 == ((size_t)pReturnedPtr % iAlign)); // Are we in fact aligned?
*ppv = pReturnedPtr;
return WMP_errSuccess;
}
ERR PKFreeAligned(void** ppv)
{
if (ppv && *ppv)
{
U8 **ppOrigPtr = (U8**)((U8*)(*ppv) - sizeof(void*));
assert(*ppOrigPtr <= (U8*)ppOrigPtr); // Something's wrong if pOrigPtr points forward
free(*ppOrigPtr);
*ppv = NULL;
}
return WMP_errSuccess;
}
int PKStrnicmp(const char* s1, const char* s2, size_t c)
{
for(; tolower(*s1) == tolower(*s2) && *s1 && *s2 && c; ++s1, ++s2, --c);
return c ? *s1 - *s2 : 0;
}
static const PKPixelInfo pixelInfo[] =
{
{&GUID_PKPixelFormatDontCare, 1, Y_ONLY, BD_8, 8, PK_pixfmtNul, 0, 0, 0, 0},
// Gray
//{&GUID_PKPixelFormat2bppGray, 1, Y_ONLY, BD_8, 2, PK_pixfmtNul},
//{&GUID_PKPixelFormat4bppGray, 1, Y_ONLY, BD_8, 4, PK_pixfmtNul},
{&GUID_PKPixelFormatBlackWhite, 1, Y_ONLY, BD_1, 1, PK_pixfmtNul, 1, 1, 1, 1},//BlackIsZero is default for GUID_PKPixelFormatBlackWhite
{&GUID_PKPixelFormatBlackWhite, 1, Y_ONLY, BD_1, 1, PK_pixfmtNul, 0, 1, 1, 1},//WhiteIsZero
{&GUID_PKPixelFormat8bppGray, 1, Y_ONLY, BD_8, 8, PK_pixfmtNul, 1, 1, 8, 1},
{&GUID_PKPixelFormat16bppGray, 1, Y_ONLY, BD_16, 16, PK_pixfmtNul, 1, 1, 16, 1},
{&GUID_PKPixelFormat16bppGrayFixedPoint, 1, Y_ONLY, BD_16S, 16, PK_pixfmtNul, 1, 1, 16, 2},
{&GUID_PKPixelFormat16bppGrayHalf, 1, Y_ONLY, BD_16F, 16, PK_pixfmtNul, 1, 1, 16, 3},
//{&GUID_PKPixelFormat32bppGray, 1, Y_ONLY, BD_32, 32, PK_pixfmtNul, 1, 1, 32, 1},
{&GUID_PKPixelFormat32bppGrayFixedPoint, 1, Y_ONLY, BD_32S, 32, PK_pixfmtNul, 1, 1, 32, 2},
{&GUID_PKPixelFormat32bppGrayFloat, 1, Y_ONLY, BD_32F, 32, PK_pixfmtNul, 1, 1, 32, 3},
// RGB
{&GUID_PKPixelFormat24bppRGB, 3, CF_RGB, BD_8, 24, PK_pixfmtNul, 2, 3, 8, 1},
{&GUID_PKPixelFormat24bppBGR, 3, CF_RGB, BD_8, 24, PK_pixfmtBGR, 2, 3, 8, 1},
{&GUID_PKPixelFormat32bppRGB, 3, CF_RGB, BD_8, 32, PK_pixfmtNul, 2, 3, 8, 1},
{&GUID_PKPixelFormat32bppBGR, 3, CF_RGB, BD_8, 32, PK_pixfmtBGR, 2, 3, 8, 1},
{&GUID_PKPixelFormat48bppRGB, 3, CF_RGB, BD_16, 48, PK_pixfmtNul, 2, 3, 16, 1},
{&GUID_PKPixelFormat48bppRGBFixedPoint, 3, CF_RGB, BD_16S, 48, PK_pixfmtNul, 2, 3, 16, 2},
{&GUID_PKPixelFormat48bppRGBHalf, 3, CF_RGB, BD_16F, 48, PK_pixfmtNul, 2, 3, 16, 3},
{&GUID_PKPixelFormat64bppRGBFixedPoint, 3, CF_RGB, BD_16S, 64, PK_pixfmtNul, 2, 3, 16, 2},
{&GUID_PKPixelFormat64bppRGBHalf, 3, CF_RGB, BD_16F, 64, PK_pixfmtNul, 2, 3, 16, 3},
//{&GUID_PKPixelFormat96bppRGB, 3, CF_RGB, BD_32, 96, PK_pixfmtNul, 2, 3, 32, 1},
{&GUID_PKPixelFormat96bppRGBFixedPoint, 3, CF_RGB, BD_32S, 96, PK_pixfmtNul, 2, 3, 32, 2},
{&GUID_PKPixelFormat96bppRGBFloat, 3, CF_RGB, BD_32F, 96, PK_pixfmtNul, 2, 3, 32, 3},
{&GUID_PKPixelFormat128bppRGBFixedPoint, 3, CF_RGB, BD_32S, 128, PK_pixfmtNul, 2, 3, 32, 2},
{&GUID_PKPixelFormat128bppRGBFloat, 3, CF_RGB, BD_32F, 128, PK_pixfmtNul, 2, 3, 32, 3},
// RGBA
{&GUID_PKPixelFormat32bppBGRA, 4, CF_RGB, BD_8, 32, PK_pixfmtHasAlpha | PK_pixfmtBGR, 2, 4, 8, 1},
{&GUID_PKPixelFormat32bppRGBA, 4, CF_RGB, BD_8, 32, PK_pixfmtHasAlpha, 2, 4, 8, 1},
{&GUID_PKPixelFormat64bppRGBA, 4, CF_RGB, BD_16, 64, PK_pixfmtHasAlpha, 2, 4, 16, 1},
{&GUID_PKPixelFormat64bppRGBAFixedPoint, 4, CF_RGB, BD_16S, 64, PK_pixfmtHasAlpha, 2, 4, 16, 2},
{&GUID_PKPixelFormat64bppRGBAHalf, 4, CF_RGB, BD_16F, 64, PK_pixfmtHasAlpha, 2, 4, 16, 3},
//{&GUID_PKPixelFormat128bppRGBA, 4, CF_RGB, BD_32, 128, PK_pixfmtHasAlpha, 2, 4, 32, 1},
{&GUID_PKPixelFormat128bppRGBAFixedPoint, 4, CF_RGB, BD_32S, 128, PK_pixfmtHasAlpha, 2, 4, 32, 2},
{&GUID_PKPixelFormat128bppRGBAFloat, 4, CF_RGB, BD_32F, 128, PK_pixfmtHasAlpha, 2, 4, 32, 3},
// PRGBA
{&GUID_PKPixelFormat32bppPBGRA, 4, CF_RGB, BD_8, 32, PK_pixfmtHasAlpha | PK_pixfmtPreMul | PK_pixfmtBGR, 2, 4, 8, 1},
{&GUID_PKPixelFormat32bppPRGBA, 4, CF_RGB, BD_8, 32, PK_pixfmtHasAlpha | PK_pixfmtPreMul, 2, 4, 8, 1},
{&GUID_PKPixelFormat64bppPRGBA, 4, CF_RGB, BD_16, 64, PK_pixfmtHasAlpha | PK_pixfmtPreMul, 2, 4, 16, 1},
//{&GUID_PKPixelFormat64bppPRGBAFixedPoint, 4, CF_RGB, BD_16S, 64, PK_pixfmtHasAlpha, 2, 4, 16, 2},
//{&GUID_PKPixelFormat64bppPRGBAHalf, 4, CF_RGB, BD_16F, 64, PK_pixfmtHasAlpha, 2, 4, 16, 3},
//{&GUID_PKPixelFormat128bppPRGBAFixedPoint, 4, CF_RGB, BD_32S, 128, PK_pixfmtHasAlpha, 2, 4, 32, 2},
{&GUID_PKPixelFormat128bppPRGBAFloat, 4, CF_RGB, BD_32F, 128, PK_pixfmtHasAlpha | PK_pixfmtPreMul, 2, 4, 32, 3},
// Packed formats
{&GUID_PKPixelFormat16bppRGB555, 3, CF_RGB, BD_5, 16, PK_pixfmtNul, 2, 3, 5, 1},
{&GUID_PKPixelFormat16bppRGB565, 3, CF_RGB, BD_565, 16, PK_pixfmtNul, 2, 3, 6, 1},
{&GUID_PKPixelFormat32bppRGB101010, 3, CF_RGB, BD_10, 32, PK_pixfmtNul, 2, 3, 10, 1},
// CMYK
{&GUID_PKPixelFormat32bppCMYK, 4, CMYK, BD_8, 32, PK_pixfmtNul, 5, 4, 8, 1},
{&GUID_PKPixelFormat40bppCMYKAlpha, 5, CMYK, BD_8, 40, PK_pixfmtHasAlpha, 5, 5, 8, 1},
{&GUID_PKPixelFormat64bppCMYK, 4, CMYK, BD_16, 64, PK_pixfmtNul, 5, 4, 16, 1},
{&GUID_PKPixelFormat80bppCMYKAlpha, 5, CMYK, BD_16, 80, PK_pixfmtHasAlpha, 5, 5, 16, 1},
// N_CHANNEL
{&GUID_PKPixelFormat24bpp3Channels, 3, NCOMPONENT, BD_8, 24, PK_pixfmtNul, PK_PI_NCH, 3, 8, 1},//the N channel TIF by PS has PhotometricInterpretation of PK_PI_RGB
{&GUID_PKPixelFormat32bpp4Channels, 4, NCOMPONENT, BD_8, 32, PK_pixfmtNul, PK_PI_NCH, 4, 8, 1},
{&GUID_PKPixelFormat40bpp5Channels, 5, NCOMPONENT, BD_8, 40, PK_pixfmtNul, PK_PI_NCH, 5, 8, 1},
{&GUID_PKPixelFormat48bpp6Channels, 6, NCOMPONENT, BD_8, 48, PK_pixfmtNul, PK_PI_NCH, 6, 8, 1},
{&GUID_PKPixelFormat56bpp7Channels, 7, NCOMPONENT, BD_8, 56, PK_pixfmtNul, PK_PI_NCH, 7, 8, 1},
{&GUID_PKPixelFormat64bpp8Channels, 8, NCOMPONENT, BD_8, 64, PK_pixfmtNul, PK_PI_NCH, 8, 8, 1},
{&GUID_PKPixelFormat32bpp3ChannelsAlpha, 4, NCOMPONENT, BD_8, 32, PK_pixfmtHasAlpha, PK_PI_NCH, 4, 8, 1},
{&GUID_PKPixelFormat40bpp4ChannelsAlpha, 5, NCOMPONENT, BD_8, 40, PK_pixfmtHasAlpha, PK_PI_NCH, 5, 8, 1},
{&GUID_PKPixelFormat48bpp5ChannelsAlpha, 6, NCOMPONENT, BD_8, 48, PK_pixfmtHasAlpha, PK_PI_NCH, 6, 8, 1},
{&GUID_PKPixelFormat56bpp6ChannelsAlpha, 7, NCOMPONENT, BD_8, 56, PK_pixfmtHasAlpha, PK_PI_NCH, 7, 8, 1},
{&GUID_PKPixelFormat64bpp7ChannelsAlpha, 8, NCOMPONENT, BD_8, 64, PK_pixfmtHasAlpha, PK_PI_NCH, 8, 8, 1},
{&GUID_PKPixelFormat72bpp8ChannelsAlpha, 9, NCOMPONENT, BD_8, 72, PK_pixfmtHasAlpha, PK_PI_NCH, 9, 8, 1},
{&GUID_PKPixelFormat48bpp3Channels, 3, NCOMPONENT, BD_16, 48, PK_pixfmtNul, PK_PI_NCH, 3, 16, 1},
{&GUID_PKPixelFormat64bpp4Channels, 4, NCOMPONENT, BD_16, 64, PK_pixfmtNul, PK_PI_NCH, 4, 16, 1},
{&GUID_PKPixelFormat80bpp5Channels, 5, NCOMPONENT, BD_16, 80, PK_pixfmtNul, PK_PI_NCH, 5, 16, 1},
{&GUID_PKPixelFormat96bpp6Channels, 6, NCOMPONENT, BD_16, 96, PK_pixfmtNul, PK_PI_NCH, 6, 16, 1},
{&GUID_PKPixelFormat112bpp7Channels, 7, NCOMPONENT, BD_16, 112, PK_pixfmtNul, PK_PI_NCH, 7, 16, 1},
{&GUID_PKPixelFormat128bpp8Channels, 8, NCOMPONENT, BD_16, 128, PK_pixfmtNul, PK_PI_NCH, 8, 16, 1},
{&GUID_PKPixelFormat64bpp3ChannelsAlpha, 4, NCOMPONENT, BD_16, 64, PK_pixfmtHasAlpha, PK_PI_NCH, 4, 16, 1},
{&GUID_PKPixelFormat80bpp4ChannelsAlpha, 5, NCOMPONENT, BD_16, 80, PK_pixfmtHasAlpha, PK_PI_NCH, 5, 16, 1},
{&GUID_PKPixelFormat96bpp5ChannelsAlpha, 6, NCOMPONENT, BD_16, 96, PK_pixfmtHasAlpha, PK_PI_NCH, 6, 16, 1},
{&GUID_PKPixelFormat112bpp6ChannelsAlpha, 7, NCOMPONENT, BD_16, 112, PK_pixfmtHasAlpha, PK_PI_NCH, 7, 16, 1},
{&GUID_PKPixelFormat128bpp7ChannelsAlpha, 8, NCOMPONENT, BD_16, 128, PK_pixfmtHasAlpha, PK_PI_NCH, 8, 16, 1},
{&GUID_PKPixelFormat144bpp8ChannelsAlpha, 9, NCOMPONENT, BD_16, 144, PK_pixfmtHasAlpha, PK_PI_NCH, 9, 16, 1},
//RGBE
{&GUID_PKPixelFormat32bppRGBE, 4, CF_RGBE, BD_8, 32, PK_pixfmtNul, PK_PI_RGBE, 4, 8, 1},
//YUV
{&GUID_PKPixelFormat12bppYUV420, 3, YUV_420, BD_8, 48, PK_pixfmtNul},
{&GUID_PKPixelFormat16bppYUV422, 3, YUV_422, BD_8, 32, PK_pixfmtNul},
{&GUID_PKPixelFormat24bppYUV444, 3, YUV_444, BD_8, 24, PK_pixfmtNul},
};
//----------------------------------------------------------------
//ERR GetPixelInfo(PKPixelFormatGUID enPixelFormat, const PKPixelInfo** ppPI)
ERR PixelFormatLookup(PKPixelInfo* pPI, U8 uLookupType)
{
ERR err = WMP_errSuccess;
size_t i;
for (i = 0; i < sizeof2(pixelInfo); ++i)
{
if (LOOKUP_FORWARD == uLookupType)
{
if (IsEqualGUID(pPI->pGUIDPixFmt, pixelInfo[i].pGUIDPixFmt))
{
*pPI = pixelInfo[i];
goto Cleanup;
}
}
else if (LOOKUP_BACKWARD_TIF == uLookupType)
{
if (pPI->uSamplePerPixel == pixelInfo[i].uSamplePerPixel &&
pPI->uBitsPerSample == pixelInfo[i].uBitsPerSample &&
pPI->uSampleFormat == pixelInfo[i].uSampleFormat &&
pPI->uInterpretation == pixelInfo[i].uInterpretation)
{
// match alpha & premult
if ((pPI->grBit & (PK_pixfmtHasAlpha | PK_pixfmtPreMul)) ==
(pixelInfo[i].grBit & (PK_pixfmtHasAlpha | PK_pixfmtPreMul)))
{
*pPI = pixelInfo[i];
goto Cleanup;
}
}
}
}
Call(WMP_errUnsupportedFormat);
Cleanup:
return err;
}
const PKPixelFormatGUID* GetPixelFormatFromHash(const U8 uPFHash)
{
int i;
for (i = 0; i < sizeof2(pixelInfo); i++)
{
if (pixelInfo[i].pGUIDPixFmt->Data4[7] == uPFHash)
return pixelInfo[i].pGUIDPixFmt;
}
// If we reached this point, we did not find anything which matched the hash
return NULL;
}
//----------------------------------------------------------------
typedef struct tagPKIIDInfo
{
const char* szExt;
const PKIID* pIIDEnc;
const PKIID* pIIDDec;
} PKIIDInfo;
static ERR GetIIDInfo(const char* szExt, const PKIIDInfo** ppInfo)
{
ERR err = WMP_errSuccess;
static PKIIDInfo iidInfo[] = {
{".jxr", &IID_PKImageWmpEncode, &IID_PKImageWmpDecode},
{".wdp", &IID_PKImageUnsupported, &IID_PKImageWmpDecode},
{".hdp", &IID_PKImageUnsupported, &IID_PKImageWmpDecode},
};
size_t i = 0;
*ppInfo = NULL;
for (i = 0; i < sizeof2(iidInfo); ++i)
{
if (0 == PKStrnicmp(szExt, iidInfo[i].szExt, strlen(iidInfo[i].szExt)))
{
*ppInfo = &iidInfo[i];
goto Cleanup;
}
}
Call(WMP_errUnsupportedFormat);
Cleanup:
return err;
}
ERR GetImageEncodeIID(const char* szExt, const PKIID** ppIID)
{
ERR err = WMP_errSuccess;
const PKIIDInfo* pInfo = NULL;
Call(GetIIDInfo(szExt, &pInfo));
*ppIID = pInfo->pIIDEnc;
Cleanup:
return err;
}
ERR GetImageDecodeIID(const char* szExt, const PKIID** ppIID)
{
ERR err = WMP_errSuccess;
const PKIIDInfo* pInfo = NULL;
Call(GetIIDInfo(szExt, &pInfo));
*ppIID = pInfo->pIIDDec;
Cleanup:
return err;
}
//================================================================
// PKFactory
//================================================================
ERR PKCreateFactory_CreateStream(PKStream** ppStream)
{
ERR err = WMP_errSuccess;
Call(PKAlloc((void **) ppStream, sizeof(**ppStream)));
Cleanup:
return err;
}
ERR PKCreateFactory_Release(PKFactory** ppFactory)
{
ERR err = WMP_errSuccess;
Call(PKFree((void **) ppFactory));
Cleanup:
return err;
}
//----------------------------------------------------------------
ERR PKCreateFactory(PKFactory** ppFactory, U32 uVersion)
{
ERR err = WMP_errSuccess;
PKFactory* pFactory = NULL;
UNREFERENCED_PARAMETER( uVersion );
Call(PKAlloc((void **) ppFactory, sizeof(**ppFactory)));
pFactory = *ppFactory;
pFactory->CreateStream = PKCreateFactory_CreateStream;
pFactory->CreateStreamFromFilename = CreateWS_File;
pFactory->CreateStreamFromMemory = CreateWS_Memory;
pFactory->Release = PKCreateFactory_Release;
Cleanup:
return err;
}
//================================================================
// PKCodecFactory
//================================================================
ERR PKCodecFactory_CreateCodec(const PKIID* iid, void** ppv)
{
ERR err = WMP_errSuccess;
if (IID_PKImageWmpEncode == *iid)
{
Call(PKImageEncode_Create_WMP((PKImageEncode**)ppv));
}
else if (IID_PKImageWmpDecode == *iid)
{
Call(PKImageDecode_Create_WMP((PKImageDecode**)ppv));
}
else
{
Call(WMP_errUnsupportedFormat);
}
Cleanup:
return err;
}
ERR PKCodecFactory_CreateDecoderFromFile(const char* szFilename, PKImageDecode** ppDecoder)
{
ERR err = WMP_errSuccess;
char *pExt = NULL;
const PKIID* pIID = NULL;
struct WMPStream* pStream = NULL;
PKImageDecode* pDecoder = NULL;
// get file extension
pExt = strrchr(szFilename, '.');
FailIf(NULL == pExt, WMP_errUnsupportedFormat);
// get decode PKIID
Call(GetImageDecodeIID(pExt, &pIID));
// create stream
Call(CreateWS_File(&pStream, szFilename, "rb"));
// Create decoder
Call(PKCodecFactory_CreateCodec(pIID, (void **) ppDecoder));
pDecoder = *ppDecoder;
// attach stream to decoder
Call(pDecoder->Initialize(pDecoder, pStream));
pDecoder->fStreamOwner = !0;
Cleanup:
return err;
}
ERR PKCodecFactory_CreateFormatConverter(PKFormatConverter** ppFConverter)
{
ERR err = WMP_errSuccess;
PKFormatConverter* pFC = NULL;
Call(PKAlloc((void **) ppFConverter, sizeof(**ppFConverter)));
pFC = *ppFConverter;
pFC->Initialize = PKFormatConverter_Initialize;
pFC->InitializeConvert = PKFormatConverter_InitializeConvert;
pFC->GetPixelFormat = PKFormatConverter_GetPixelFormat;
pFC->GetSourcePixelFormat = PKFormatConverter_GetSourcePixelFormat;
pFC->GetSize = PKFormatConverter_GetSize;
pFC->GetResolution = PKFormatConverter_GetResolution;
pFC->Copy = PKFormatConverter_Copy;
pFC->Convert = PKFormatConverter_Convert;
pFC->Release = PKFormatConverter_Release;
Cleanup:
return err;
}
ERR PKCreateCodecFactory_Release(PKCodecFactory** ppCFactory)
{
ERR err = WMP_errSuccess;
Call(PKFree((void **) ppCFactory));
Cleanup:
return err;
}
ERR PKCreateCodecFactory(PKCodecFactory** ppCFactory, U32 uVersion)
{
ERR err = WMP_errSuccess;
PKCodecFactory* pCFactory = NULL;
UNREFERENCED_PARAMETER( uVersion );
Call(PKAlloc((void **) ppCFactory, sizeof(**ppCFactory)));
pCFactory = *ppCFactory;
pCFactory->CreateCodec = PKCodecFactory_CreateCodec;
pCFactory->CreateDecoderFromFile = PKCodecFactory_CreateDecoderFromFile;
pCFactory->CreateFormatConverter = PKCodecFactory_CreateFormatConverter;
pCFactory->Release = PKCreateCodecFactory_Release;
Cleanup:
return err;
}
//================================================================
// PKImageEncode
//================================================================
ERR PKImageEncode_Initialize(
PKImageEncode* pIE,
struct WMPStream* pStream,
void* pvParam,
size_t cbParam)
{
ERR err = WMP_errSuccess;
UNREFERENCED_PARAMETER( pIE );
UNREFERENCED_PARAMETER( pvParam );
UNREFERENCED_PARAMETER( cbParam );
pIE->pStream = pStream;
pIE->guidPixFormat = GUID_PKPixelFormatDontCare;
pIE->fResX = 96;
pIE->fResY = 96;
pIE->cFrame = 1;
Call(pIE->pStream->GetPos(pIE->pStream, &pIE->offStart));
Cleanup:
return err;
}
ERR PKImageEncode_Terminate(
PKImageEncode* pIE)
{
UNREFERENCED_PARAMETER( pIE );
return WMP_errSuccess;
}
ERR PKImageEncode_SetPixelFormat(
PKImageEncode* pIE,
PKPixelFormatGUID enPixelFormat)
{
pIE->guidPixFormat = enPixelFormat;
return WMP_errSuccess;
}
ERR PKImageEncode_SetSize(
PKImageEncode* pIE,
I32 iWidth,
I32 iHeight)
{
ERR err = WMP_errSuccess;
pIE->uWidth = (U32)iWidth;
pIE->uHeight = (U32)iHeight;
return err;
}
ERR PKImageEncode_SetResolution(
PKImageEncode* pIE,
Float fResX,
Float fResY)
{
pIE->fResX = fResX;
pIE->fResY = fResY;
return WMP_errSuccess;
}
ERR PKImageEncode_SetColorContext(PKImageEncode *pIE,
const U8 *pbColorContext,
U32 cbColorContext)
{
UNREFERENCED_PARAMETER( pIE );
UNREFERENCED_PARAMETER( pbColorContext );
UNREFERENCED_PARAMETER( cbColorContext );
return WMP_errNotYetImplemented;
}
ERR PKImageEncode_SetDescriptiveMetadata(PKImageEncode *pIE, const DESCRIPTIVEMETADATA *pDescMetadata)
{
UNREFERENCED_PARAMETER( pIE );
UNREFERENCED_PARAMETER( pDescMetadata );
return WMP_errNotYetImplemented;
}
ERR PKImageEncode_WritePixels(
PKImageEncode* pIE,
U32 cLine,
U8* pbPixels,
U32 cbStride)
{
UNREFERENCED_PARAMETER( pIE );
UNREFERENCED_PARAMETER( cLine );
UNREFERENCED_PARAMETER( pbPixels );
UNREFERENCED_PARAMETER( cbStride );
return WMP_errAbstractMethod;
}
ERR PKImageEncode_WriteSource(
PKImageEncode* pIE,
PKFormatConverter* pFC,
PKRect* pRect)
{
ERR err = WMP_errSuccess;
PKPixelFormatGUID enPFFrom = GUID_PKPixelFormatDontCare;
PKPixelFormatGUID enPFTo = GUID_PKPixelFormatDontCare;
PKPixelInfo pPIFrom;
PKPixelInfo pPITo;
U32 cbStrideTo = 0;
U32 cbStrideFrom = 0;
U32 cbStride = 0;
U8* pb = NULL;
// CWMTranscodingParam* pParam = NULL;
// get pixel format
Call(pFC->GetSourcePixelFormat(pFC, &enPFFrom));
Call(pFC->GetPixelFormat(pFC, &enPFTo));
FailIf(!IsEqualGUID(&pIE->guidPixFormat, &enPFTo), WMP_errUnsupportedFormat);
// calc common stride
// Call(GetPixelInfo(enPFFrom, &pPIFrom));
pPIFrom.pGUIDPixFmt = &enPFFrom;
PixelFormatLookup(&pPIFrom, LOOKUP_FORWARD);
// Call(GetPixelInfo(enPFTo, &pPITo));
pPITo.pGUIDPixFmt = &enPFTo;
PixelFormatLookup(&pPITo, LOOKUP_FORWARD);
// cbStrideFrom = (pPIFrom->cbPixel * pRect->Width + pPIFrom->cbPixelDenom - 1) / pPIFrom->cbPixelDenom;
cbStrideFrom = (BD_1 == pPIFrom.bdBitDepth ? ((pPIFrom.cbitUnit * pRect->Width + 7) >> 3) : (((pPIFrom.cbitUnit + 7) >> 3) * pRect->Width));
if (&GUID_PKPixelFormat12bppYUV420 == pPIFrom.pGUIDPixFmt
|| &GUID_PKPixelFormat16bppYUV422 == pPIFrom.pGUIDPixFmt)
cbStrideFrom >>= 1;
// cbStrideTo = (pPITo->cbPixel * pIE->uWidth + pPITo->cbPixelDenom - 1) / pPITo->cbPixelDenom;
cbStrideTo = (BD_1 == pPITo.bdBitDepth ? ((pPITo.cbitUnit * pIE->uWidth + 7) >> 3) : (((pPITo.cbitUnit + 7) >> 3) * pIE->uWidth));
if (&GUID_PKPixelFormat12bppYUV420 == pPITo.pGUIDPixFmt
|| &GUID_PKPixelFormat16bppYUV422 == pPITo.pGUIDPixFmt)
cbStrideTo >>= 1;
cbStride = max(cbStrideFrom, cbStrideTo);
// actual dec/enc with local buffer
Call(PKAllocAligned((void **) &pb, cbStride * pRect->Height, 128));
Call(pFC->Copy(pFC, pRect, pb, cbStride));
Call(pIE->WritePixels(pIE, pRect->Height, pb, cbStride));
Cleanup:
PKFreeAligned((void **) &pb);
return err;
}
ERR PKImageEncode_WritePixelsBandedBegin(PKImageEncode* pEncoder, struct WMPStream *pPATempFile)
{
UNREFERENCED_PARAMETER( pEncoder );
UNREFERENCED_PARAMETER( pPATempFile );
return WMP_errAbstractMethod;
}
ERR PKImageEncode_WritePixelsBanded(PKImageEncode* pEncoder, U32 cLines, U8* pbPixels, U32 cbStride, Bool fLastCall)
{
UNREFERENCED_PARAMETER( pEncoder );
UNREFERENCED_PARAMETER( cLines );
UNREFERENCED_PARAMETER( pbPixels );
UNREFERENCED_PARAMETER( cbStride );
UNREFERENCED_PARAMETER( fLastCall );
return WMP_errAbstractMethod;
}
ERR PKImageEncode_WritePixelsBandedEnd(PKImageEncode* pEncoder)
{
UNREFERENCED_PARAMETER( pEncoder );
return WMP_errAbstractMethod;
}
ERR PKImageEncode_Transcode(
PKImageEncode* pIE,
PKFormatConverter* pFC,
PKRect* pRect)
{
ERR err = WMP_errSuccess;
PKPixelFormatGUID enPFFrom = GUID_PKPixelFormatDontCare;
PKPixelFormatGUID enPFTo = GUID_PKPixelFormatDontCare;
PKPixelInfo pPIFrom;
PKPixelInfo pPITo;
U32 cbStrideTo = 0;
U32 cbStrideFrom = 0;
U32 cbStride = 0;
U8* pb = NULL;
CWMTranscodingParam cParam = {0};
// get pixel format
Call(pFC->GetSourcePixelFormat(pFC, &enPFFrom));
Call(pFC->GetPixelFormat(pFC, &enPFTo));
FailIf(!IsEqualGUID(&pIE->guidPixFormat, &enPFTo), WMP_errUnsupportedFormat);
// calc common stride
// Call(GetPixelInfo(enPFFrom, &pPIFrom));
pPIFrom.pGUIDPixFmt = &enPFFrom;
PixelFormatLookup(&pPIFrom, LOOKUP_FORWARD);
// Call(GetPixelInfo(enPFTo, &pPITo));
pPITo.pGUIDPixFmt = &enPFTo;
PixelFormatLookup(&pPITo, LOOKUP_FORWARD);
// cbStrideFrom = (pPIFrom->cbPixel * pRect->Width + pPIFrom->cbPixelDenom - 1) / pPIFrom->cbPixelDenom;
cbStrideFrom = (BD_1 == pPIFrom.bdBitDepth ? ((pPIFrom.cbitUnit * pRect->Width + 7) >> 3) : (((pPIFrom.cbitUnit + 7) >> 3) * pRect->Width));
if (&GUID_PKPixelFormat12bppYUV420 == pPIFrom.pGUIDPixFmt
|| &GUID_PKPixelFormat16bppYUV422 == pPIFrom.pGUIDPixFmt)
cbStrideFrom >>= 1;
// cbStrideTo = (pPITo->cbPixel * pIE->uWidth + pPITo->cbPixelDenom - 1) / pPITo->cbPixelDenom;
cbStrideTo = (BD_1 == pPITo.bdBitDepth ? ((pPITo.cbitUnit * pIE->uWidth + 7) >> 3) : (((pPITo.cbitUnit + 7) >> 3) * pIE->uWidth));
if (&GUID_PKPixelFormat12bppYUV420 == pPITo.pGUIDPixFmt
|| &GUID_PKPixelFormat16bppYUV422 == pPITo.pGUIDPixFmt)
cbStrideTo >>= 1;
cbStride = max(cbStrideFrom, cbStrideTo);
if(pIE->bWMP){
cParam.cLeftX = pFC->pDecoder->WMP.wmiI.cROILeftX;
cParam.cTopY = pFC->pDecoder->WMP.wmiI.cROITopY;
cParam.cWidth = pFC->pDecoder->WMP.wmiI.cROIWidth;
cParam.cHeight = pFC->pDecoder->WMP.wmiI.cROIHeight;
cParam.oOrientation = pFC->pDecoder->WMP.wmiI.oOrientation;
// cParam.cfColorFormat = pFC->pDecoder->WMP.wmiI.cfColorFormat;
cParam.uAlphaMode = pFC->pDecoder->WMP.wmiSCP.uAlphaMode;
cParam.bfBitstreamFormat = pFC->pDecoder->WMP.wmiSCP.bfBitstreamFormat;
cParam.sbSubband = pFC->pDecoder->WMP.wmiSCP.sbSubband;
cParam.bIgnoreOverlap = pFC->pDecoder->WMP.bIgnoreOverlap;
Call(pIE->Transcode(pIE, pFC->pDecoder, &cParam));
}
else
{
// actual dec/enc with local buffer
Call(PKAllocAligned((void **) &pb, cbStride * pRect->Height, 128));
Call(pFC->Copy(pFC, pRect, pb, cbStride));
Call(pIE->WritePixels(pIE, pRect->Height, pb, cbStride));
}
Cleanup:
PKFreeAligned((void **) &pb);
return err;
}
ERR PKImageEncode_CreateNewFrame(
PKImageEncode* pIE,
void* pvParam,
size_t cbParam)
{
UNREFERENCED_PARAMETER( pIE );
UNREFERENCED_PARAMETER( pvParam );
UNREFERENCED_PARAMETER( cbParam );
// NYI
return WMP_errSuccess;
}
ERR PKImageEncode_Release(
PKImageEncode** ppIE)
{
PKImageEncode *pIE = *ppIE;
pIE->pStream->Close(&pIE->pStream);
return PKFree((void **) ppIE);
}
ERR PKImageEncode_Create(PKImageEncode** ppIE)
{
ERR err = WMP_errSuccess;
PKImageEncode* pIE = NULL;
Call(PKAlloc((void **) ppIE, sizeof(**ppIE)));
pIE = *ppIE;
pIE->Initialize = PKImageEncode_Initialize;
pIE->Terminate = PKImageEncode_Terminate;
pIE->SetPixelFormat = PKImageEncode_SetPixelFormat;
pIE->SetSize = PKImageEncode_SetSize;
pIE->SetResolution = PKImageEncode_SetResolution;
pIE->SetColorContext = PKImageEncode_SetColorContext;
pIE->SetDescriptiveMetadata = PKImageEncode_SetDescriptiveMetadata;
pIE->WritePixels = PKImageEncode_WritePixels;
// pIE->WriteSource = PKImageEncode_WriteSource;
pIE->WritePixelsBandedBegin = PKImageEncode_WritePixelsBandedBegin;
pIE->WritePixelsBanded = PKImageEncode_WritePixelsBanded;
pIE->WritePixelsBandedEnd = PKImageEncode_WritePixelsBandedEnd;
pIE->CreateNewFrame = PKImageEncode_CreateNewFrame;
pIE->Release = PKImageEncode_Release;
pIE->bWMP = FALSE;
Cleanup:
return err;
}
//================================================================
// PKImageDecode
//================================================================
ERR PKImageDecode_Initialize(
PKImageDecode* pID,
struct WMPStream* pStream)
{
ERR err = WMP_errSuccess;
pID->pStream = pStream;
pID->guidPixFormat = GUID_PKPixelFormatDontCare;
pID->fResX = 96;
pID->fResY = 96;
pID->cFrame = 1;
Call(pID->pStream->GetPos(pID->pStream, &pID->offStart));
memset(&pID->WMP.wmiDEMisc, 0, sizeof(pID->WMP.wmiDEMisc));
Cleanup:
return WMP_errSuccess;
}
ERR PKImageDecode_GetPixelFormat(
PKImageDecode* pID,
PKPixelFormatGUID* pPF)
{
*pPF = pID->guidPixFormat;
return WMP_errSuccess;
}
ERR PKImageDecode_GetSize(
PKImageDecode* pID,
I32* piWidth,
I32* piHeight)
{
*piWidth = (I32)pID->uWidth;
*piHeight = (I32)pID->uHeight;
return WMP_errSuccess;
}
ERR PKImageDecode_GetResolution(
PKImageDecode* pID,
Float* pfResX,
Float* pfResY)
{
*pfResX = pID->fResX;
*pfResY = pID->fResY;
return WMP_errSuccess;
}
ERR PKImageDecode_GetColorContext(PKImageDecode *pID, U8 *pbColorContext, U32 *pcbColorContext)
{
UNREFERENCED_PARAMETER( pID );
UNREFERENCED_PARAMETER( pbColorContext );
UNREFERENCED_PARAMETER( pcbColorContext );
return WMP_errNotYetImplemented;
}
ERR PKImageDecode_GetDescriptiveMetadata(PKImageDecode *pIE, DESCRIPTIVEMETADATA *pDescMetadata)
{
UNREFERENCED_PARAMETER( pIE );
UNREFERENCED_PARAMETER( pDescMetadata );
return WMP_errNotYetImplemented;
}
ERR PKImageDecode_Copy(
PKImageDecode* pID,
const PKRect* pRect,
U8* pb,
U32 cbStride)
{
UNREFERENCED_PARAMETER( pID );
UNREFERENCED_PARAMETER( pRect );
UNREFERENCED_PARAMETER( pb );
UNREFERENCED_PARAMETER( cbStride );
return WMP_errAbstractMethod;
}
ERR PKImageDecode_GetFrameCount(
PKImageDecode* pID,
U32* puCount)
{
*puCount = pID->cFrame;
return WMP_errSuccess;
}
ERR PKImageDecode_SelectFrame(
PKImageDecode* pID,
U32 uFrame)
{
UNREFERENCED_PARAMETER( pID );
UNREFERENCED_PARAMETER( uFrame );
// NYI
return WMP_errSuccess;
}
ERR PKImageDecode_Release(
PKImageDecode** ppID)
{
PKImageDecode* pID = *ppID;
pID->fStreamOwner && pID->pStream->Close(&pID->pStream);
return PKFree((void **) ppID);
}
ERR PKImageDecode_Create(
PKImageDecode** ppID)
{
ERR err = WMP_errSuccess;
PKImageDecode* pID = NULL;
Call(PKAlloc((void **) ppID, sizeof(**ppID)));
pID = *ppID;
pID->Initialize = PKImageDecode_Initialize;
pID->GetPixelFormat = PKImageDecode_GetPixelFormat;
pID->GetSize = PKImageDecode_GetSize;
pID->GetResolution = PKImageDecode_GetResolution;
pID->GetColorContext = PKImageDecode_GetColorContext;
pID->GetDescriptiveMetadata = PKImageDecode_GetDescriptiveMetadata;
pID->Copy = PKImageDecode_Copy;
pID->GetFrameCount = PKImageDecode_GetFrameCount;
pID->SelectFrame = PKImageDecode_SelectFrame;
pID->Release = PKImageDecode_Release;
Cleanup:
return err;
}

View File

@ -1,641 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "JXRMeta.h"
#include "../include/guiddef.h"
//================================================================
#define WMP_SDK_VERSION 0x0101
#define PK_SDK_VERSION 0x0101
#define sizeof2(array) (sizeof(array)/sizeof(*(array)))
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef min
#define min(b,a) ((a) < (b) ? (a) : (b))
#endif
#ifdef __ANSI__
#define STRCPY_SAFE(pszDest, cbDest, pszSrc) (strncpy((pszDest), (pszSrc), (cbDest)) == (pszDest) ? 0 : 1)
#else
#define STRCPY_SAFE(pszDest, cbDest, pszSrc) (strcpy_s((pszDest), (cbDest), (pszSrc)))
#endif // __ANSI__
//================================================================
typedef struct tagPKRect
{
I32 X;
I32 Y;
I32 Width;
I32 Height;
} PKRect;
//================================================================
typedef U32 PKIID;
EXTERN_C const PKIID IID_PKImageScanEncode;
EXTERN_C const PKIID IID_PKImageFrameEncode;
EXTERN_C const PKIID IID_PKImageWmpEncode;
EXTERN_C const PKIID IID_PKImageWmpDecode;
struct IFDEntry
{
U16 uTag;
U16 uType;
U32 uCount;
U32 uValue;
};
EXTERN_C const U32 IFDEntryTypeSizes[13];
EXTERN_C const U32 SizeofIFDEntry;
//================================================================
typedef float Float;
typedef enum tagPKStreamFlags
{
PKStreamOpenRead = 0x00000000UL,
PKStreamOpenWrite = 0x00000001UL,
PKStreamOpenReadWrite = 0x00000002UL,
PKStreamNoLock = 0x00010000UL,
PKStreamNoSeek = 0x00020000UL,
PKStreamCompress = 0x00040000UL,
} PKStreamFlags;
/* Undefined formats */
#define GUID_PKPixelFormatUndefined GUID_PKPixelFormatDontCare
DEFINE_GUID(GUID_PKPixelFormatDontCare, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x00);
/* Indexed formats */
//DEFINE_GUID(GUID_PKPixelFormat1bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x01);
//DEFINE_GUID(GUID_PKPixelFormat2bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x02);
//DEFINE_GUID(GUID_PKPixelFormat4bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x03);
//DEFINE_GUID(GUID_PKPixelFormat8bppIndexed, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x04);
DEFINE_GUID(GUID_PKPixelFormatBlackWhite, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x05);
//DEFINE_GUID(GUID_PKPixelFormat2bppGray, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x06);
//DEFINE_GUID(GUID_PKPixelFormat4bppGray, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x07);
DEFINE_GUID(GUID_PKPixelFormat8bppGray, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x08);
/* sRGB formats (gamma is approx. 2.2) */
/* For a full definition, see the sRGB spec */
/* 16bpp formats */
DEFINE_GUID(GUID_PKPixelFormat16bppRGB555, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x09);
DEFINE_GUID(GUID_PKPixelFormat16bppRGB565, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0a);
DEFINE_GUID(GUID_PKPixelFormat16bppGray, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0b);
/* 24bpp formats */
DEFINE_GUID(GUID_PKPixelFormat24bppBGR, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0c);
DEFINE_GUID(GUID_PKPixelFormat24bppRGB, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0d);
/* 32bpp format */
DEFINE_GUID(GUID_PKPixelFormat32bppBGR, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0e);
DEFINE_GUID(GUID_PKPixelFormat32bppBGRA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0f);
DEFINE_GUID(GUID_PKPixelFormat32bppPBGRA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x10);
DEFINE_GUID(GUID_PKPixelFormat32bppGrayFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x11);
DEFINE_GUID(GUID_PKPixelFormat32bppRGB, 0xd98c6b95, 0x3efe, 0x47d6, 0xbb, 0x25, 0xeb, 0x17, 0x48, 0xab, 0x0c, 0xf1);
DEFINE_GUID(GUID_PKPixelFormat32bppRGBA, 0xf5c7ad2d, 0x6a8d, 0x43dd, 0xa7, 0xa8, 0xa2, 0x99, 0x35, 0x26, 0x1a, 0xe9);
DEFINE_GUID(GUID_PKPixelFormat32bppPRGBA, 0x3cc4a650, 0xa527, 0x4d37, 0xa9, 0x16, 0x31, 0x42, 0xc7, 0xeb, 0xed, 0xba);
/* 48bpp format */
DEFINE_GUID(GUID_PKPixelFormat48bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x12);
/* scRGB formats. Gamma is 1.0 */
/* For a full definition, see the scRGB spec */
/* 16bpp format */
DEFINE_GUID(GUID_PKPixelFormat16bppGrayFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x13);
/* 32bpp format */
DEFINE_GUID(GUID_PKPixelFormat32bppRGB101010, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x14);
/* 48bpp format */
DEFINE_GUID(GUID_PKPixelFormat48bppRGB, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x15);
/* 64bpp format */
DEFINE_GUID(GUID_PKPixelFormat64bppRGBA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x16);
DEFINE_GUID(GUID_PKPixelFormat64bppPRGBA, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x17);
/* 96bpp format */
DEFINE_GUID(GUID_PKPixelFormat96bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x18);
DEFINE_GUID(GUID_PKPixelFormat96bppRGBFloat, 0xe3fed78f, 0xe8db, 0x4acf, 0x84, 0xc1, 0xe9, 0x7f, 0x61, 0x36, 0xb3, 0x27);
/* Floating point scRGB formats */
DEFINE_GUID(GUID_PKPixelFormat128bppRGBAFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x19);
DEFINE_GUID(GUID_PKPixelFormat128bppPRGBAFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1a);
DEFINE_GUID(GUID_PKPixelFormat128bppRGBFloat, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1b);
/* CMYK formats. */
DEFINE_GUID(GUID_PKPixelFormat32bppCMYK, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1c);
/* Photon formats */
DEFINE_GUID(GUID_PKPixelFormat64bppRGBAFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1d);
DEFINE_GUID(GUID_PKPixelFormat64bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x40);
DEFINE_GUID(GUID_PKPixelFormat128bppRGBAFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1e);
DEFINE_GUID(GUID_PKPixelFormat128bppRGBFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x41);
DEFINE_GUID(GUID_PKPixelFormat64bppRGBAHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3a);
DEFINE_GUID(GUID_PKPixelFormat64bppRGBHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x42);
DEFINE_GUID(GUID_PKPixelFormat48bppRGBHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3b);
DEFINE_GUID(GUID_PKPixelFormat32bppRGBE, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3d);
DEFINE_GUID(GUID_PKPixelFormat16bppGrayHalf, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3e);
DEFINE_GUID(GUID_PKPixelFormat32bppGrayFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x3f);
/* More CMYK formats and n-Channel formats */
DEFINE_GUID(GUID_PKPixelFormat64bppCMYK, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x1f);
DEFINE_GUID(GUID_PKPixelFormat24bpp3Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x20);
DEFINE_GUID(GUID_PKPixelFormat32bpp4Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x21);
DEFINE_GUID(GUID_PKPixelFormat40bpp5Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x22);
DEFINE_GUID(GUID_PKPixelFormat48bpp6Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x23);
DEFINE_GUID(GUID_PKPixelFormat56bpp7Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x24);
DEFINE_GUID(GUID_PKPixelFormat64bpp8Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x25);
DEFINE_GUID(GUID_PKPixelFormat48bpp3Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x26);
DEFINE_GUID(GUID_PKPixelFormat64bpp4Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x27);
DEFINE_GUID(GUID_PKPixelFormat80bpp5Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x28);
DEFINE_GUID(GUID_PKPixelFormat96bpp6Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x29);
DEFINE_GUID(GUID_PKPixelFormat112bpp7Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2a);
DEFINE_GUID(GUID_PKPixelFormat128bpp8Channels, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2b);
DEFINE_GUID(GUID_PKPixelFormat40bppCMYKAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2c);
DEFINE_GUID(GUID_PKPixelFormat80bppCMYKAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2d);
DEFINE_GUID(GUID_PKPixelFormat32bpp3ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2e);
DEFINE_GUID(GUID_PKPixelFormat40bpp4ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x2f);
DEFINE_GUID(GUID_PKPixelFormat48bpp5ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x30);
DEFINE_GUID(GUID_PKPixelFormat56bpp6ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x31);
DEFINE_GUID(GUID_PKPixelFormat64bpp7ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x32);
DEFINE_GUID(GUID_PKPixelFormat72bpp8ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x33);
DEFINE_GUID(GUID_PKPixelFormat64bpp3ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x34);
DEFINE_GUID(GUID_PKPixelFormat80bpp4ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x35);
DEFINE_GUID(GUID_PKPixelFormat96bpp5ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x36);
DEFINE_GUID(GUID_PKPixelFormat112bpp6ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x37);
DEFINE_GUID(GUID_PKPixelFormat128bpp7ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x38);
DEFINE_GUID(GUID_PKPixelFormat144bpp8ChannelsAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x39);
/* YCrCb from Advanced Profile */
DEFINE_GUID(GUID_PKPixelFormat12bppYCC420, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x44);
DEFINE_GUID(GUID_PKPixelFormat16bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x45);
DEFINE_GUID(GUID_PKPixelFormat20bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x46);
DEFINE_GUID(GUID_PKPixelFormat32bppYCC422, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x47);
DEFINE_GUID(GUID_PKPixelFormat24bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x48);
DEFINE_GUID(GUID_PKPixelFormat30bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x49);
DEFINE_GUID(GUID_PKPixelFormat48bppYCC444, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4a);
DEFINE_GUID(GUID_PKPixelFormat16bpp48bppYCC444FixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4b);
DEFINE_GUID(GUID_PKPixelFormat20bppYCC420Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4c);
DEFINE_GUID(GUID_PKPixelFormat24bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4d);
DEFINE_GUID(GUID_PKPixelFormat30bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4e);
DEFINE_GUID(GUID_PKPixelFormat48bppYCC422Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x4f);
DEFINE_GUID(GUID_PKPixelFormat32bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x50);
DEFINE_GUID(GUID_PKPixelFormat40bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x51);
DEFINE_GUID(GUID_PKPixelFormat64bppYCC444Alpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x52);
DEFINE_GUID(GUID_PKPixelFormat64bppYCC444AlphaFixedPoint, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x53);
//YUV
#define GUID_PKPixelFormat12bppYUV420 GUID_PKPixelFormat12bppYCC420
#define GUID_PKPixelFormat16bppYUV422 GUID_PKPixelFormat16bppYCC422
#define GUID_PKPixelFormat24bppYUV444 GUID_PKPixelFormat24bppYCC444
/* CMYKDIRECT from Advanced Profile */
DEFINE_GUID(GUID_PKPixelFormat32bppCMYKDIRECT, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x54);
DEFINE_GUID(GUID_PKPixelFormat64bppCMYKDIRECT, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x55);
DEFINE_GUID(GUID_PKPixelFormat40bppCMYKDIRECTAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x56);
DEFINE_GUID(GUID_PKPixelFormat80bppCMYKDIRECTAlpha, 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x43);
// PhotometricInterpretation
#define PK_PI_W0 0 // WhiteIsZero
#define PK_PI_B0 1 // BlackIsZero
#define PK_PI_RGB 2
#define PK_PI_RGBPalette 3
#define PK_PI_TransparencyMask 4
#define PK_PI_CMYK 5
#define PK_PI_YCbCr 6
#define PK_PI_CIELab 8
#define PK_PI_NCH 100
#define PK_PI_RGBE 101
#define PK_pixfmtNul 0x00000000
#define PK_pixfmtHasAlpha 0x00000010
#define PK_pixfmtPreMul 0x00000020
#define PK_pixfmtBGR 0x00000040
#define PK_pixfmtNeedConvert 0x80000000
#define LOOKUP_FORWARD 0
#define LOOKUP_BACKWARD_TIF 1
typedef unsigned long WMP_GRBIT;
typedef GUID PKPixelFormatGUID;
typedef struct tagPKPixelInfo
{
const PKPixelFormatGUID* pGUIDPixFmt;
size_t cChannel;
COLORFORMAT cfColorFormat;
BITDEPTH_BITS bdBitDepth;
U32 cbitUnit;
WMP_GRBIT grBit;
// TIFF
U32 uInterpretation;
U32 uSamplePerPixel;
U32 uBitsPerSample;
U32 uSampleFormat;
} PKPixelInfo;
//================================================================
ERR PKAlloc(void** ppv, size_t cb);
ERR PKFree(void** ppv);
//----------------------------------------------------------------
//ERR GetPixelInfo(PKPixelFormatGUID enPixelFormat, const PKPixelInfo** ppPI);
ERR PixelFormatLookup(PKPixelInfo* pPI, U8 uLookupType);
const PKPixelFormatGUID* GetPixelFormatFromHash(const U8 uPFHash);
ERR GetImageEncodeIID(const char* szExt, const PKIID** ppIID);
ERR GetImageDecodeIID(const char* szExt, const PKIID** ppIID);
//================================================================
#ifdef __ANSI__
struct tagPKFactory;
struct tagPKCodecFactory;
struct tagPKImageDecode;
struct tagPKImageEncode;
struct tagPKFormatConverter;
#define PKFactory struct tagPKFactory
#define PKCodecFactory struct tagPKCodecFactory
#define PKImageDecode struct tagPKImageDecode
#define PKImageEncode struct tagPKImageEncode
#define PKFormatConverter struct tagPKFormatConverter
#else // __ANSI__
typedef struct tagPKFactory PKFactory;
typedef struct tagPKCodecFactory PKCodecFactory;
typedef struct tagPKImageDecode PKImageDecode;
typedef struct tagPKImageEncode PKImageEncode;
typedef struct tagPKFormatConverter PKFormatConverter;
#endif // __ANSI__
//================================================================
typedef struct tagPKStream
{
ERR (*InitializeFromFilename)(const char*, ULong);
ERR (*Release)(void);
FILE* fp;
} PKStream;
//================================================================
typedef struct tagPKFactory
{
ERR (*CreateStream)(PKStream**);
ERR (*CreateStreamFromFilename)(struct WMPStream**, const char*, const char*);
ERR (*CreateStreamFromMemory)(struct WMPStream**, void*, size_t);
ERR (*Release)(PKFactory**);
#ifdef __ANSI__
#undef PKFactory
#endif // __ANSI__
} PKFactory;
//----------------------------------------------------------------
ERR PKCreateFactory_CreateStream(PKStream** ppStream);
ERR PKCreateFactory_Release(PKFactory** ppFactory);
EXTERN_C ERR PKCreateFactory(PKFactory**, U32);
//================================================================
typedef struct tagPKCodecFactory
{
ERR (*CreateCodec)(const PKIID*, void**);
ERR (*CreateDecoderFromFile)(const char*, PKImageDecode**);
ERR (*CreateFormatConverter)(PKFormatConverter**);
ERR (*Release)(PKCodecFactory**);
#ifdef __ANSI__
#undef PKCodecFactory
#endif // __ANSI__
} PKCodecFactory;
//----------------------------------------------------------------
ERR PKCodecFactory_CreateCodec(const PKIID* iid, void** ppv);
ERR PKCreateCodecFactory_Release(PKCodecFactory** ppCFactory);
EXTERN_C ERR PKCreateCodecFactory(PKCodecFactory**, U32);
//================================================================
typedef enum BANDEDENCSTATE
{
BANDEDENCSTATE_UNINITIALIZED = 0,
BANDEDENCSTATE_INIT,
BANDEDENCSTATE_ENCODING,
BANDEDENCSTATE_TERMINATED,
BANDEDENCSTATE_NONBANDEDENCODE,
} BANDEDENCSTATE;
typedef struct tagPKImageEncode
{
//ERR (*GetPixelFormat)(MILPixelFormat*));
ERR (*Initialize)(PKImageEncode*, struct WMPStream*, void*, size_t);
ERR (*Terminate)(PKImageEncode*);
ERR (*SetPixelFormat)(PKImageEncode*, PKPixelFormatGUID);
ERR (*SetSize)(PKImageEncode*, I32, I32);
ERR (*SetResolution)(PKImageEncode*, Float, Float);
ERR (*SetColorContext)(PKImageEncode *pIE, const U8 *pbColorContext,
U32 cbColorContext);
ERR (*SetDescriptiveMetadata)(PKImageEncode *pIE,
const DESCRIPTIVEMETADATA *pDescMetadata);
ERR (*WritePixels)(PKImageEncode*, U32, U8*, U32);
ERR (*WriteSource)(PKImageEncode*, PKFormatConverter*, PKRect*);
// Banded encode API - currently only implemented for WMP encoder
ERR (*WritePixelsBandedBegin)(PKImageEncode* pEncoder, struct WMPStream *pPlanarAlphaTempFile);
ERR (*WritePixelsBanded)(PKImageEncode* pEncoder, U32 cLines, U8* pbPixels, U32 cbStride, Bool fLastCall);
ERR (*WritePixelsBandedEnd)(PKImageEncode* pEncoder);
#define TEMPFILE_COPYBUF_SIZE 8192 // Means when using tempfile for planar alpha banded encode, copy this many bytes at a time
ERR (*Transcode)(PKImageEncode*, PKImageDecode*, CWMTranscodingParam*);
ERR (*CreateNewFrame)(PKImageEncode*, void*, size_t);
ERR (*Release)(PKImageEncode**);
struct WMPStream* pStream;
size_t offStart;
PKPixelFormatGUID guidPixFormat;
U32 uWidth;
U32 uHeight;
U32 idxCurrentLine;
Float fResX;
Float fResY;
U32 cFrame;
Bool fHeaderDone;
size_t offPixel;
size_t cbPixel;
U8 *pbColorContext;
U32 cbColorContext;
U8 *pbEXIFMetadata;
U32 cbEXIFMetadataByteCount;
U8 *pbGPSInfoMetadata;
U32 cbGPSInfoMetadataByteCount;
U8 *pbIPTCNAAMetadata;
U32 cbIPTCNAAMetadataByteCount;
U8 *pbXMPMetadata;
U32 cbXMPMetadataByteCount;
U8 *pbPhotoshopMetadata;
U32 cbPhotoshopMetadataByteCount;
DESCRIPTIVEMETADATA sDescMetadata;
Bool bWMP;//for the encoder in decoding
struct
{
WmpDEMisc wmiDEMisc;
CWMImageInfo wmiI;
CWMIStrCodecParam wmiSCP;
CTXSTRCODEC ctxSC;
CWMImageInfo wmiI_Alpha;
CWMIStrCodecParam wmiSCP_Alpha;
CTXSTRCODEC ctxSC_Alpha;
Bool bHasAlpha;
Long nOffImage;
Long nCbImage;
Long nOffAlpha;
Long nCbAlpha;
ORIENTATION oOrientation;
// Banded encode state variables
BANDEDENCSTATE eBandedEncState;
struct WMPStream *pPATempFile;
} WMP;
#ifdef __ANSI__
#undef PKImageEncode
#endif // __ANSI__
} PKImageEncode;
//----------------------------------------------------------------
ERR PKImageEncode_Create_WMP(PKImageEncode** ppIE);
ERR PKImageEncode_Initialize(PKImageEncode* pIE, struct WMPStream* pStream, void* pvParam, size_t cbParam);
ERR PKImageEncode_Terminate(PKImageEncode* pIE);
ERR PKImageEncode_SetPixelFormat(PKImageEncode* pIE, PKPixelFormatGUID enPixelFormat);
ERR PKImageEncode_SetSize(PKImageEncode* pIE, I32 iWidth, I32 iHeight);
ERR PKImageEncode_SetResolution(PKImageEncode* pIE, Float rX, Float rY);
ERR PKImageEncode_SetColorContext(PKImageEncode *pIE, const U8 *pbColorContext, U32 cbColorContext);
ERR PKImageEncode_SetDescriptiveMetadata(PKImageEncode *pIE, const DESCRIPTIVEMETADATA *pDescMetadata);
ERR PKImageEncode_WritePixels(PKImageEncode* pIE, U32 cLine, U8* pbPixel, U32 cbStride);
ERR PKImageEncode_CreateNewFrame(PKImageEncode* pIE, void* pvParam, size_t cbParam);
ERR PKImageEncode_Release(PKImageEncode** ppIE);
ERR PKImageEncode_SetXMPMetadata_WMP(PKImageEncode *pIE, const U8 *pbXMPMetadata, U32 cbXMPMetadata);
ERR PKImageEncode_SetEXIFMetadata_WMP(PKImageEncode *pIE, const U8 *pbEXIFMetadata, U32 cbEXIFMetadata);
ERR PKImageEncode_SetGPSInfoMetadata_WMP(PKImageEncode *pIE, const U8 *pbGPSInfoMetadata, U32 cbGPSInfoMetadata);
ERR PKImageEncode_SetIPTCNAAMetadata_WMP(PKImageEncode *pIE, const U8 *pbIPTCNAAMetadata, U32 cbIPTCNAAMetadata);
ERR PKImageEncode_SetPhotoshopMetadata_WMP(PKImageEncode *pIE, const U8 *pbPhotoshopMetadata, U32 cbPhotoshopMetadata);
void FreeDescMetadata(DPKPROPVARIANT *pvar);
ERR PKImageEncode_Create(PKImageEncode** ppIE);
//================================================================
typedef struct tagPKImageDecode
{
ERR (*Initialize)(PKImageDecode*, struct WMPStream* pStream);
ERR (*GetPixelFormat)(PKImageDecode*, PKPixelFormatGUID*);
ERR (*GetSize)(PKImageDecode*, I32*, I32*);
ERR (*GetResolution)(PKImageDecode*, Float*, Float*);
ERR (*GetColorContext)(PKImageDecode *pID, U8 *pbColorContext,
U32 *pcbColorContext);
ERR (*GetDescriptiveMetadata)(PKImageDecode *pIE,
DESCRIPTIVEMETADATA *pDescMetadata);
ERR (*GetRawStream)(PKImageDecode*, struct WMPStream**);
ERR (*Copy)(PKImageDecode*, const PKRect*, U8*, U32);
ERR (*GetFrameCount)(PKImageDecode*, U32*);
ERR (*SelectFrame)(PKImageDecode*, U32);
ERR (*Release)(PKImageDecode**);
struct WMPStream* pStream;
Bool fStreamOwner;
size_t offStart;
PKPixelFormatGUID guidPixFormat;
U32 uWidth;
U32 uHeight;
U32 idxCurrentLine;
Float fResX;
Float fResY;
U32 cFrame;
struct
{
WmpDEMisc wmiDEMisc;
CWMImageInfo wmiI;
CWMIStrCodecParam wmiSCP;
CTXSTRCODEC ctxSC;
CWMImageInfo wmiI_Alpha;
CWMIStrCodecParam wmiSCP_Alpha;
CTXSTRCODEC ctxSC_Alpha;
Bool bHasAlpha;
Long nOffImage;
Long nCbImage;
Long nOffAlpha;
Long nCbAlpha;
Bool bIgnoreOverlap;
size_t DecoderCurrMBRow;
size_t DecoderCurrAlphaMBRow;
size_t cMarker;
size_t cLinesDecoded;
size_t cLinesCropped; // Lines may be cropped from the top - buffer for subsequent decodes must be adjusted
Bool fFirstNonZeroDecode;
Bool fOrientationFromContainer;
ORIENTATION oOrientationFromContainer; // Tag 0xBC02 in HD Photo container
DESCRIPTIVEMETADATA sDescMetadata;
} WMP;
#ifdef __ANSI__
#undef PKImageDecode
#endif // __ANSI__
} PKImageDecode;
//----------------------------------------------------------------
ERR PKImageDecode_Create_WMP(PKImageDecode** ppID);
ERR PKImageDecode_Initialize(PKImageDecode* pID, struct WMPStream* pStream);
ERR PKImageDecode_GetPixelFormat(PKImageDecode* pID, PKPixelFormatGUID* pPF);
ERR PKImageDecode_GetSize(PKImageDecode* pID, I32* piWidth, I32* piHeight);
ERR PKImageDecode_GetResolution(PKImageDecode* pID, Float* pfrX, Float* pfrY);
ERR PKImageDecode_GetColorContext(PKImageDecode *pID, U8 *pbColorContext, U32 *pcbColorContext);
ERR PKImageDecode_GetDescriptiveMetadata(PKImageDecode *pID, DESCRIPTIVEMETADATA *pDescMetadata);
ERR PKImageDecode_Copy(PKImageDecode* pID, const PKRect* pRect, U8* pb, U32 cbStride);
ERR PKImageDecode_GetFrameCount(PKImageDecode* pID, U32* puCount);
ERR PKImageDecode_SelectFrame(PKImageDecode* pID, U32 uFrame);
ERR PKImageDecode_Release(PKImageDecode** ppID);
ERR PKImageDecode_GetXMPMetadata_WMP(PKImageDecode *pID, U8 *pbXMPMetadata, U32 *pcbXMPMetadata);
ERR PKImageDecode_GetEXIFMetadata_WMP(PKImageDecode *pID, U8 *pbEXIFMetadata, U32 *pcbEXIFMetadata);
ERR PKImageDecode_GetGPSInfoMetadata_WMP(PKImageDecode *pID, U8 *pbGPSInfoMetadata, U32 *pcbGPSInfoMetadata);
ERR PKImageDecode_GetIPTCNAAMetadata_WMP(PKImageDecode *pID, U8 *pbIPTCNAAMetadata, U32 *pcbIPTCNAAMetadata);
ERR PKImageDecode_GetPhotoshopMetadata_WMP(PKImageDecode *pID, U8 *pbPhotoshopMetadata, U32 *pcbPhotoshopMetadata);
ERR PKImageDecode_Create(PKImageDecode** ppID);
ERR PKCodecFactory_CreateDecoderFromFile(const char* szFilename, PKImageDecode** ppDecoder);
//================================================================
typedef struct tagPKFormatConverter
{
ERR (*Initialize)(PKFormatConverter*, PKImageDecode*, char *pExt, PKPixelFormatGUID);
ERR (*InitializeConvert)(PKFormatConverter* pFC, const PKPixelFormatGUID enPFFrom,
char *pExt, PKPixelFormatGUID enPFTTo);
ERR (*GetPixelFormat)(PKFormatConverter*, PKPixelFormatGUID*);
ERR (*GetSourcePixelFormat)(PKFormatConverter*, PKPixelFormatGUID*);
ERR (*GetSize)(PKFormatConverter*, I32*, I32*);
ERR (*GetResolution)(PKFormatConverter*, Float*, Float*);
ERR (*Copy)(PKFormatConverter*, const PKRect*, U8*, U32);
ERR (*Convert)(PKFormatConverter*, const PKRect*, U8*, U32);
ERR (*Release)(PKFormatConverter**);
PKImageDecode* pDecoder;
PKPixelFormatGUID enPixelFormat;
#ifdef __ANSI__
#undef PKFormatConverter
#endif // __ANSI__
} PKFormatConverter;
//----------------------------------------------------------------
ERR PKImageEncode_Transcode(PKImageEncode* pIE, PKFormatConverter* pFC, PKRect* pRect);
ERR PKImageEncode_WriteSource(PKImageEncode* pIE, PKFormatConverter* pFC, PKRect* pRect);
ERR PKFormatConverter_Initialize(PKFormatConverter* pFC, PKImageDecode* pID, char *pExt, PKPixelFormatGUID enPF);
ERR PKFormatConverter_InitializeConvert(PKFormatConverter* pFC, const PKPixelFormatGUID enPFFrom,
char *pExt, PKPixelFormatGUID enPFTo);
ERR PKFormatConverter_GetPixelFormat(PKFormatConverter* pFC, PKPixelFormatGUID* pPF);
ERR PKFormatConverter_GetSourcePixelFormat(PKFormatConverter* pFC, PKPixelFormatGUID* pPF);
ERR PKFormatConverter_GetSize(PKFormatConverter* pFC, I32* piWidth, I32* piHeight);
ERR PKFormatConverter_GetResolution(PKFormatConverter* pFC, Float* pfrX, Float* pfrY);
ERR PKFormatConverter_Copy(PKFormatConverter* pFC, const PKRect* pRect, U8* pb, U32 cbStride);
ERR PKFormatConverter_Convert(PKFormatConverter* pFC, const PKRect* pRect, U8* pb, U32 cbStride);
ERR PKFormatConverter_Release(PKFormatConverter** ppFC);
// Think of this as static member of PKFormatConverter "class"
ERR PKFormatConverter_EnumConversions(const PKPixelFormatGUID *pguidSourcePF,
const U32 iIndex,
const PKPixelFormatGUID **ppguidTargetPF);
ERR PKCodecFactory_CreateFormatConverter(PKFormatConverter** ppFConverter);
//----------------------------------------------------------------
ERR PKAlloc(void** ppv, size_t cb);
ERR PKFree(void** ppv);
ERR PKAllocAligned(void** ppv, size_t cb, size_t iAlign);
ERR PKFreeAligned(void** ppv);
#ifdef __cplusplus
} // extern "C"
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,904 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#include "JXRMeta.h"
#include "JXRGlue.h"
// read and write big and little endian words/dwords from a buffer on both big and little endian cpu's
// with full buffer overflow checking
ERR getbfcpy(U8* pbdest, const U8* pb, size_t cb, size_t ofs, U32 n)
{
ERR err = WMP_errSuccess;
FailIf(ofs + n > cb, WMP_errBufferOverflow);
memcpy(pbdest, &pb[ofs], n);
Cleanup:
return err;
}
ERR getbfw(const U8* pb, size_t cb, size_t ofs, U16* pw)
{
ERR err = WMP_errSuccess;
FailIf(ofs + sizeof(U16) > cb, WMP_errBufferOverflow);
*pw = (U16)( pb[ofs] + ( pb[ofs + 1] << 8 ) );
Cleanup:
return err;
}
ERR getbfdw(const U8* pb, size_t cb, size_t ofs, U32* pdw)
{
ERR err = WMP_errSuccess;
FailIf(ofs + sizeof(U32) > cb, WMP_errBufferOverflow);
*pdw = pb[ofs] + ( pb[ofs + 1] << 8 ) + ( pb[ofs + 2] << 16UL ) + ( pb[ofs + 3] << 24UL );
Cleanup:
return err;
}
ERR getbfwbig(const U8* pb, size_t cb, size_t ofs, U16* pw)
{
ERR err = WMP_errSuccess;
FailIf(ofs + sizeof(U16) > cb, WMP_errBufferOverflow);
*pw = (U16)( pb[ofs + 1] + ( pb[ofs] << 8 ) );
Cleanup:
return err;
}
ERR getbfdwbig(const U8* pb, size_t cb, size_t ofs, U32* pdw)
{
ERR err = WMP_errSuccess;
FailIf(ofs + sizeof(U32) > cb, WMP_errBufferOverflow);
*pdw = pb[ofs + 3] + ( pb[ofs + 2] << 8 ) + ( pb[ofs + 1] << 16UL ) + ( pb[ofs] << 24UL );
Cleanup:
return err;
}
ERR getbfwe(const U8* pb, size_t cb, size_t ofs, U16* pw, U8 endian)
{
if ( endian == WMP_INTEL_ENDIAN )
return ( getbfw(pb, cb, ofs, pw) );
else
return ( getbfwbig(pb, cb, ofs, pw) );
}
ERR getbfdwe(const U8* pb, size_t cb, size_t ofs, U32* pdw, U8 endian)
{
if ( endian == WMP_INTEL_ENDIAN )
return ( getbfdw(pb, cb, ofs, pdw) );
else
return ( getbfdwbig(pb, cb, ofs, pdw) );
}
ERR setbfcpy(U8* pb, size_t cb, size_t ofs, const U8* pbset, size_t cbset)
{
ERR err = WMP_errSuccess;
FailIf(ofs + cbset > cb, WMP_errBufferOverflow);
memcpy(&pb[ofs], pbset, cbset);
Cleanup:
return err;
}
ERR setbfw(U8* pb, size_t cb, size_t ofs, U16 dw)
{
ERR err = WMP_errSuccess;
FailIf(ofs + sizeof(U16) > cb, WMP_errBufferOverflow);
pb[ofs] = (U8)dw;
pb[ofs + 1] = (U8)( dw >> 8 );
Cleanup:
return err;
}
ERR setbfdw(U8* pb, size_t cb, size_t ofs, U32 dw)
{
ERR err = WMP_errSuccess;
FailIf(ofs + sizeof(U32) > cb, WMP_errBufferOverflow);
pb[ofs] = (U8)dw;
pb[ofs + 1] = (U8)( dw >> 8 );
pb[ofs + 2] = (U8)( dw >> 16 );
pb[ofs + 3] = (U8)( dw >> 24 );
Cleanup:
return err;
}
ERR setbfwbig(U8* pb, size_t cb, size_t ofs, U16 dw)
{
ERR err = WMP_errSuccess;
FailIf(ofs + sizeof(U16) > cb, WMP_errBufferOverflow);
pb[ofs + 1] = (U8)dw;
pb[ofs] = (U8)( dw >> 8 );
Cleanup:
return err;
}
ERR setbfdwbig(U8* pb, size_t cb, size_t ofs, U32 dw)
{
ERR err = WMP_errSuccess;
FailIf(ofs + sizeof(U32) > cb, WMP_errBufferOverflow);
pb[ofs + 3] = (U8)dw;
pb[ofs + 2] = (U8)( dw >> 8 );
pb[ofs + 1] = (U8)( dw >> 16 );
pb[ofs] = (U8)( dw >> 24 );
Cleanup:
return err;
}
//================================================================
// BufferCalcIFDSize (arbitrary endian)
// StreamCalcIFDSize (little endian)
//
// count up the number of bytes needed to store the IFD and all
// associated data including a subordinate interoperability IFD if any
//================================================================
ERR BufferCalcIFDSize(const U8* pbdata, size_t cbdata, U32 ofsifd, U8 endian, U32* pcbifd)
{
ERR err = WMP_errSuccess;
U16 cDir;
U16 i;
U32 ofsdir;
U32 cbifd = 0;
U32 cbEXIFIFD = 0;
U32 cbGPSInfoIFD = 0;
U32 cbInteroperabilityIFD = 0;
*pcbifd = 0;
Call(getbfwe(pbdata, cbdata, ofsifd, &cDir, endian));
cbifd = sizeof(U16) + cDir * SizeofIFDEntry + sizeof(U32);
ofsdir = ofsifd + sizeof(U16);
for ( i = 0; i < cDir; i++ )
{
U16 tag;
U16 type;
U32 count;
U32 value;
U32 datasize;
Call(getbfwe(pbdata, cbdata, ofsdir, &tag, endian));
Call(getbfwe(pbdata, cbdata, ofsdir + sizeof(U16), &type, endian));
Call(getbfdwe(pbdata, cbdata, ofsdir + 2 * sizeof(U16), &count, endian));
Call(getbfdwe(pbdata, cbdata, ofsdir + 2 * sizeof(U16) + sizeof(U32), &value, endian));
FailIf(type == 0 || type >= sizeof(IFDEntryTypeSizes) / sizeof(IFDEntryTypeSizes[0]), WMP_errFail);
if ( tag == WMP_tagEXIFMetadata )
{
Call(BufferCalcIFDSize(pbdata, cbdata, value, endian, &cbEXIFIFD));
}
else if ( tag == WMP_tagGPSInfoMetadata )
{
Call(BufferCalcIFDSize(pbdata, cbdata, value, endian, &cbGPSInfoIFD));
}
else if ( tag == WMP_tagInteroperabilityIFD )
{
Call(BufferCalcIFDSize(pbdata, cbdata, value, endian, &cbInteroperabilityIFD));
}
else
{
datasize = IFDEntryTypeSizes[type] * count;
if ( datasize > 4 )
cbifd += datasize;
}
ofsdir += SizeofIFDEntry;
}
if ( cbEXIFIFD != 0 )
cbifd += ( cbifd & 1 ) + cbEXIFIFD;
if ( cbGPSInfoIFD != 0 )
cbifd += ( cbifd & 1 ) + cbGPSInfoIFD;
if ( cbInteroperabilityIFD != 0 )
cbifd += ( cbifd & 1 ) + cbInteroperabilityIFD;
*pcbifd = cbifd;
Cleanup:
return err;
}
ERR StreamCalcIFDSize(struct WMPStream* pWS, U32 uIFDOfs, U32 *pcbifd)
{
ERR err = WMP_errSuccess;
size_t offCurPos = 0;
Bool GetPosOK = FALSE;
U16 cDir;
U32 i;
U32 ofsdir;
U32 cbifd = 0;
U32 cbEXIFIFD = 0;
U32 cbGPSInfoIFD = 0;
U32 cbInteroperabilityIFD = 0;
*pcbifd = 0;
Call(pWS->GetPos(pWS, &offCurPos));
GetPosOK = TRUE;
Call(GetUShort(pWS, uIFDOfs, &cDir));
cbifd = sizeof(U16) + cDir * SizeofIFDEntry + sizeof(U32);
ofsdir = uIFDOfs + sizeof(U16);
for ( i = 0; i < cDir; i++ )
{
U16 tag;
U16 type;
U32 count;
U32 value;
U32 datasize;
Call(GetUShort(pWS, ofsdir, &tag));
Call(GetUShort(pWS, ofsdir + sizeof(U16), &type));
Call(GetULong(pWS, ofsdir + 2 * sizeof(U16), &count));
Call(GetULong(pWS, ofsdir + 2 * sizeof(U16) + sizeof(U32), &value));
FailIf(type == 0 || type >= sizeof(IFDEntryTypeSizes) / sizeof(IFDEntryTypeSizes[0]), WMP_errUnsupportedFormat);
if ( tag == WMP_tagEXIFMetadata )
{
Call(StreamCalcIFDSize(pWS, value, &cbEXIFIFD));
}
else if ( tag == WMP_tagGPSInfoMetadata )
{
Call(StreamCalcIFDSize(pWS, value, &cbGPSInfoIFD));
}
else if ( tag == WMP_tagInteroperabilityIFD )
{
Call(StreamCalcIFDSize(pWS, value, &cbInteroperabilityIFD));
}
else
{
datasize = IFDEntryTypeSizes[type] * count;
if ( datasize > 4 )
cbifd += datasize;
}
ofsdir += SizeofIFDEntry;
}
if ( cbEXIFIFD != 0 )
cbifd += ( cbifd & 1 ) + cbEXIFIFD;
if ( cbGPSInfoIFD != 0 )
cbifd += ( cbifd & 1 ) + cbGPSInfoIFD;
if ( cbInteroperabilityIFD != 0 )
cbifd += ( cbifd & 1 ) + cbInteroperabilityIFD;
*pcbifd = cbifd;
Cleanup:
if ( GetPosOK )
Call(pWS->SetPos(pWS, offCurPos));
return ( err );
}
// src IFD copied to dst IFD with any nested IFD's
// src IFD is arbitrary endian, arbitrary data arrangement
// dst IFD is little endian, data arranged in tag order
// dst IFD tags are ordered the same as src IFD so src IFD tags must be in order
ERR BufferCopyIFD(const U8* pbsrc, U32 cbsrc, U32 ofssrc, U8 endian, U8* pbdst, U32 cbdst, U32* pofsdst)
{
ERR err = WMP_errSuccess;
U16 cDir;
U16 i;
U16 ofsEXIFIFDEntry = 0;
U16 ofsGPSInfoIFDEntry = 0;
U16 ofsInteroperabilityIFDEntry = 0;
U32 ofsEXIFIFD = 0;
U32 ofsGPSInfoIFD = 0;
U32 ofsInteroperabilityIFD = 0;
U32 ofsdstnextdata;
U32 ofsdst = *pofsdst;
U32 ofssrcdir;
U32 ofsdstdir;
U32 ofsnextifd;
Call(getbfwe(pbsrc, cbsrc, ofssrc, &cDir, endian));
Call(setbfw(pbdst, cbdst, ofsdst, cDir));
ofsnextifd = ofsdst + sizeof(U16) + SizeofIFDEntry * cDir;
ofsdstnextdata = ofsnextifd + sizeof(U32);
ofssrcdir = ofssrc + sizeof(U16);
ofsdstdir = ofsdst + sizeof(U16);
for ( i = 0; i < cDir; i++ )
{
U16 tag;
U16 type;
U32 count;
U32 value;
U32 size;
Call(getbfwe(pbsrc, cbsrc, ofssrcdir, &tag, endian));
Call(setbfw(pbdst, cbdst, ofsdstdir, tag));
Call(getbfwe(pbsrc, cbsrc, ofssrcdir + sizeof(U16), &type, endian));
Call(setbfw(pbdst, cbdst, ofsdstdir + sizeof(U16), type));
Call(getbfdwe(pbsrc, cbsrc, ofssrcdir + 2 * sizeof(U16), &count, endian));
Call(setbfdw(pbdst, cbdst, ofsdstdir + 2 * sizeof(U16), count));
Call(getbfdwe(pbsrc, cbsrc, ofssrcdir + 2 * sizeof(U16) + sizeof(U32), &value, endian));
Call(setbfdw(pbdst, cbdst, ofsdstdir + 2 * sizeof(U16) + sizeof(U32), 0));
FailIf(type == 0 || type >= sizeof(IFDEntryTypeSizes) / sizeof(IFDEntryTypeSizes[0]), WMP_errFail);
if ( tag == WMP_tagEXIFMetadata )
{
ofsEXIFIFDEntry = (U16) ofsdstdir;
ofsEXIFIFD = value;
}
else if ( tag == WMP_tagGPSInfoMetadata )
{
ofsGPSInfoIFDEntry = (U16) ofsdstdir;
ofsGPSInfoIFD = value;
}
else if ( tag == WMP_tagInteroperabilityIFD )
{
ofsInteroperabilityIFDEntry = (U16) ofsdstdir;
ofsInteroperabilityIFD = value;
}
else
{
U32 ofsdstdata = ofsdstdir + 2 * sizeof(U16) + sizeof(U32);
U32 ofssrcdata = ofssrcdir + 2 * sizeof(U16) + sizeof(U32);
size = count * IFDEntryTypeSizes[type];
if ( size > 4 )
{
ofssrcdata = value;
Call(setbfdw(pbdst, cbdst, ofsdstdata, ofsdstnextdata));
ofsdstdata = ofsdstnextdata;
ofsdstnextdata += size;
}
FailIf(ofssrcdata + size > cbsrc || ofsdstdata + size > cbdst, WMP_errBufferOverflow);
if ( size == count || endian == WMP_INTEL_ENDIAN )
// size == count means 8-bit data means endian doesn't matter
memcpy(&pbdst[ofsdstdata], &pbsrc[ofssrcdata], size);
else
{ // big endian source and endian matters
U32 j;
switch ( IFDEntryTypeSizes[type] )
{
case 2:
for ( j = 0; j < count; j++ )
{
U16 w;
getbfwbig(pbsrc, cbsrc, ofssrcdata + j * sizeof(U16), &w);
setbfw(pbdst, cbdst, ofsdstdata + j * sizeof(U16), w);
}
break;
case 8:
if ( type == WMP_typDOUBLE )
{
for ( j = 0; j < count; j++ )
{
U32 dwlo;
U32 dwhi;
getbfdwbig(pbsrc, cbsrc, ofssrcdata + j * 8, &dwhi);
getbfdwbig(pbsrc, cbsrc, ofssrcdata + j * 8 + sizeof(U32), &dwlo);
setbfdw(pbdst, cbdst, ofsdstdata + j * 8, dwlo);
setbfdw(pbdst, cbdst, ofsdstdata + j * 8 + sizeof(U32), dwhi);
}
break;
}
count *= 2;
// RATIONAL's fall through to be handled as LONG's
case 4:
for ( j = 0; j < count; j++ )
{
U32 dw;
getbfdwbig(pbsrc, cbsrc, ofssrcdata + j * sizeof(U32), &dw);
setbfdw(pbdst, cbdst, ofsdstdata + j * sizeof(U32), dw);
}
break;
}
}
}
ofssrcdir += SizeofIFDEntry;
ofsdstdir += SizeofIFDEntry;
}
Call(setbfdw(pbdst, cbdst, ofsnextifd, 0)); // no nextIFD
if ( ofsEXIFIFDEntry != 0 )
{
ofsdstnextdata += ( ofsdstnextdata & 1 );
Call(setbfdw(pbdst, cbdst, ofsEXIFIFDEntry + 2 * sizeof(U16) + sizeof(U32), ofsdstnextdata));
Call(BufferCopyIFD(pbsrc, cbsrc, ofsEXIFIFD, endian, pbdst, cbdst, &ofsdstnextdata));
}
if ( ofsGPSInfoIFDEntry != 0 )
{
ofsdstnextdata += ( ofsdstnextdata & 1 );
Call(setbfdw(pbdst, cbdst, ofsGPSInfoIFDEntry + 2 * sizeof(U16) + sizeof(U32), ofsdstnextdata));
Call(BufferCopyIFD(pbsrc, cbsrc, ofsGPSInfoIFD, endian, pbdst, cbdst, &ofsdstnextdata));
}
if ( ofsInteroperabilityIFDEntry != 0 )
{
ofsdstnextdata += ( ofsdstnextdata & 1 );
Call(setbfdw(pbdst, cbdst, ofsInteroperabilityIFDEntry + 2 * sizeof(U16) + sizeof(U32), ofsdstnextdata));
Call(BufferCopyIFD(pbsrc, cbsrc, ofsInteroperabilityIFD, endian, pbdst, cbdst, &ofsdstnextdata));
}
*pofsdst = ofsdstnextdata;
Cleanup:
return err;
}
// src IFD copied to dst IFD with any nested IFD's
// src IFD is little endian, arbitrary data arrangement
// dst IFD is little endian, data arranged in tag order
// dst IFD tags are ordered the same as src IFD so src IFD tags must be in order
ERR StreamCopyIFD(struct WMPStream* pWS, U32 ofssrc, U8* pbdst, U32 cbdst, U32* pofsdst)
{
ERR err = WMP_errSuccess;
size_t offCurPos = 0;
Bool GetPosOK = FALSE;
U16 cDir;
U16 i;
U16 ofsEXIFIFDEntry = 0;
U16 ofsGPSInfoIFDEntry = 0;
U16 ofsInteroperabilityIFDEntry = 0;
U32 ofsEXIFIFD = 0;
U32 ofsGPSInfoIFD = 0;
U32 ofsInteroperabilityIFD = 0;
U32 ofsdstnextdata;
U32 ofsdst = *pofsdst;
U32 ofssrcdir;
U32 ofsdstdir;
U32 ofsnextifd;
Call(pWS->GetPos(pWS, &offCurPos));
GetPosOK = TRUE;
Call(GetUShort(pWS, ofssrc, &cDir));
Call(setbfw(pbdst, cbdst, ofsdst, cDir));
ofsnextifd = ofsdst + sizeof(U16) + SizeofIFDEntry * cDir;
ofsdstnextdata = ofsnextifd + sizeof(U32);
ofssrcdir = ofssrc + sizeof(U16);
ofsdstdir = ofsdst + sizeof(U16);
for ( i = 0; i < cDir; i++ )
{
U16 tag;
U16 type;
U32 count;
U32 value;
U32 size;
Call(GetUShort(pWS, ofssrcdir, &tag));
Call(setbfw(pbdst, cbdst, ofsdstdir, tag));
Call(GetUShort(pWS, ofssrcdir + sizeof(U16), &type));
Call(setbfw(pbdst, cbdst, ofsdstdir + sizeof(U16), type));
Call(GetULong(pWS, ofssrcdir + 2 * sizeof(U16), &count));
Call(setbfdw(pbdst, cbdst, ofsdstdir + 2 * sizeof(U16), count));
Call(GetULong(pWS, ofssrcdir + 2 * sizeof(U16) + sizeof(U32), &value));
Call(setbfdw(pbdst, cbdst, ofsdstdir + 2 * sizeof(U16) + sizeof(U32), 0));
FailIf(type == 0 || type >= sizeof(IFDEntryTypeSizes) / sizeof(IFDEntryTypeSizes[0]), WMP_errFail);
if ( tag == WMP_tagEXIFMetadata )
{
ofsEXIFIFDEntry = (U16) ofsdstdir;
ofsEXIFIFD = value;
}
else if ( tag == WMP_tagGPSInfoMetadata )
{
ofsGPSInfoIFDEntry = (U16) ofsdstdir;
ofsGPSInfoIFD = value;
}
else if ( tag == WMP_tagInteroperabilityIFD )
{
ofsInteroperabilityIFDEntry = (U16) ofsdstdir;
ofsInteroperabilityIFD = value;
}
else
{
U32 ofsdstdata = ofsdstdir + 2 * sizeof(U16) + sizeof(U32);
U32 ofssrcdata = ofssrcdir + 2 * sizeof(U16) + sizeof(U32);
size = count * IFDEntryTypeSizes[type];
if ( size > 4 )
{
ofssrcdata = value;
Call(setbfdw(pbdst, cbdst, ofsdstdata, ofsdstnextdata));
ofsdstdata = ofsdstnextdata;
ofsdstnextdata += size;
}
FailIf(ofsdstdata + size > cbdst, WMP_errBufferOverflow);
Call(pWS->SetPos(pWS, ofssrcdata));
Call(pWS->Read(pWS, &pbdst[ofsdstdata], size));
}
ofssrcdir += SizeofIFDEntry;
ofsdstdir += SizeofIFDEntry;
}
Call(setbfdw(pbdst, cbdst, ofsnextifd, 0)); // no nextIFD
if ( ofsEXIFIFDEntry != 0 )
{
ofsdstnextdata += ( ofsdstnextdata & 1 );
Call(setbfdw(pbdst, cbdst, ofsEXIFIFDEntry + 2 * sizeof(U16) + sizeof(U32), ofsdstnextdata));
Call(StreamCopyIFD(pWS, ofsEXIFIFD, pbdst, cbdst, &ofsdstnextdata));
}
if ( ofsGPSInfoIFDEntry != 0 )
{
ofsdstnextdata += ( ofsdstnextdata & 1 );
Call(setbfdw(pbdst, cbdst, ofsGPSInfoIFDEntry + 2 * sizeof(U16) + sizeof(U32), ofsdstnextdata));
Call(StreamCopyIFD(pWS, ofsGPSInfoIFD, pbdst, cbdst, &ofsdstnextdata));
}
if ( ofsInteroperabilityIFDEntry != 0 )
{
ofsdstnextdata += ( ofsdstnextdata & 1 );
Call(setbfdw(pbdst, cbdst, ofsInteroperabilityIFDEntry + 2 * sizeof(U16) + sizeof(U32), ofsdstnextdata));
Call(StreamCopyIFD(pWS, ofsInteroperabilityIFD, pbdst, cbdst, &ofsdstnextdata));
}
*pofsdst = ofsdstnextdata;
Cleanup:
if ( GetPosOK )
Call(pWS->SetPos(pWS, offCurPos));
return err;
}
//================================================================
ERR GetUShort(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
__out_ecount(1) U16* puValue)
{
ERR err = WMP_errSuccess;
U8 cVal;
Call(pWS->SetPos(pWS, offPos));
Call(pWS->Read(pWS, &cVal, sizeof(cVal)));
puValue[0] = (U16) cVal;
Call(pWS->Read(pWS, &cVal, sizeof(cVal)));
puValue[0] += ((U16) cVal) << 8;
Cleanup:
return err;
}
ERR PutUShort(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
U16 uValue)
{
ERR err = WMP_errSuccess;
U8 cVal = (U8) uValue;
Call(pWS->SetPos(pWS, offPos));
Call(pWS->Write(pWS, &cVal, sizeof(cVal)));
cVal = (U8) (uValue >> 8);
Call(pWS->Write(pWS, &cVal, sizeof(cVal)));
Cleanup:
return err;
}
ERR GetULong(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
__out_ecount(1) U32* puValue)
{
ERR err = WMP_errSuccess;
U8 cVal;
Call(pWS->SetPos(pWS, offPos));
Call(pWS->Read(pWS, &cVal, sizeof(cVal)));
puValue[0] = (U32) cVal;
Call(pWS->Read(pWS, &cVal, sizeof(cVal)));
puValue[0] += ((U32) cVal) << 8;
Call(pWS->Read(pWS, &cVal, sizeof(cVal)));
puValue[0] += ((U32) cVal) << 16;
Call(pWS->Read(pWS, &cVal, sizeof(cVal)));
puValue[0] += ((U32) cVal) << 24;
Cleanup:
return err;
}
ERR PutULong(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
U32 uValue)
{
ERR err = WMP_errSuccess;
U8 cVal = (U8) uValue;
Call(pWS->SetPos(pWS, offPos));
Call(pWS->Write(pWS, &cVal, sizeof(cVal)));
cVal = (U8) (uValue >> 8);
Call(pWS->Write(pWS, &cVal, sizeof(cVal)));
cVal = (U8) (uValue >> 16);
Call(pWS->Write(pWS, &cVal, sizeof(cVal)));
cVal = (U8) (uValue >> 24);
Call(pWS->Write(pWS, &cVal, sizeof(cVal)));
Cleanup:
return err;
}
ERR ReadBinaryData(__in_ecount(1) struct WMPStream* pWS,
const __in_win U32 uCount,
const __in_win U32 uValue,
U8 **ppbData)
{
ERR err = WMP_errSuccess;
U8 *pbData = NULL;
Call(PKAlloc((void **) &pbData, uCount + 2)); // Allocate buffer to store data with space for an added ascii or unicode null
if (uCount <= 4)
{
unsigned int i;
for (i = 0; i < uCount; i++)
pbData[i] = ((U8*)&uValue)[i]; // Copy least sig bytes - we assume 'II' type TIFF files
}
else
{
size_t offPosPrev;
Call(pWS->GetPos(pWS, &offPosPrev));
Call(pWS->SetPos(pWS, uValue));
Call(pWS->Read(pWS, pbData, uCount));
Call(pWS->SetPos(pWS, offPosPrev));
}
*ppbData = pbData;
Cleanup:
if (Failed(err))
{
if (pbData)
PKFree((void **) &pbData);
}
return err;
}
ERR ReadPropvar(__in_ecount(1) struct WMPStream* pWS,
const __in_win U16 uType,
const __in_win U32 uCount,
const __in_win U32 uValue,
__out_win DPKPROPVARIANT *pvar)
{
ERR err = WMP_errSuccess;
// U8 *pbData = NULL;
memset(pvar, 0, sizeof(*pvar));
if (uCount == 0)
goto Cleanup; // Nothing to read in here
switch (uType)
{
case WMP_typASCII:
pvar->vt = DPKVT_LPSTR;
Call(ReadBinaryData(pWS, uCount, uValue, (U8 **) &pvar->VT.pszVal));
assert(0 == pvar->VT.pszVal[uCount - 1]); // Check that it's null-terminated
// make sure (ReadBinaryData allocated uCount + 2 so this and unicode can have forced nulls)
pvar->VT.pszVal[uCount] = 0;
break;
case WMP_typBYTE:
case WMP_typUNDEFINED:
// Return as regular C array rather than safearray, as this type is sometimes
// used to convey unicode (which does not require a count field). Caller knows
// uCount and can convert to safearray if necessary.
pvar->vt = (DPKVT_BYREF | DPKVT_UI1);
Call(ReadBinaryData(pWS, uCount, uValue, &pvar->VT.pbVal));
break;
case WMP_typSHORT:
if (1 == uCount)
{
pvar->vt = DPKVT_UI2;
pvar->VT.uiVal = (U16)(uValue & 0x0000FFFF);
}
else if (2 == uCount)
{
pvar->vt = DPKVT_UI4;
pvar->VT.ulVal = uValue;
}
else
{
assert(FALSE); // NYI
FailIf(TRUE, WMP_errNotYetImplemented);
}
break;
default:
assert(FALSE); // Unhandled type
FailIf(TRUE, WMP_errNotYetImplemented);
break;
}
Cleanup:
return err;
}
ERR WriteWmpDE(
__in_ecount(1) struct WMPStream* pWS,
size_t *pOffPos,
const __in_ecount(1) WmpDE* pDE,
const U8 *pbData,
U32 *pcbDataWrittenToOffset)
{
ERR err = WMP_errSuccess;
size_t offPos = *pOffPos;
assert(-1 != pDE->uCount);
assert(-1 != pDE->uValueOrOffset);
if (pcbDataWrittenToOffset)
{
assert(pbData); // Makes no sense to provide this arg without pbData
*pcbDataWrittenToOffset = 0;
}
Call(PutUShort(pWS, offPos, pDE->uTag)); offPos += 2;
Call(PutUShort(pWS, offPos, pDE->uType)); offPos += 2;
Call(PutULong(pWS, offPos, pDE->uCount)); offPos += 4;
switch (pDE->uType)
{
case WMP_typASCII:
case WMP_typUNDEFINED:
case WMP_typBYTE:
if (pDE->uCount <= 4)
{
U8 pad[4] = {0};
Call(pWS->SetPos(pWS, offPos));
if (NULL == pbData)
pbData = (U8*)&pDE->uValueOrOffset;
Call(pWS->Write(pWS, pbData, pDE->uCount));
Call(pWS->Write(pWS, pad, 4 - pDE->uCount)); offPos += 4;
}
else
{
Call(PutULong(pWS, offPos, pDE->uValueOrOffset)); offPos += 4;
// Write the data if requested to do so
if (pbData)
{
Call(pWS->SetPos(pWS, pDE->uValueOrOffset));
Call(pWS->Write(pWS, pbData, pDE->uCount));
Call(pWS->SetPos(pWS, offPos));
*pcbDataWrittenToOffset = pDE->uCount;
}
}
break;
case WMP_typSHORT:
if (pDE->uCount <= 2)
{
U16 uiShrt1 = 0;
U16 uiShrt2 = 0;
if (NULL == pbData)
pbData = (U8*)&pDE->uValueOrOffset;
if (pDE->uCount > 0)
uiShrt1 = *((U16*)pbData);
if (pDE->uCount > 1)
{
assert(FALSE); // Untested - remove this assert after this has been tested
uiShrt2 = *(U16*)(pbData + 2);
}
Call(PutUShort(pWS, offPos, uiShrt1)); offPos += 2;
Call(PutUShort(pWS, offPos, uiShrt2)); offPos += 2;
}
else
{
assert(FALSE); // Untested - remove this assert after this has been tested
Call(PutULong(pWS, offPos, pDE->uValueOrOffset)); offPos += 4;
// Write the data if requested to do so
if (pbData)
{
U32 i;
Call(pWS->SetPos(pWS, pDE->uValueOrOffset));
for (i = 0; i < pDE->uCount; i++)
{
const U16 uiShort = *(U16*)(pbData + i*sizeof(U16));
Call(PutUShort(pWS, offPos, uiShort)); // Write one at a time for endian purposes - but inefficient
}
Call(pWS->SetPos(pWS, offPos));
*pcbDataWrittenToOffset = pDE->uCount * sizeof(U16);
}
}
break;
case WMP_typFLOAT:
case WMP_typLONG:
if (pDE->uCount <= 1)
{
if (NULL == pbData)
pbData = (U8*)&pDE->uValueOrOffset;
Call(PutULong(pWS, offPos, *(U32*)pbData)); offPos += 4;
}
else
{
assert(FALSE); // Untested - remove this assert after this has been tested
Call(PutULong(pWS, offPos, pDE->uValueOrOffset)); offPos += 4;
// Write the data if requested to do so
if (pbData)
{
U32 i;
Call(pWS->SetPos(pWS, pDE->uValueOrOffset));
for (i = 0; i < pDE->uCount; i++)
{
const U32 uLong = *(U32*)(pbData + i*sizeof(U32));
Call(PutULong(pWS, offPos, uLong)); // Write one at a time for endian purposes - but inefficient
}
Call(pWS->SetPos(pWS, offPos));
*pcbDataWrittenToOffset = pDE->uCount * sizeof(U32);
}
}
break;
default:
assert(FALSE); // Alert the programmer
Call(WMP_errInvalidParameter);
break;
}
Cleanup:
*pOffPos = offPos;
return err;
}

View File

@ -1,258 +0,0 @@
//*@@@+++@@@@******************************************************************
//
// Copyright © Microsoft Corp.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// • Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// • Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//*@@@---@@@@******************************************************************
#pragma once
#include "../image/sys/windowsmediaphoto.h"
#ifndef WIN32
#include <wmspecstring.h>
#endif
#ifndef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(P) { (P) = (P); }
#endif
//================================================================
// Container
//================================================================
// Keep these in sort order so that we can easily confirm we are outputting tags in ascending order
#define WMP_tagNull 0
#define WMP_tagDocumentName 0x010d // Descriptive metadata tag
#define WMP_tagImageDescription 0x010e // Descriptive metadata tag
#define WMP_tagCameraMake 0x010f // Descriptive metadata tag
#define WMP_tagCameraModel 0x0110 // Descriptive metadata tag
#define WMP_tagPageName 0x011d // Descriptive metadata tag
#define WMP_tagPageNumber 0x0129 // Descriptive metadata tag
#define WMP_tagSoftware 0x0131 // Descriptive metadata tag
#define WMP_tagDateTime 0x0132 // Descriptive metadata tag
#define WMP_tagArtist 0x013b // Descriptive metadata tag
#define WMP_tagHostComputer 0x013c // Descriptive metadata tag
#define WMP_tagXMPMetadata 0x02bc
#define WMP_tagRatingStars 0x4746 // Descriptive metadata tag
#define WMP_tagRatingValue 0x4749 // Descriptive metadata tag
#define WMP_tagCopyright 0x8298 // Descriptive metadata tag
#define WMP_tagEXIFMetadata 0x8769
#define WMP_tagGPSInfoMetadata 0x8825
#define WMP_tagIPTCNAAMetadata 0x83bb
#define WMP_tagPhotoshopMetadata 0x8649
#define WMP_tagInteroperabilityIFD 0xa005
#define WMP_tagIccProfile 0x8773 // Need to use same tag as TIFF!!
#define WMP_tagCaption 0x9c9b // Descriptive metadata tag
#define WMP_tagPixelFormat 0xbc01
#define WMP_tagTransformation 0xbc02
#define WMP_tagCompression 0xbc03
#define WMP_tagImageType 0xbc04
#define WMP_tagImageWidth 0xbc80
#define WMP_tagImageHeight 0xbc81
#define WMP_tagWidthResolution 0xbc82
#define WMP_tagHeightResolution 0xbc83
#define WMP_tagImageOffset 0xbcc0
#define WMP_tagImageByteCount 0xbcc1
#define WMP_tagAlphaOffset 0xbcc2
#define WMP_tagAlphaByteCount 0xbcc3
#define WMP_tagImageDataDiscard 0xbcc4
#define WMP_tagAlphaDataDiscard 0xbcc5
#define WMP_typBYTE 1
#define WMP_typASCII 2
#define WMP_typSHORT 3
#define WMP_typLONG 4
#define WMP_typRATIONAL 5
#define WMP_typSBYTE 6
#define WMP_typUNDEFINED 7
#define WMP_typSSHORT 8
#define WMP_typSLONG 9
#define WMP_typSRATIONAL 10
#define WMP_typFLOAT 11
#define WMP_typDOUBLE 12
#define WMP_valCompression 0xbc
#define WMP_valWMPhotoID WMP_valCompression
#ifdef WIN32
#define __in_win
#define __out_win
#endif
//================================================================
typedef enum
{
DPKVT_EMPTY = 0,
DPKVT_UI1 = 17,
DPKVT_UI2 = 18,
DPKVT_UI4 = 19,
DPKVT_LPSTR = 30,
DPKVT_LPWSTR = 31,
DPKVT_BYREF = 0x4000,
} DPKVARTYPE;
typedef struct DPKPROPVARIANT
{
DPKVARTYPE vt;
union
{
U8 bVal; // DPKVT_UI1
U16 uiVal; // DPKVT_UI2
U32 ulVal; // DPKVT_UI4
char *pszVal; // DPKVT_LPSTR
U16 *pwszVal; // DPKVT_LPWSTR
U8 *pbVal; // DPKVT_BYREF | DPKVT_UI1
} VT;
} DPKPROPVARIANT;
typedef struct DESCRIPTIVEMETADATA
{
DPKPROPVARIANT pvarImageDescription; // WMP_tagImageDescription
DPKPROPVARIANT pvarCameraMake; // WMP_tagCameraMake
DPKPROPVARIANT pvarCameraModel; // WMP_tagCameraModel
DPKPROPVARIANT pvarSoftware; // WMP_tagSoftware
DPKPROPVARIANT pvarDateTime; // WMP_tagDateTime
DPKPROPVARIANT pvarArtist; // WMP_tagArtist
DPKPROPVARIANT pvarCopyright; // WMP_tagCopyright
DPKPROPVARIANT pvarRatingStars; // WMP_tagRatingStars
DPKPROPVARIANT pvarRatingValue; // WMP_tagRatingValue
DPKPROPVARIANT pvarCaption; // WMP_tagCaption
DPKPROPVARIANT pvarDocumentName; // WMP_tagDocumentName
DPKPROPVARIANT pvarPageName; // WMP_tagPageName
DPKPROPVARIANT pvarPageNumber; // WMP_tagPageNumber
DPKPROPVARIANT pvarHostComputer; // WMP_tagHostComputer
} DESCRIPTIVEMETADATA;
typedef struct tagWmpDE
{
U16 uTag;
U16 uType;
U32 uCount;
U32 uValueOrOffset;
} WmpDE;
typedef struct tagWmpDEMisc
{
U32 uImageOffset;
U32 uImageByteCount;
U32 uAlphaOffset;
U32 uAlphaByteCount;
U32 uOffPixelFormat;
U32 uOffImageByteCount;
U32 uOffAlphaOffset;
U32 uOffAlphaByteCount;
U32 uColorProfileOffset;
U32 uColorProfileByteCount;
U32 uXMPMetadataOffset;
U32 uXMPMetadataByteCount;
U32 uEXIFMetadataOffset;
U32 uEXIFMetadataByteCount;
U32 uGPSInfoMetadataOffset;
U32 uGPSInfoMetadataByteCount;
U32 uIPTCNAAMetadataOffset;
U32 uIPTCNAAMetadataByteCount;
U32 uPhotoshopMetadataOffset;
U32 uPhotoshopMetadataByteCount;
U32 uDescMetadataOffset;
U32 uDescMetadataByteCount;
} WmpDEMisc;
//================================================================
EXTERN_C ERR GetUShort(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
__out_ecount(1) U16* puValue
);
EXTERN_C ERR PutUShort(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
U16 uValue
);
EXTERN_C ERR GetULong(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
__out_ecount(1) U32* puValue
);
EXTERN_C ERR PutULong(
__in_ecount(1) struct WMPStream* pWS,
size_t offPos,
U32 uValue
);
EXTERN_C ERR WriteWmpDE(
__in_ecount(1) struct WMPStream* pWS,
size_t *pOffPos,
const __in_ecount(1) WmpDE* pDE,
const U8 *pbData,
U32 *pcbDataWrittenToOffset
);
EXTERN_C ERR ReadPropvar(__in_ecount(1) struct WMPStream* pWS,
const __in_win U16 uType,
const __in_win U32 uCount,
const __in_win U32 uValue,
__out_win DPKPROPVARIANT *pvar);
// read and write little endian words/dwords from a buffer on both big and little endian cpu's
// with full buffer overflow checking
#define WMP_INTEL_ENDIAN ('I')
EXTERN_C ERR getbfcpy(U8* pbdest, const U8* pb, size_t cb, size_t ofs, U32 n);
EXTERN_C ERR getbfw(const U8* pb, size_t cb, size_t ofs, U16* pw);
EXTERN_C ERR getbfdw(const U8* pb, size_t cb, size_t ofs, U32* pdw);
EXTERN_C ERR getbfwbig(const U8* pb, size_t cb, size_t ofs, U16* pw);
EXTERN_C ERR getbfdwbig(const U8* pb, size_t cb, size_t ofs, U32* pdw);
EXTERN_C ERR getbfwe(const U8* pb, size_t cb, size_t ofs, U16* pw, U8 endian);
EXTERN_C ERR getbfdwe(const U8* pb, size_t cb, size_t ofs, U32* pdw, U8 endian);
EXTERN_C ERR setbfcpy(U8* pb, size_t cb, size_t ofs, const U8* pbset, size_t cbset);
EXTERN_C ERR setbfw(U8* pb, size_t cb, size_t ofs, U16 dw);
EXTERN_C ERR setbfdw(U8* pb, size_t cb, size_t ofs, U32 dw);
EXTERN_C ERR setbfwbig(U8* pb, size_t cb, size_t ofs, U16 dw);
EXTERN_C ERR setbfdwbig(U8* pb, size_t cb, size_t ofs, U32 dw);
EXTERN_C ERR BufferCalcIFDSize(const U8* pb, size_t cb, U32 uIFDOfs, U8 endian, U32 *pcbifd);
EXTERN_C ERR StreamCalcIFDSize(struct WMPStream* pWS, U32 uIFDOfs, U32 *pcbifd);
EXTERN_C ERR BufferCopyIFD(const U8* pbsrc, U32 cbsrc, U32 ofssrc, U8 endian, U8* pbdest, U32 cbdest, U32* pofsdest);
EXTERN_C ERR StreamCopyIFD(struct WMPStream* pWS, U32 ofssrc, U8* pbdest, U32 cbdest, U32* pofsdest);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More