Compare commits

..

178 Commits
v0.80 ... v0.82

Author SHA1 Message Date
Carlos Fernandez
fc14c61ac1 Merge branch 'pr/n411_Abhinav95' 2016-08-16 10:33:50 -07:00
Carlos Fernandez
c4073d1813 leptonica/tesseract version upgrade in release build (VS) 2016-08-16 10:33:17 -07:00
Abhinav Shukla
a78f7d2a05 Only processing the stream specified by dvblang 2016-08-16 05:23:44 -07:00
Carlos Fernandez
cfa8f5ac31 Merge branch 'pr/n410_Abhinav95' 2016-08-15 16:36:50 -07:00
Abhinav Shukla
4b239fd2ee Adding ocrlang and dvblang, removing special cases for languages 2016-08-15 16:24:06 -07:00
Carlos Fernandez
676539cf8c Updated Tesseract and leptonica versions, included the files in the repo because there's a royal pain to find and/or build. 2016-08-15 16:15:50 -07:00
Carlos Fernandez
9bd4f5acdb Merge branch 'pr/n408_Abhinav95' 2016-08-15 15:18:52 -07:00
Abhinav Shukla
0ad7ae6f66 Merge remote-tracking branch 'upstream/master' 2016-08-13 05:32:22 -07:00
Abhinav Shukla
625b477c23 Remove misleading comment 2016-08-12 15:09:08 -07:00
Carlos Fernandez
a75ba7edd4 Merge branch 'pr/n408_Abhinav95' 2016-08-12 15:07:59 -07:00
Abhinav Shukla
3a24024aaf Setting default language file directory to TESSERACT_PREFIX/tessdata 2016-08-12 15:05:52 -07:00
Carlos Fernandez
e4769fd0e6 Merge branch 'pr/n408_Abhinav95' 2016-08-12 10:23:13 -07:00
Abhinav Shukla
cd706068c8 Fixing problem with windows paths for traineddata 2016-08-12 03:40:59 -07:00
Carlos Fernandez
00a2dcfa77 Merge branch 'pr/n407_Abhinav95' 2016-08-11 12:54:34 -07:00
Carlos Fernandez
a27c8019a6 Minor typo correction 2016-08-11 12:53:49 -07:00
Abhinav Shukla
3f27fd7dc1 Fixing error with path of tesseract traineddata 2016-08-11 12:21:24 -07:00
Abhinav Shukla
a83467f595 Removing excessive language notices 2016-08-11 11:58:46 -07:00
Abhinav Shukla
45d8c63a45 Adding 99 possible languages to DVB subtitle OCR 2016-08-11 11:17:39 -07:00
Abhinav Shukla
0fd7967e7f Improving documentation readability 2016-08-10 12:54:34 -07:00
Abhinav Shukla
e2f850192f Italic Detection and improved documentation 2016-08-10 09:33:08 -07:00
Abhinav Shukla
5a6dfd0c18 Added correct progress display and hue image filter for colored subs 2016-08-10 06:43:58 -07:00
Abhinav Shukla
ef8141c8a9 User documentation 2016-08-10 03:39:01 -07:00
Carlos Fernandez
5a4aa337b3 Removed compile warnings. 2016-08-08 14:41:32 -07:00
Carlos Fernandez
7687576e1f Pushed version number to 0.82 2016-08-08 14:13:48 -07:00
Carlos Fernandez
8ca63e02eb Merge branch 'pr/n405_Abhinav95' 2016-08-08 14:05:23 -07:00
Carlos Fernandez
606a5a56bc Final changes for the max 80 characters correction in help screen. 2016-08-08 12:14:45 -07:00
Carlos Fernandez
af8a79757e More changes in help screen 2016-08-08 12:05:30 -07:00
Carlos Fernandez
e920c06dc0 More help screen changes. 2016-08-08 12:02:27 -07:00
Carlos Fernandez
ed8592f5f8 More changes in help screen 2016-08-08 11:59:12 -07:00
Carlos Fernandez
f5bb5fba27 More changes in help screen. 2016-08-08 11:56:56 -07:00
Carlos Fernandez
43acdce578 More help screen changes. 2016-08-08 11:55:48 -07:00
Abhinav Shukla
92b899dc2a Cleanliness is all. 2016-08-08 11:55:31 -07:00
Carlos Fernandez
f4c60c3aed More help screen corrections. 2016-08-08 11:53:41 -07:00
Carlos Fernandez
057a1d11b1 More help corrections 2016-08-08 11:42:31 -07:00
Carlos Fernandez
030635a86b help screen corrections 2016-08-08 11:36:23 -07:00
Carlos Fernandez
af248ffd24 Correction in help screen 2016-08-08 11:26:40 -07:00
Abhinav Shukla
fa60e2ad68 Fixing build error when HardsubX not enabled 2016-08-05 12:33:17 -07:00
Abhinav Shukla
b2784bd3da Dumping HardsubX parameters 2016-08-05 12:21:35 -07:00
Carlos Fernandez
8bfcb24d15 Added new lines to bitmap -> transcript 2016-08-05 11:02:46 -07:00
Abhinav Shukla
1aaf8b465f Fixing bug with time interval in packet processing 2016-08-04 00:34:58 -07:00
Abhinav Shukla
ffb85d90a3 Update Makefile to check if libav present 2016-08-03 20:09:19 -07:00
Abhinav Shukla
37d9f93eb5 Merge remote-tracking branch 'upstream/master' 2016-08-01 11:26:29 -07:00
Abhinav Shukla
39559413f5 Fix errors with classifiers, write debug display function 2016-08-01 11:19:48 -07:00
Carlos Fernandez
8c845f5135 Merge branch 'pr/n403_canihavesomecoffee' 2016-08-01 10:46:04 -07:00
Carlos Fernandez
ef7ad10fdb Merge branch 'pr/n404_Abhinav95' 2016-08-01 10:45:30 -07:00
Carlos Fernandez
e6ca4274ec Undo part of the clever capitalization stuff. Doesn't work well for TV stations that are all caps except for hard of hearing notes. 2016-08-01 10:44:44 -07:00
Abhinav Shukla
d97c51139f Freeing result iterator after a frame is processed 2016-08-01 00:02:05 -07:00
Abhinav Shukla
52dfc82054 Setting up different levels of subtitle classifiers 2016-07-31 23:54:48 -07:00
Abhinav Shukla
773fb63f92 Accurate time base conversion, changing file structure 2016-07-31 23:21:44 -07:00
Abhinav Shukla
7ce4c4008c Adding HardsubX parameter parsing 2016-07-31 22:11:13 -07:00
Abhinav Shukla
178db0a085 Merge remote-tracking branch 'upstream/master' 2016-07-31 13:51:20 -07:00
Abhinav Shukla
bc833c47dc Setting up other hardsubx parameters 2016-07-31 13:51:13 -07:00
Abhinav Shukla
617b4658b4 Creating new macro and updating Makefile, hadnling errors 2016-07-31 12:13:45 -07:00
canihavesomecoffee
98a79e0e55 Re-add the VERSION_FILE_PRESENT flag 2016-07-30 18:37:32 +02:00
Carlos Fernandez
878106386c Corrected capitalization stuff: Don't touch lines that already have both upper and lower case (i.e. assume they are correct already) and don't force new sentence between frames as that's just not correct. Long sentences will take more than one frame for sure. 2016-07-29 16:41:06 -07:00
Abhinav Shukla
3c870eef7d Freeing color detection tables 2016-07-26 23:21:27 -07:00
Abhinav Shukla
4f3d61a7eb Fixing memory leaks in frame processing 2016-07-26 23:17:14 -07:00
Carlos Fernandez
470e80a194 Minor correction in help screen 2016-07-25 16:16:05 -07:00
Abhinav Shukla
92885635ed Generating a basic, correctly timed output file with simple OCR 2016-07-23 18:18:32 -07:00
Abhinav Shukla
722cecf0d3 Resolving merge conflict with dvbcolor and syncing with upstream 2016-07-22 19:51:51 -07:00
Abhinav Shukla
6a9d7e7da2 Fixing segfault for empty OCR line 2016-07-22 17:54:32 -07:00
Abhinav Shukla
22ec6b96b2 Fixing compilation warnings for image_copy struct 2016-07-22 07:01:05 -07:00
Abhinav Shukla
0c8471438a Fixing error with invalid next size and correctly formatting SRT/VTT color output 2016-07-22 06:46:11 -07:00
Abhinav Shukla
3a74381318 Modifying API call not present in tesseract 3.03 2016-07-21 16:13:59 -07:00
Abhinav Shukla
0fcf9298bb Merge remote-tracking branch 'upstream/master' into dvbcolor 2016-07-21 15:29:12 -07:00
Carlos Fernandez
c8bd4e22a5 Added missing library for OCR 2016-07-21 14:59:56 -07:00
Carlos Fernandez
a918bc2798 Added OCR to linux build script
Skip another to the SCTE 57 2003 sections in PMT
2016-07-21 14:56:17 -07:00
Abhinav Shukla
9d81498bd9 Moving tesseract handle to hardsubx ctx 2016-07-21 14:54:33 -07:00
Abhinav Shukla
a2eced9201 Color output in <font> tags for SRT and WebVTT 2016-07-20 12:08:42 -07:00
Abhinav Shukla
36b08c5d74 Working color detection and output for SRT from DVB 2016-07-19 19:25:46 -07:00
Abhinav Shukla
f280feff65 Passing DVB region background color 2016-07-16 06:16:42 -07:00
Abhinav Shukla
f37e944ac4 Fixed errors in word color recognition 2016-07-09 20:39:38 -07:00
Abhinav Shukla
cf281c22ce Detecting color of every word 2016-07-07 19:42:10 -07:00
Abhinav Shukla
4d8cb4d4d4 Creating copy of image before quantization 2016-07-07 15:15:59 -07:00
Abhinav Shukla
7426841b5e Basic structure for color detection in DVB 2016-07-07 04:00:20 -07:00
Abhinav Shukla
89efdb6178 Sauvola Binarization, color independent thresholding 2016-07-06 19:15:44 -07:00
Abhinav Shukla
a37a08ef70 Merge remote-tracking branch 'upstream/master' 2016-07-06 19:08:34 -07:00
Carlos Fernandez
db80caf74a - WebVTT from DVB
- Added X-TIMESTAMP-MAP to the WebVTT header
2016-07-06 12:18:40 -07:00
Carlos Fernandez
672010711d spung: Embedded OCR comments inside the spupng tags (instead of below), much more readable. 2016-07-05 15:20:28 -07:00
Carlos Fernandez
a4cea54db8 Passed CRLF to OCR 2016-07-05 14:48:54 -07:00
Carlos Fernandez
ddbf8124a8 Merge branch 'pr/n399_canihavesomecoffee' 2016-07-05 10:34:22 -07:00
canihavesomecoffee
5655db6cd2 Update Linux & Mac build
Update the Linux & Mac build to reflect the changes made for the version
file.
2016-07-05 18:10:19 +02:00
canihavesomecoffee
c764ced536 Update compile info 2016-07-05 18:05:44 +02:00
canihavesomecoffee
9f4bff884f Update build script for windows
-
2016-07-05 18:01:47 +02:00
canihavesomecoffee
b002d58259 Updates git ignore for new file
Add a git ignore for the "real" dynamic header file, remove the ignore
for the other one.
2016-07-05 17:57:47 +02:00
Anshul Maheshwari
bdf3f6d833 close #394 Illegal .srt being created from DVBs 2016-07-03 23:59:19 +05:30
Anshul Maheshwari
7f183193d5 resolve Tesseract fail cause spngpng to fail #391
Signed-off-by: Anshul Maheshwari <er.anshul.maheshwari@gmail.com>
2016-07-03 23:03:23 +05:30
Anshul Maheshwari
d3ae186f6b Merge remote-tracking branch 'origin/master' 2016-07-03 13:05:09 +05:30
Anshul Maheshwari
18cd92e5a8 close #397 Incorrect progress display 2016-07-03 13:04:17 +05:30
Abhinav Shukla
0e4281d4a2 Merge remote-tracking branch 'upstream/master' 2016-06-30 14:29:04 -07:00
Abhinav Shukla
7d19fa971d Setting up encoder 2016-06-30 14:19:50 -07:00
Anshul Maheshwari
a66c5aae06 Correcting y offset 2016-06-28 23:25:20 +05:30
Anshul Maheshwari
eea1792f0e Fix memory leakage in spupng
Signed-off-by: Anshul Maheshwari <er.anshul.maheshwari@gmail.com>
2016-06-27 00:54:44 +05:30
Anshul Maheshwari
e6bd773762 Fixing missing lines in spupng
Signed-off-by: Anshul Maheshwari <er.anshul.maheshwari@gmail.com>
2016-06-27 00:33:06 +05:30
Abhinav Shukla
98f1e15666 Limiting sutitle region to bottom 25% of the frame 2016-06-21 07:31:01 -07:00
Abhinav Shukla
c61e787bca Midterm evaluation - initial code 2016-06-21 06:48:10 -07:00
Abhinav Shukla
2dfa3778cb Added seeking to a frame at a particular time instead of linear iteration 2016-06-16 04:57:21 -07:00
Abhinav Shukla
d99dc4c6f8 Setting up binary neighbourhood search workflow and other helpers 2016-06-15 17:01:44 -07:00
Abhinav Shukla
8507a842be Added HSV colorspace conversion 2016-06-15 16:25:39 -07:00
Abhinav Shukla
8e5b9b2655 Merge remote-tracking branch 'upstream/master' 2016-06-14 12:02:08 -07:00
Abhinav Shukla
954724e12a Added vertical edge detection and morphology to get subtitle ROI 2016-06-14 11:59:10 -07:00
Carlos Fernandez
97dd511452 Merge branch 'pr/n390_rkuchumov' 2016-06-14 10:57:09 -07:00
Kuchumov Ruslan
93b1e64896 skipping redundant bytes at the end of tx3g atom 2016-06-14 09:44:35 +03:00
Carlos Fernandez
933dc50c62 Updates CHANGES.TXT 2016-06-13 12:00:46 -07:00
Kuchumov Ruslan
8b740f4af2 void atom hotfix 2016-06-12 19:59:22 +03:00
Abhinav Shukla
13db1dfbfa Fixing error with frame numbers of parsed packets, now parsing video only 2016-06-09 16:31:25 -07:00
Carlos Fernandez
03cd838ff4 Fixed some of the legit warnings from Visual Studio. 2016-06-09 14:16:37 -07:00
Abhishek Vinjamoori
c8aa7b17a7 Corrected initialisation of two variables related to stats 2016-06-09 23:56:01 +05:30
Carlos Fernandez
67fb6235f4 - Fix for signal support (for file rotation) in linux
- Add hack to ignore table_id=0xc0 (Program Information) in PMT without ignoring the full PMT.
2016-06-08 17:54:56 -07:00
Carlos Fernandez
7d5f8031ca Merge branch 'pr/n379_abhishek-vinjamoori' 2016-06-08 10:30:36 -07:00
canihavesomecoffee
b8eec82f2a Update file to copy necessary DLL to output folder
Updates the project file to copy the two DLL's after compiling, so that
we can run from that directory.
2016-06-08 02:50:23 +02:00
canihavesomecoffee
04be7be06b Add OCR build support
Adds OCR build support by creating two new build configs (one debug, one
release) and some instructions about what VS expects on those configs.
2016-06-08 02:25:13 +02:00
Abhishek Vinjamoori
b224b57a43 Added feature list to CHANGES.txt 2016-06-08 00:06:20 +05:30
Abhishek Vinjamoori
f764e23881 Corrected closing of files issue. 2016-06-07 23:55:25 +05:30
Abhishek Vinjamoori
8fefe8c1b3 Fixed memory issues caused by strdup. 2016-06-07 12:47:36 +05:30
Abhishek Vinjamoori
dd93e9d672 Corrected append parameter assignment 2016-06-07 01:27:48 +05:30
Abhishek Vinjamoori
7b69100de9 Changed append parameter into ccx_s_write struct 2016-06-07 00:26:46 +05:30
Abhishek Vinjamoori
9819dbe0c1 Merge remote-tracking branch 'upstream/master' into Rotation 2016-06-06 23:07:03 +05:30
Abhishek Vinjamoori
6a5bb8bab4 Corrected the conditional statement error. File always in create mode 2016-06-06 23:06:41 +05:30
Carlos Fernandez
48878185de Merge branch 'pr/n382_canihavesomecoffee' 2016-06-06 10:24:08 -07:00
Abhishek Vinjamoori
9c5d3cdde1 Added --append paramter for preventing overwriting of files. 2016-06-05 01:26:29 +05:30
canihavesomecoffee
6ea677cd7a Move debug statement to more appropriate location
Now shows reset count for every file switched instead of keeping it
once. Also closes #375
2016-06-04 20:42:18 +02:00
canihavesomecoffee
05e451d41e Rename ccextractor to ccextractorwin for compilation 2016-06-04 20:40:34 +02:00
Abhishek Vinjamoori
ff41c56e82 Removed string errors 2016-06-04 16:53:53 +05:30
Abhishek Vinjamoori
554c1077a0 Modified rotation renaming 2016-06-04 16:09:22 +05:30
Abhinav Shukla
bc40119b72 Basic text output 2016-06-03 12:55:56 -07:00
Abhinav Shukla
65587815ff Basic video frame processing with ffmpeg 2016-06-02 13:57:08 -07:00
Abhinav Shukla
c3eabcfd96 Setting up ffmpeg frame processing (-s in the Makefile to reduce executable size) 2016-06-01 17:37:58 -07:00
Abhishek Vinjamoori
fa563c6542 Removed another debugging statement 2016-06-01 13:26:40 +05:30
Abhishek Vinjamoori
7219f91648 Checked for errors and returning original encoder in such cases. Removed debug statements 2016-06-01 13:21:31 +05:30
Abhishek Vinjamoori
8d22988808 Modified a few parameters. Now feature works fine 2016-06-01 12:50:59 +05:30
Abhishek Vinjamoori
6f249c92d6 File rotation feature 2016-06-01 02:17:55 +05:30
Abhinav Shukla
204543af9a Setting up preliminary HardsubX context 2016-05-30 14:38:50 -07:00
Abhinav Shukla
c8345643c6 Adding HardsubX workflow 2016-05-30 10:44:55 -07:00
Carlos Fernandez
4a61570a50 On missing headers don't dump the payload by default. 2016-05-27 17:29:48 -07:00
Carlos Fernandez
57b060b15d Added -sem to CHANGES.TXT 2016-05-27 17:16:09 -07:00
Carlos Fernandez
c31b3e823f Add more details on "premature end of file" condition 2016-05-27 16:43:58 -07:00
Carlos Fernandez
5d3aa26cdc Detailed premature end of file error on cut TS 2016-05-27 12:16:27 -07:00
Carlos Fernandez
0b2e12ce0c Changed target to XP 2016-05-27 10:45:27 -07:00
Carlos Fernandez
3a6ed7a243 Added -sem to create a semaphore file when we have an open file so external tools won't move or delete files before they are ready. 2016-05-27 10:43:27 -07:00
Carlos Fernandez
2541666333 Merge branch 'pr/n372_canihavesomecoffee' 2016-05-26 15:11:49 -07:00
Abhinav Shukla
5bcb974b96 Fixes #353 - Memory consumption reduced by 180 MB 2016-05-26 14:37:02 -07:00
Abhinav Shukla
5c65ccc12b Fixing high memory usage 2016-05-26 13:23:10 -07:00
canihavesomecoffee
61ee4b25fe Fixing warnings
- Removed unused variables
- Renamed remainder variables to better name
- Moved sha256_buf to external to avoid C4127 warning
2016-05-26 10:40:19 +02:00
Carlos Fernandez
35017de391 Fix: For MP4 files on multiple inputs CCExtractor was processing always the first file (due to using a hardcoded 0) 2016-05-25 18:38:14 -07:00
Carlos Fernandez
5efe51720c Merge branch 'pr/n367_abhishek-vinjamoori' 2016-05-25 13:28:47 -07:00
canihavesomecoffee
410c39986b Gitignore remove blank line
-
2016-05-25 21:06:37 +02:00
canihavesomecoffee
928f57bd4c Small fix added
-
2016-05-25 20:59:27 +02:00
canihavesomecoffee
6b0e57f07d Update files to reflect upcoming .81
-
2016-05-25 20:58:42 +02:00
Abhishek Vinjamoori
111258d2f0 Removed EXIT variables 2016-05-25 22:26:14 +05:30
Carlos Fernandez
db1fab51f4 Merge branch 'pr/n351_abhishek-vinjamoori' 2016-05-25 08:11:17 -07:00
Abhishek Vinjamoori
04893f4347 Changed the return variable directly without checking 2016-05-25 11:21:52 +05:30
Abhinav Shukla
e1083a030c Removing debug print statement 2016-05-24 10:13:09 -07:00
Abhinav Shukla
fa373115ad Fixing wrong function prototype 2016-05-24 10:05:20 -07:00
Abhinav Shukla
4b8f14eab1 Fixes #139 - Case fixing in teletext 2016-05-24 09:36:49 -07:00
Abhishek Vinjamoori
653795ceef Fixes #315. Force File Buffer Flushing issue. 2016-05-23 23:23:14 +05:30
Abhishek Vinjamoori
115a6103d4 Completed the other statistics 2016-05-23 17:59:49 +05:30
canihavesomecoffee
a238352fb3 Changing file permissions (attempt 2) 2016-05-23 11:57:06 +02:00
canihavesomecoffee
1322f89fcd Fixes
- pre-build.sh executable by default now
- git ignore updated so the updated compile_info.h won't show up when
it's being changed after building CCExtractor
2016-05-23 11:52:46 +02:00
canihavesomecoffee
c1ec393bed Better small file fix
Not calculating every time, but once the file is opened, using existing
code.
2016-05-22 17:56:39 +02:00
canihavesomecoffee
243cd64d56 Merge remote-tracking branch 'CCExtractor/master' 2016-05-22 11:38:14 +02:00
canihavesomecoffee
e06be2d2f1 Manual implementation of York He Fix
-
2016-05-22 11:35:12 +02:00
Carlos Fernandez
8cfbf87420 Merge branch 'pr/n362_Abhinav95' 2016-05-22 01:30:12 -07:00
canihavesomecoffee
ff3be07df5 Add linux/mac build scripts
-
2016-05-22 09:44:55 +02:00
canihavesomecoffee
a0787e740e Add windows pre-build event
Updates the .h file that contains the build date & git commit hash (if
available)
2016-05-22 08:13:53 +02:00
canihavesomecoffee
e5b21a3a91 Adds --version parameter
Start of the --version parameter. Displays version & file hash already,
git commit & compilation date not yet finished.
2016-05-22 03:50:16 +02:00
canihavesomecoffee
f694c95510 Add hashing library and update makefiles
- Adds a open-source hashing lib for SHA2 (SHA-256, SHA-386, SHA-512)
from http://www.aarongifford.com/computers/sha.html, with some small
modifications to make it work unders windows too
- Updates build commands to reflect this change
2016-05-22 03:49:31 +02:00
canihavesomecoffee
b5731a279a Add compile info header
Will be used to show compilation date & git commit if they're available
2016-05-22 03:47:17 +02:00
canihavesomecoffee
6bb86efa97 Add VS extension to gitignore 2016-05-22 03:45:53 +02:00
Abhinav Shukla
c54027562f Updating CHANGES.txt 2016-05-21 14:42:46 -07:00
Abhinav Shukla
a2163adc95 Merge remote-tracking branch 'upstream/master' 2016-05-21 14:00:57 -07:00
Abhinav Shukla
73c35ccb30 Correcting display of sub mode and info in transcripts 2016-05-21 13:59:27 -07:00
Carlos Fernandez
bcfdda5f8d Merge branch 'pr/n357_gshruti95' 2016-05-20 19:06:52 -07:00
Abhinav Shukla
1dd5e3089c Fix #359 - Teletext page number in -ucla 2016-05-19 12:06:58 -07:00
Shruti
74c1d6d30d Fixes #354 : Excessive XDS notices 2016-05-10 19:55:47 +05:30
Shruti
0579d7d8d7 Fixes #354 : Excessive XDS notices 2016-05-10 19:51:08 +05:30
Shruti
1d31c784e7 Fixes #354 : Excessive XDS notices 2016-05-10 19:50:16 +05:30
David Liontooth
b385fa74b0 Update build.command
Include zvbi to fix #346
2016-04-16 16:17:47 -07:00
108 changed files with 12958 additions and 1039 deletions

15
.gitignore vendored
View File

@@ -9,8 +9,8 @@ CVS
*.o
linux/ccextractor
linux/depend
windows/debug/**
windows/release/**
windows/Debug/**
windows/Release/**
build/
####
@@ -20,3 +20,14 @@ build/
*.sdf
*.opensdf
*.user
*.opendb
####
# Ignore the header file that is updated upon build
src/lib_ccx/compile_info_real.h
#### Ignore windows OCR libraries and folders
windows/libs/leptonica/**
windows/libs/tesseract/**
windows/Release-OCR/**
windows/Debug-OCR/**

View File

@@ -6,7 +6,7 @@ Carlos' version (mainstream) is the most stable branch.
Extracting subtitles has never been so easy. Just type the following command:
ccextractor "name of input"
Gui lovers should download the Sorceforge version of CCExtractor, the Git Version is not your cup of tea.
GUI lovers should download the Sourceforge version of CCExtractor, the Git Version is not your cup of tea.
http://ccextractor.sourceforge.net/download-ccextractor.html
For News about release, please find CHANGES.TXT

View File

@@ -1,3 +1,51 @@
0.82(2016-08-15)
-----------------
- New: HardsubX - Burned in subtitle extraction subsystem.
- New: Color Detection in DVB Subtitles
- Fix: Corrected sentence capitalization
- Fix: Skipping redundant bytes at the end of tx3g atom in MP4
- Fix: Illegal SRT files being created from DVB subtitles
- Fix: Incorrect Progress Display
0.81 (2016-06-13)
-----------------
- New: --version parameter for extensive version information (version number, compile date, executable hash, git commit (if appropriate))
- New: Add -sem (semaphore) to create a .sem file when an output file is open and delete it when it's closed.
- New: Add --append parameter. This will prevent overwriting of existing files.
- New: File Rotation support added. The user has to send a USR1 signal to rotate.
- Fix: Issues with files <1 Mb
- Fix: Preview of generated transcript.
- Fix: Statistics were not generated anymore.
- Fix: Correcting display of sub mode and info in transcripts.
- Fix: Teletext page number displayed in -UCLA.
- Fix: Removal of excessive XDS notices about aspect ratio info.
- Fix: Force Flushing of file buffers works for all files now.
- Fix: mp4 void atoms that was causing some .mp4 files to fail.
- Fix: Memory usage caused by EPG processing was high due to many non-dynamic buffers.
- Fix: Project files for Visual Studio now include OCR support in Windows.
0.80 (2016-04-24)
-----------------
- Fix: "Premature end of file" (one of the scenarios)
- Fix: XDS data is always parsed again (needed to extract information such as program name)
- Fix: Teletext parsing: @ was incorrectly exported as * - X/26 packet specifications in ETS 300 706 v1.2.1 now better followed
- Fix: Teletext parsing: Latin G2 subsets and accented characters not displaying properly
- Fix: Timing in -ucla
- Fix: Timing in ISDB (some instances)
- Fix: "mfra" mp4 box weight changed to 1 (this helps with correct file format detection)
- Fix: Fix for TARGET File is null.
- Fix: Fixed SegFaults while parsing parameters (if mandatory parameter is not present in -outinterval, -codec or -nocodec)
- Fix: Crash when input small is too small
- Fix: Update some URLs in code (references to docs)
- Fix: -delay now updates final timestamp in ISDB, too
- Fix: Removed minor compiler warnings
- Fix: Visual Studio solution files working again
- Fix: ffmpeg integration working again
- New: Added --forceflush (-ff). If used, output file descriptors will be flushed immediately after being written to
- New: Hexdump XDS packets that we cannot parse (shouldn't be many of those anyway)
- New: If input file cannot be open, provide a decent human readable explanation
- New: GXF support
0.79 (2016-01-09)
-----------------
- Support for Grid Format (g608)

45
docs/HARDSUBX.txt Normal file
View File

@@ -0,0 +1,45 @@
Overview
========
Subtitles which are burned into the video (or hard subbed) can be extracted using the -hardsubx flag.
The system works by processing video frames and extracting only the subtitles from them, followed
by an OCR recognition using Tesseract.
Dependencies
============
Tesseract (OCR library by Google)
Leptonica (C Image processing library)
FFMpeg (Video Processing Library)
Compilation
===========
Linux
-----
Make sure Tesseract, Leptonica and FFMPeg are installed, and that their libraries can be found using pkg-config.
Refer to OCR.txt for installation details.
To install FFmpeg (libav), follow the steps at:-
https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu - For Ubuntu, Debian and Linux Mint
https://trac.ffmpeg.org/wiki/CompilationGuide/Generic - For generic Linux compilation
To validate your FFMpeg installation, make sure you can run the following commands on your terminal:-
pkg-config --cflags libavcodec
pkg-config --cflags libavformat
pkg-config --cflags libavutil
pkg-config --cflags libswscale
pkg-config --libs libavcodec
pkg-config --libs libavformat
pkg-config --libs libavutil
pkg-config --libs libswscale
On success, you should see the correct include directory path and the linker flags.
To build the program with hardsubx support, from the linux directory run:-
make ENABLE_HARDSUBX=yes
Windows
-------
Coming Soon

View File

@@ -1,4 +1,4 @@
ccextractor, 0.79
ccextractor, 0.81
-----------------
Authors: Carlos Fernández (cfsmp3), Volker Quetschke.
Maintainer: cfsmp3
@@ -14,12 +14,12 @@ You can subscribe to new releases notifications at freshmeat:
http://freshmeat.net/projects/ccextractor
Google Summer of Code 2014 students
- Willem van iseghem
- Willem Van Iseghem
- Ruslan KuchumoV
- Anshul Maheshwari
Google Summer of Code 2015 students
- Willem van iseghem
- Willem Van Iseghem
- Ruslan Kuchumov
- Anshul Maheshwari
- Nurendra Choudhary

View File

@@ -2,10 +2,10 @@ SHELL = /bin/sh
CC = gcc
SYS := $(shell gcc -dumpmachine)
CFLAGS = -O3 -std=gnu99
INCLUDE = -I../src/gpacmp4/ -I../src/libpng -I../src/zlib -I../src/lib_ccx -I../src/.
CFLAGS = -O3 -std=gnu99 -s
INCLUDE = -I../src/gpacmp4/ -I../src/libpng -I../src/lib_hash -I../src/zlib -I../src/lib_ccx -I../src/.
INCLUDE += -I../src/zvbi
ALL_FLAGS = -Wno-write-strings -D_FILE_OFFSET_BITS=64
ALL_FLAGS = -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT
LDFLAGS = -lm
ifneq (, $(findstring linux, $(SYS)))
@@ -14,7 +14,7 @@ endif
TARGET = ccextractor
OBJS_DIR = objs
VPATH = ../src:../src/gpacmp4:../src/libpng:../src/zlib:../src/lib_ccx:../src/zvbi
VPATH = ../src:../src/gpacmp4:../src/libpng:../src/zlib:../src/lib_ccx:../src/zvbi:../src/lib_hash
SRCS_DIR = ../src
SRCS_C = $(wildcard $(SRCS_DIR)/*.c)
@@ -42,10 +42,33 @@ SRCS_ZLIB_DIR = $(SRCS_DIR)/zlib
SRCS_ZLIB = $(wildcard $(SRCS_ZLIB_DIR)/*.c)
OBJS_ZLIB = $(SRCS_ZLIB:$(SRCS_ZLIB_DIR)/%.c=$(OBJS_DIR)/%.o)
SRCS_HASH_DIR = $(SRCS_DIR)/lib_hash
SRCS_HASH = $(wildcard $(SRCS_HASH_DIR)/*.c)
OBJS_HASH = $(SRCS_HASH:$(SRCS_HASH_DIR)/%.c=$(OBJS_DIR)/%.o)
INSTLALL = cp -f -p
INSTLALL_PROGRAM = $(INSTLALL)
DESTDIR = /usr/bin
ifeq ($(ENABLE_HARDSUBX),yes)
ENABLE_OCR=yes
CFLAGS+=-DENABLE_HARDSUBX
CFLAGS+= $(shell pkg-config --cflags libavcodec)
CFLAGS+= $(shell pkg-config --cflags libavformat)
CFLAGS+= $(shell pkg-config --cflags libavutil)
CFLAGS+= $(shell pkg-config --cflags libswscale)
AV_LDFLAGS+= $(shell pkg-config --libs libavcodec )
AV_LDFLAGS+= $(shell pkg-config --libs libavformat )
AV_LDFLAGS+= $(shell pkg-config --libs libavutil )
AV_LDFLAGS+= $(shell pkg-config --libs libswscale )
ifeq ($(AV_LDFLAGS),$(EMPTY))
$(error **ERROR** "libav not found")
else
$(info "libav found")
endif
LDFLAGS+= $(AV_LDFLAGS)
endif
ifeq ($(ENABLE_OCR),yes)
CFLAGS+=-DENABLE_OCR -DPNG_NO_CONFIG_H
TESS_LDFLAGS+= $(shell pkg-config --libs tesseract)
@@ -83,14 +106,14 @@ LDFLAGS+= $(shell pkg-config --libs libavutil )
endif
.PHONY: all
all: objs_dir $(TARGET)
all: pre-build objs_dir $(TARGET)
.PHONY: objs_dir
objs_dir:
mkdir -p $(OBJS_DIR)
$(TARGET): $(OBJS) $(OBJS_PNG) $(OBJS_GPACMP4) $(OBJS_ZVBI) $(OBJS_ZLIB) $(OBJS_CCX)
$(CC) $(ALL_FLAGS) $(CFLAGS) $(OBJS) $(OBJS_CCX) $(OBJS_PNG) $(OBJS_ZVBI) $(OBJS_GPACMP4) $(OBJS_ZLIB) $(LDFLAGS) -o $@
$(TARGET): $(OBJS) $(OBJS_PNG) $(OBJS_GPACMP4) $(OBJS_ZVBI) $(OBJS_ZLIB) $(OBJS_HASH) $(OBJS_CCX)
$(CC) $(ALL_FLAGS) $(CFLAGS) $(OBJS) $(OBJS_CCX) $(OBJS_PNG) $(OBJS_ZVBI) $(OBJS_GPACMP4) $(OBJS_ZLIB) $(OBJS_HASH) $(LDFLAGS) -o $@
$(OBJS_DIR)/%.o: %.c
$(CC) -c $(ALL_FLAGS) $(INCLUDE) $(CFLAGS) $< -o $@
@@ -104,7 +127,7 @@ $(OBJS_DIR)/ccextractor.o: ccextractor.c
.PHONY: clean
clean:
rm -rf $(TARGET) 2>/dev/null || true
rm -rf $(OBJS_CCX) $(OBJS_PNG) $(OBJS_ZLIB) $(OBJS_GPACMP4) $(OBJS) 2>/dev/null || true
rm -rf $(OBJS_CCX) $(OBJS_PNG) $(OBJS_ZLIB) $(OBJS_GPACMP4) $(OBJS_HASH) $(OBJS) 2>/dev/null || true
rm -rdf $(OBJS_DIR) 2>/dev/null || true
rm -rf .depend 2>/dev/null || true
@@ -118,8 +141,12 @@ uninstall:
.PHONY: depend dep
depend dep:
$(CC) $(CFLAGS) $(INCLUDE) -E -MM $(SRCS_C) $(SRCS_PNG) $(SRCS_ZVBI) $(SRCS_ZLIB) $(SRCS_CCX) \
$(CC) $(CFLAGS) $(INCLUDE) -E -MM $(SRCS_C) $(SRCS_PNG) $(SRCS_ZVBI) $(SRCS_ZLIB) $(SRCS_HASH) $(SRCS_CCX) \
$(SRCS_GPACMP4_C) $(SRCS_GPACMP4_CPP) |\
sed 's/^[a-zA-Z_0-9]*.o/$(OBJS_DIR)\/&/' > .depend
.PHONY: pre-build
pre-build:
./pre-build.sh
-include .depend

View File

@@ -1,12 +1,14 @@
#!/bin/bash
BLD_FLAGS="-std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64"
BLD_INCLUDE="-I../src/lib_ccx/ -I../src/gpacmp4/ -I../src/libpng/ -I../src/zlib/ -I../src/zvbi"
BLD_FLAGS="-g -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR"
BLD_INCLUDE="-I /usr/include/leptonica/ -I /usr/include/tesseract/ -I../src/lib_ccx/ -I../src/gpacmp4/ -I../src/libpng/ -I../src/zlib/ -I../src/zvbi -I../src/lib_hash"
SRC_LIBPNG="$(find ../src/libpng/ -name '*.c')"
SRC_ZLIB="$(find ../src/zlib/ -name '*.c')"
SRC_ZVBI="$(find ../src/zvbi/ -name '*.c')"
SRC_CCX="$(find ../src/lib_ccx/ -name '*.c')"
SRC_GPAC="$(find ../src/gpacmp4/ -name '*.c')"
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZLIB $SRC_ZVBI $SRC_LIBPNG"
BLD_LINKER="-lm -zmuldefs"
SRC_HASH="$(find ../src/lib_hash/ -name '*.c')"
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZLIB $SRC_ZVBI $SRC_LIBPNG $SRC_HASH"
BLD_LINKER="-lm -zmuldefs -l tesseract -l lept"
./pre-build.sh
gcc $BLD_FLAGS $BLD_INCLUDE -o ccextractor $BLD_SOURCES $BLD_LINKER

View File

@@ -1,12 +1,14 @@
#!/bin/bash
BLD_FLAGS="-g -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64"
BLD_INCLUDE="-I../src/lib_ccx/ -I../src/gpacmp4/ -I../src/libpng/ -I../src/zlib/ -I../src/zvbi"
BLD_FLAGS="-g -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT"
BLD_INCLUDE="-I../src/lib_ccx/ -I../src/gpacmp4/ -I../src/libpng/ -I../src/zlib/ -I../src/zvbi -I../src/lib_hash"
SRC_LIBPNG="$(find ../src/libpng/ -name '*.c')"
SRC_ZLIB="$(find ../src/zlib/ -name '*.c')"
SRC_ZVBI="$(find ../src/zvbi/ -name '*.c')"
SRC_CCX="$(find ../src/lib_ccx/ -name '*.c')"
SRC_GPAC="$(find ../src/gpacmp4/ -name '*.c')"
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZLIB $SRC_ZVBI $SRC_LIBPNG"
SRC_HASH="$(find ../src/lib_hash/ -name '*.c')"
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZLIB $SRC_ZVBI $SRC_LIBPNG $SRC_HASH"
BLD_LINKER="-lm -zmuldefs"
./pre-build.sh
gcc $BLD_FLAGS $BLD_INCLUDE -o ccextractor $BLD_SOURCES $BLD_LINKER

34
linux/pre-build.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
echo "Obtaining Git commit"
commit=(`git rev-parse HEAD 2>/dev/null`)
if [ -z "$commit" ]; then
echo "Git command not present, trying folder approach"
if [ -d "../.git" ]; then
echo "Git folder found, using HEAD file"
head="`cat ../.git/HEAD`"
ref_pos=(`expr match "$head" 'ref: '`)
if [ $ref_pos -eq 5 ]; then
echo "HEAD file contains a ref, following"
commit=(`cat "../.git/${head:5}"`)
echo "Extracted commit: $commit"
else
echo "HEAD contains a commit, using it"
commit="$head"
echo "Extracted commit: $commit"
fi
fi
fi
if [ -z "$commit" ]; then
commit="Unknown"
fi
builddate=`date +%Y-%m-%d`
echo "Storing variables in file"
echo "Commit: $commit"
echo "Date: $builddate"
echo "#ifndef CCX_CCEXTRACTOR_COMPILE_REAL_H" > ../src/lib_ccx/compile_info_real.h
echo "#define CCX_CCEXTRACTOR_COMPILE_REAL_H" >> ../src/lib_ccx/compile_info_real.h
echo "#define GIT_COMMIT \"$commit\"" >> ../src/lib_ccx/compile_info_real.h
echo "#define COMPILE_DATE \"$builddate\"" >> ../src/lib_ccx/compile_info_real.h
echo "#endif" >> ../src/lib_ccx/compile_info_real.h
echo "Stored all in compile.h"
echo "Done."

View File

@@ -1,12 +1,17 @@
#!/bin/bash
cd `dirname $0`
BLD_FLAGS="-std=gnu99 -Wno-write-strings -DGPAC_CONFIG_DARWIN -D_FILE_OFFSET_BITS=64 -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek"
BLD_INCLUDE="-I../src/lib_ccx/ -I../src/gpacmp4/ -I../src/libpng/ -I../src/zlib/"
SRC_LIBPNG="$(find ../src/libpng/ -name '*.c')"
SRC_ZLIB="$(find ../src/zlib/ -name '*.c')"
SRC_CCX="$(find ../src/lib_ccx/ -name '*.c')"
SRC_GPAC="$(find ../src/gpacmp4/ -name '*.c')"
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZLIB $SRC_LIBPNG"
BLD_FLAGS="-std=gnu99 -Wno-write-strings -DGPAC_CONFIG_DARWIN -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek"
BLD_INCLUDE="-I../src/lib_ccx -I../src/gpacmp4 -I../src/libpng -I../src/zlib -I../src/zvbi -I../src/lib_hash"
SRC_LIBPNG="$(find ../src/libpng -name '*.c')"
SRC_ZLIB="$(find ../src/zlib -name '*.c')"
SRC_ZVBI="$(find ../src/zvbi -name '*.c')"
SRC_CCX="$(find ../src/lib_ccx -name '*.c')"
SRC_GPAC="$(find ../src/gpacmp4 -name '*.c')"
SRC_LIB_HASH="$(find ../src/lib_hash -name '*.c')"
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZVBI $SRC_ZLIB $SRC_LIBPNG $SRC_LIB_HASH"
BLD_LINKER="-lm -liconv"
./pre-build.sh
gcc $BLD_FLAGS $BLD_INCLUDE -o ccextractor $BLD_SOURCES $BLD_LINKER

34
mac/pre-build.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
echo "Obtaining Git commit"
commit=(`git rev-parse HEAD 2>/dev/null`)
if [ -z "$commit" ]; then
echo "Git command not present, trying folder approach"
if [ -d "../.git" ]; then
echo "Git folder found, using HEAD file"
head="`cat ../.git/HEAD`"
ref_pos=(`expr match "$head" 'ref: '`)
if [ $ref_pos -eq 5 ]; then
echo "HEAD file contains a ref, following"
commit=(`cat "../.git/${head:5}"`)
echo "Extracted commit: $commit"
else
echo "HEAD contains a commit, using it"
commit="$head"
echo "Extracted commit: $commit"
fi
fi
fi
if [ -z "$commit" ]; then
commit="Unknown"
fi
builddate=`date +%Y-%m-%d`
echo "Storing variables in file"
echo "Commit: $commit"
echo "Date: $builddate"
echo "#ifndef CCX_CCEXTRACTOR_COMPILE_REAL_H" > ../src/lib_ccx/compile_info_real.h
echo "#define CCX_CCEXTRACTOR_COMPILE_REAL_H" >> ../src/lib_ccx/compile_info_real.h
echo "#define GIT_COMMIT \"$commit\"" >> ../src/lib_ccx/compile_info_real.h
echo "#define COMPILE_DATE \"$builddate\"" >> ../src/lib_ccx/compile_info_real.h
echo "#endif" >> ../src/lib_ccx/compile_info_real.h
echo "Stored all in compile.h"
echo "Done."

View File

@@ -10,6 +10,7 @@ License: GPL 2.0
#include <signal.h>
#include "ccx_common_option.h"
#include "ccx_mp4.h"
#include "hardsubx.h"
struct lib_ccx_ctx *signal_ctx;
void sigint_handler()
@@ -45,6 +46,14 @@ int main(int argc, char *argv[])
{
exit(ret);
}
#ifdef ENABLE_HARDSUBX
if(ccx_options.hardsubx)
{
// Perform burned in subtitle extraction
hardsubx(&ccx_options);
return 0;
}
#endif
// Initialize libraries
ctx = init_libraries(&ccx_options);
if (!ctx && errno == ENOMEM)
@@ -105,8 +114,8 @@ int main(int argc, char *argv[])
#ifndef _WIN32
signal_ctx = ctx;
m_signal(SIGINT, sigint_handler);
create_signal();
#endif
while (switch_to_next_file(ctx, 0))
{
prepare_for_new_file(ctx);
@@ -167,7 +176,7 @@ int main(int argc, char *argv[])
case CCX_SM_MP4:
mprint ("\rAnalyzing data with GPAC (MP4 library)\n");
close_input_file(ctx); // No need to have it open. GPAC will do it for us
processmp4 (ctx, &ctx->mp4_cfg, ctx->inputfile[0]);
processmp4(ctx, &ctx->mp4_cfg, ctx->inputfile[ctx->current_file]);
if (ccx_options.print_file_reports)
print_file_report(ctx);
break;
@@ -270,7 +279,7 @@ int main(int argc, char *argv[])
+(LLONG) ((dec_ctx->frames_since_last_gop)*1000/29.97)) );
}
/* if (dec_ctx->false_pict_header)
if (dec_ctx->false_pict_header)
mprint ("\nNumber of likely false picture headers (discarded): %d\n",dec_ctx->false_pict_header);
if (dec_ctx->stat_numuserheaders)
@@ -294,7 +303,7 @@ int main(int argc, char *argv[])
mprint("\n\nNOTE! The CEA 608 / Divicom standard encoding for closed\n");
mprint("caption is not well understood!\n\n");
mprint("Please submit samples to the developers.\n\n\n");
}*/
}
}
@@ -322,7 +331,6 @@ int main(int argc, char *argv[])
s1, s2);
}
#endif
dbg_print(CCX_DMT_708, "[CEA-708] The 708 decoder was reset [%d] times.\n", ctx->freport.data_from_708->reset_count);
if (is_decoder_processed_enough(ctx) == CCX_TRUE)
{

View File

@@ -417,9 +417,18 @@ GF_Err tx3g_Read(GF_Box *s, GF_BitStream *bs)
ptr->size -= 18 + GPP_BOX_SIZE + GPP_STYLE_SIZE;
while (ptr->size) {
if (ptr->size < 8) {
/* Sometimes there are void atoms at the end of an atom and they are not parsed correctecly */
/* So just skip them if we have less than 8 bytes to parse */
/* "The actual size of an atom cannot be less than 8 bytes" from QTFF specs */
ptr->size = 0;
return GF_OK;
}
e = gf_isom_parse_box(&a, bs);
if (e) return e;
if (ptr->size<a->size) return GF_ISOM_INVALID_FILE;
ptr->size -= a->size;
if (a->type==GF_ISOM_BOX_TYPE_FTAB) {
if (ptr->font_table) gf_isom_box_del((GF_Box *) ptr->font_table);

View File

@@ -102,7 +102,7 @@ proceed_box:
}
//handle large box
if (size == 1) {
if (size == 1 && type != GF_ISOM_BOX_TYPE_VOID) {
size = gf_bs_read_u64(bs);
hdr_size += 8;
}

View File

@@ -130,9 +130,104 @@ enum
*/
const char *language[NB_LANGUAGE] =
{
"und",
"eng",
"fin",
"spa",
/*0*/"und", //Undefined
/*1*/"eng",
/*2*/"afr",
/*3*/"amh",
/*4*/"ara",
/*5*/"asm",
/*6*/"aze",
/*7*/"bel",
/*8*/"ben",
/*9*/"bod",
/*10*/"bos",
/*11*/"bul",
/*12*/"cat",
/*13*/"ceb",
/*14*/"ces",
/*15*/"chs",
/*16*/"chi",
/*17*/"chr",
/*18*/"cym",
/*19*/"dan",
/*20*/"deu",
/*21*/"dzo",
/*22*/"ell",
/*23*/"enm",
/*24*/"epo",
/*25*/"equ",
/*26*/"est",
/*27*/"eus",
/*28*/"fas",
/*29*/"fin",
/*30*/"fra",
/*31*/"frk",
/*32*/"frm",
/*33*/"gle",
/*34*/"glg",
/*35*/"grc",
/*36*/"guj",
/*37*/"hat",
/*38*/"heb",
/*39*/"hin",
/*40*/"hrv",
/*41*/"hun",
/*42*/"iku",
/*43*/"ind",
/*44*/"isl",
/*45*/"ita",
/*46*/"jav",
/*47*/"jpn",
/*48*/"kan",
/*49*/"kat",
/*50*/"kaz",
/*51*/"khm",
/*52*/"kir",
/*53*/"kor",
/*54*/"kur",
/*55*/"lao",
/*56*/"lat",
/*57*/"lav",
/*58*/"lit",
/*59*/"mal",
/*60*/"mar",
/*61*/"mkd",
/*62*/"mlt",
/*63*/"msa",
/*64*/"mya",
/*65*/"nep",
/*66*/"nld",
/*67*/"nor",
/*68*/"ori",
/*69*/"osd",
/*70*/"pan",
/*71*/"pol",
/*72*/"por",
/*73*/"pus",
/*74*/"ron",
/*75*/"rus",
/*76*/"san",
/*77*/"sin",
/*78*/"slk",
/*79*/"slv",
/*80*/"spa",
/*81*/"sqi",
/*82*/"srp",
/*83*/"swa",
/*84*/"swe",
/*85*/"syr",
/*86*/"tam",
/*87*/"tel",
/*88*/"tgk",
/*89*/"tgl",
/*90*/"tha",
/*91*/"tir",
/*92*/"tur",
/*93*/"uig",
/*94*/"ukr",
/*95*/"urd",
/*96*/"uzb",
/*97*/"vie",
/*98*/"yid",
NULL
};

View File

@@ -289,7 +289,7 @@ enum cdp_section_type
#define CCX_TXT_AUTO_NOT_YET_FOUND 1
#define CCX_TXT_IN_USE 2 // Positive autodetected, or forced, etc
#define NB_LANGUAGE 5
#define NB_LANGUAGE 100
extern const char *language[NB_LANGUAGE];
#define DEF_VAL_STARTCREDITSNOTBEFORE "0"

View File

@@ -56,8 +56,22 @@ void init_options (struct ccx_s_options *options)
options->xmltvoutputinterval=0; // interval in seconds between writting xmltv full file output
options->xmltvonlycurrent=0; // 0 off 1 on
options->keep_output_closed = 0; // By default just keep the file open.
options->force_flush = 0; // Don't flush whenever content is writtern.
options->force_flush = 0; // Don't flush whenever content is written.
options->append_mode = 0; //By default, files are overwritten.
options->ucla = 0; // By default, -UCLA not used
options->hardsubx = 0; // By default, don't try to extract hard subtitles
options->dvbcolor = 0; // By default, only text detected in DVB
options->dvblang = NULL; // By default, autodetect DVB language
options->ocrlang = NULL; // By default, autodetect .traineddata file
/*HardsubX related stuff*/
options->hardsubx_ocr_mode = 0;
options->hardsubx_subcolor = 0;
options->hardsubx_min_sub_duration = 0.5;
options->hardsubx_detect_italics = 0;
options->hardsubx_conf_thresh = 0.0;
options->hardsubx_hue = 0.0;
options->hardsubx_lum_thresh = 95.0;
options->transcript_settings = ccx_encoders_default_transcript_settings;
options->millis_separator=',';
@@ -108,6 +122,7 @@ void init_options (struct ccx_s_options *options)
options->enc_cfg.no_bom = 0; // Use BOM by default.
options->enc_cfg.services_charsets = NULL;
options->enc_cfg.all_services_charset = NULL;
options->enc_cfg.with_semaphore = 0;
options->settings_dtvcc.enabled = 0;
options->settings_dtvcc.active_services_count = 0;

View File

@@ -36,6 +36,7 @@ struct encoder_cfg
enum ccx_output_format write_format; // 0=Raw, 1=srt, 2=SMI
int keep_output_closed;
int force_flush; // Force flush on content write
int append_mode; //Append mode for output files
int ucla; // 1 if -UCLA used, 0 if not
enum ccx_encoding_type encoding;
@@ -44,6 +45,7 @@ struct encoder_cfg
int autodash; // Add dashes (-) before each speaker automatically?
int trim_subs; // " Remove spaces at sides? "
int sentence_cap ; // FIX CASE? = Fix case?
int with_semaphore; // Write a .sem file on file open and delete it on close?
/* Credit stuff */
char *start_credits_text;
char *end_credits_text;
@@ -116,7 +118,21 @@ struct ccx_s_options // Options from user parameters
int xmltvonlycurrent; // 0 off 1 on
int keep_output_closed;
int force_flush; // Force flush on content write
int append_mode; //Append mode for output files
int ucla; // 1 if UCLA used, 0 if not
int hardsubx; // 1 if burned-in subtitles to be extracted
int dvbcolor; // 1 if Color to be detected for DVB
char *dvblang; // The name of the language stream for DVB
char *ocrlang; // The name of the .traineddata file to be loaded with tesseract
/*HardsubX related stuff*/
int hardsubx_ocr_mode;
int hardsubx_subcolor;
float hardsubx_min_sub_duration;
int hardsubx_detect_italics;
float hardsubx_conf_thresh;
float hardsubx_hue;
float hardsubx_lum_thresh;
ccx_encoders_transcript_format transcript_settings; // Keeps the settings for generating transcript output files.
enum ccx_output_date_format date_format;

View File

@@ -55,6 +55,9 @@ struct ccx_common_timing_ctx *init_timing_ctx(struct ccx_common_timing_settings_
ctx->max_pts = 0;
ctx->sync_pts = 0;
ctx->minimum_fts = 0;
ctx->sync_pts2fts_set = 0;
ctx->sync_pts2fts_fts = 0;
ctx->sync_pts2fts_pts = 0;
ctx->fts_now = 0; // Time stamp of current file (w/ fts_offset, w/o fts_global)
ctx->fts_offset = 0; // Time before first sync_pts
@@ -175,6 +178,7 @@ int set_fts(struct ccx_common_timing_ctx *ctx)
// Start counting again from here
ctx->pts_set = 1; // Force min to be set again
ctx->sync_pts2fts_set = 0; // Make note of the new conversion values
// Avoid next async test - the gap might have occured on
// current_tref != 0.
@@ -208,6 +212,12 @@ int set_fts(struct ccx_common_timing_ctx *ctx)
// If pts_set is TRUE we have min_pts
ctx->fts_now = (LLONG)((ctx->current_pts - ctx->min_pts)/(MPEG_CLOCK_FREQ/1000)
+ ctx->fts_offset);
if (!ctx->sync_pts2fts_set)
{
ctx->sync_pts2fts_pts = ctx->current_pts;
ctx->sync_pts2fts_fts = ctx->fts_now;
ctx->sync_pts2fts_set = 1;
}
}
else
{

View File

@@ -46,6 +46,9 @@ struct ccx_common_timing_ctx
LLONG fts_fc_offset; // Time before first GOP
LLONG fts_max; // Remember the maximum fts that we saw in current file
LLONG fts_global; // Duration of previous files (-ve mode)
int sync_pts2fts_set; //0 = No, 1 = Yes
LLONG sync_pts2fts_fts;
LLONG sync_pts2fts_pts;
};
// Count 608 (per field) and 708 blocks since last set_fts() call
extern int cb_field1, cb_field2, cb_708;

View File

@@ -285,9 +285,10 @@ struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *set
ctx->max_gop_length = 0;
ctx->has_ccdata_buffered = 0;
ctx->in_bufferdatatype = CCX_UNKNOWN;
ctx->frames_since_last_gop = 0;
/* ctx->stat_numuserheaders = 0;
ctx->frames_since_last_gop = 0;
ctx->total_pulldownfields = 0;
ctx->total_pulldownframes = 0;
ctx->stat_numuserheaders = 0;
ctx->stat_dvdccheaders = 0;
ctx->stat_scte20ccheaders = 0;
ctx->stat_replay5000headers = 0;
@@ -295,7 +296,7 @@ struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *set
ctx->stat_dishheaders = 0;
ctx->stat_hdtv = 0;
ctx->stat_divicom = 0;
ctx->false_pict_header = 0;*/
ctx->false_pict_header = 0;
memcpy(&ctx->extraction_start, &setting->extraction_start,sizeof(struct ccx_boundary_time));
memcpy(&ctx->extraction_end, &setting->extraction_end,sizeof(struct ccx_boundary_time));

View File

@@ -373,6 +373,7 @@ static int reserve_buf(struct ISDBText *text, size_t len)
text->buf = ptr;
text->len = blen;
isdb_log ("expanded ctx->text(%lu)\n", blen);
return CCX_OK;
}
static int append_char(ISDBSubContext *ctx, const char ch)

View File

@@ -167,7 +167,7 @@ struct lib_cc_decode
unsigned top_field_first; // Needs to be global
/* Stats. Modified in es_userdata.c*/
/* int stat_numuserheaders;
int stat_numuserheaders;
int stat_dvdccheaders;
int stat_scte20ccheaders;
int stat_replay5000headers;
@@ -175,7 +175,7 @@ struct lib_cc_decode
int stat_dishheaders;
int stat_hdtv;
int stat_divicom;
int false_pict_header;*/
int false_pict_header;
ccx_dtvcc_ctx *dtvcc;
int current_field;

View File

@@ -116,6 +116,9 @@ typedef struct ccx_decoders_xds_context
int cur_xds_packet_type;
struct ccx_common_timing_ctx *timing;
unsigned current_ar_start;
unsigned current_ar_end;
int xds_write_to_file; // Set to 1 if XDS data is to be written to file
} ccx_decoders_xds_context_t;
@@ -704,6 +707,7 @@ int xds_do_current_and_future (struct cc_subtitle *sub, struct ccx_decoders_xds_
case XDS_TYPE_ASPECT_RATIO_INFO:
{
unsigned ar_start, ar_end;
int changed = 0;
was_proc = 1;
if (ctx->cur_xds_payload_length < 5) // We need 2 data bytes
break;
@@ -716,8 +720,20 @@ int xds_do_current_and_future (struct cc_subtitle *sub, struct ccx_decoders_xds_
ar_end = 262 - (ctx->cur_xds_payload[3] & 0x1F);
unsigned active_picture_height = ar_end - ar_start;
float aspect_ratio = (float) 320 / active_picture_height;
ccx_common_logging.log_ftn("\rXDS Notice: Aspect ratio info, start line=%u, end line=%u\n", ar_start,ar_end);
ccx_common_logging.log_ftn("\rXDS Notice: Aspect ratio info, active picture height=%u, ratio=%f\n", active_picture_height, aspect_ratio);
if (ar_start != ctx->current_ar_start)
{
ctx->current_ar_start = ar_start;
ctx->current_ar_end = ar_end;
changed = 1;
ccx_common_logging.log_ftn("\rXDS Notice: Aspect ratio info, start line=%u, end line=%u\n", ar_start, ar_end);
ccx_common_logging.log_ftn("\rXDS Notice: Aspect ratio info, active picture height=%u, ratio=%f\n", active_picture_height, aspect_ratio);
}
else
{
ccx_common_logging.debug_ftn(CCX_DMT_DECODER_XDS, "\rXDS Notice: Aspect ratio info, start line=%u, end line=%u\n", ar_start, ar_end);
ccx_common_logging.debug_ftn(CCX_DMT_DECODER_XDS, "\rXDS Notice: Aspect ratio info, active picture height=%u, ratio=%f\n", active_picture_height, aspect_ratio);
}
}
case XDS_TYPE_PROGRAM_DESC_1:

View File

@@ -168,7 +168,7 @@ static int ccx_demuxer_open(struct ccx_demuxer *ctx, const char *file)
{
case CCX_SM_ELEMENTARY_OR_NOT_FOUND:
case CCX_SM_PROGRAM:
if ( detect_myth(ctx->parent) )
if ( detect_myth(ctx) )
{
ctx->stream_mode=CCX_SM_MYTH;
}

View File

@@ -13,7 +13,7 @@
#ifdef WIN32
int fsync(int fd)
{
FlushFileBuffers(fd);
return FlushFileBuffers((HANDLE)_get_osfhandle(fd)) ? 0 : -1;
}
#endif
@@ -57,7 +57,7 @@ static const char *smptett_header = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
" <body>\n"
" <div>\n";
static const char *webvtt_header = "WEBVTT\r\n\r\n";
static const char *webvtt_header = "WEBVTT\r\n";
static const char *simple_xml_header = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<captions>\r\n";
@@ -552,7 +552,7 @@ int write_cc_subtitle_as_transcript(struct cc_subtitle *sub, struct encoder_ctx
if (context->sentence_cap)
{
//TODO capitalize (context, line_number,data);
//TODO correct_case(line_number, data);
//TODO correct_case_with_dictionary(line_number, data);
}
if (start_time == -1)
@@ -616,12 +616,15 @@ int write_cc_subtitle_as_transcript(struct cc_subtitle *sub, struct encoder_ctx
if(context->in_fileformat == 1)
//TODO, data->my_field == 1 ? data->channel : data->channel + 2); // Data from field 2 is CC3 or 4
fdprintf(context->out->fh, "CC?|");
else if (!context->ucla)
else if (!context->ucla || !strcmp(sub->mode,"TLT"))
fdprintf(context->out->fh, sub->info);
}
if (context->transcript_settings->showMode)
{
fdprintf(context->out->fh, "%s|", sub->mode);
if(context->ucla && strcmp(sub->mode,"TLT") == 0)
fdprintf(context->out->fh, "|");
else
fdprintf(context->out->fh, "%s|", sub->mode);
}
ret = write(context->out->fh, context->subline, length);
if(ret < length)
@@ -660,8 +663,8 @@ void write_cc_line_as_simplexml(struct eia608_screen *data, struct encoder_ctx *
char *cap1 = "</caption>";
if (context->sentence_cap)
{
capitalize (context, line_number, data);
correct_case(line_number, data);
if (clever_capitalize (context, line_number, data))
correct_case_with_dictionary(line_number, data);
}
length = get_str_basic (context->subline, data->characters[line_number],
context->trim_subs, CCX_ENC_ASCII, context->encoding, CCX_DECODER_608_SCREEN_WIDTH);
@@ -684,8 +687,8 @@ void write_cc_line_as_transcript2(struct eia608_screen *data, struct encoder_ctx
LLONG end_time = data->end_time;
if (context->sentence_cap)
{
capitalize (context, line_number, data);
correct_case(line_number, data);
if (clever_capitalize (context, line_number, data))
correct_case_with_dictionary(line_number, data);
}
int length = get_str_basic (context->subline, data->characters[line_number],
context->trim_subs, CCX_ENC_ASCII, context->encoding, CCX_DECODER_608_SCREEN_WIDTH);
@@ -909,6 +912,7 @@ int write_cc_bitmap_as_transcript(struct cc_subtitle *sub, struct encoder_ctx *c
fdprintf(context->out->fh,"DVB|");
}
fdprintf(context->out->fh,"%s",token);
write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length);
token = strtok(NULL,"\r\n");
}
@@ -1081,19 +1085,14 @@ static int init_output_ctx(struct encoder_ctx *ctx, struct encoder_cfg *cfg)
basefilename = get_basename(cfg->output_filename);
extension = get_file_extension(cfg->write_format);
ret = init_write(&ctx->out[0], strdup(cfg->output_filename));
ret = init_write(&ctx->out[0], strdup(cfg->output_filename), cfg->with_semaphore);
check_ret(cfg->output_filename);
ret = init_write(&ctx->out[1], create_outfilename(basefilename, "_2", extension));
ret = init_write(&ctx->out[1], create_outfilename(basefilename, "_2", extension), cfg->with_semaphore);
check_ret(ctx->out[1].filename);
}
else if (cfg->extract == 1)
{
ret = init_write(ctx->out, strdup(cfg->output_filename));
check_ret(cfg->output_filename);
}
else
{
ret = init_write(ctx->out, strdup(cfg->output_filename));
ret = init_write(ctx->out, strdup(cfg->output_filename), cfg->with_semaphore );
check_ret(cfg->output_filename);
}
}
@@ -1104,19 +1103,14 @@ static int init_output_ctx(struct encoder_ctx *ctx, struct encoder_cfg *cfg)
if (cfg->extract == 12)
{
ret = init_write(&ctx->out[0], create_outfilename(basefilename, "_1", extension));
ret = init_write(&ctx->out[0], create_outfilename(basefilename, "_1", extension), cfg->with_semaphore);
check_ret(ctx->out[0].filename);
ret = init_write(&ctx->out[1], create_outfilename(basefilename, "_2", extension));
ret = init_write(&ctx->out[1], create_outfilename(basefilename, "_2", extension), cfg->with_semaphore);
check_ret(ctx->out[1].filename);
}
else if (cfg->extract == 1)
{
ret = init_write(ctx->out, create_outfilename(basefilename, NULL, extension));
check_ret(ctx->out->filename);
}
else
{
ret = init_write(ctx->out, create_outfilename(basefilename, NULL, extension));
ret = init_write(ctx->out, create_outfilename(basefilename, NULL, extension), cfg->with_semaphore);
check_ret(ctx->out->filename);
}
}
@@ -1129,6 +1123,8 @@ static int init_output_ctx(struct encoder_ctx *ctx, struct encoder_cfg *cfg)
{
ctx->out[0].fh = STDOUT_FILENO;
ctx->out[0].filename = NULL;
ctx->out[0].with_semaphore = 0;
ctx->out[0].semaphore_filename = NULL;
mprint ("Sending captions to stdout.\n");
}
@@ -1222,6 +1218,7 @@ struct encoder_ctx *init_encoder(struct encoder_cfg *opt)
ctx->capacity=INITIAL_ENC_BUFFER_CAPACITY;
ctx->srt_counter = 0;
ctx->wrote_webvtt_sync_header = 0;
ctx->program_number = opt->program_number;
ctx->send_to_srv = opt->send_to_srv;
@@ -1326,6 +1323,8 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
if(!context)
return CCX_OK;
context = change_filename(context);
if (sub->type == CC_608)
{
struct eia608_screen *data = NULL;
@@ -1335,7 +1334,7 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
// Determine context based on channel. This replaces the code that was above, as this was incomplete (for cases where -12 was used for example)
out = get_output_ctx(context, data->my_field);
context->new_sentence = 1;
// context->new_sentence = 1; CFS: WHY??? Sentences may appear in different frames
if(data->format == SFORMAT_XDS)
{

View File

@@ -37,6 +37,9 @@ struct encoder_ctx
/* keep count of srt subtitle*/
unsigned int srt_counter;
/* Did we write the WebVTT sync header already? */
unsigned int wrote_webvtt_sync_header;
/* Input outputs */
/* Flag giving hint that output is send to server through network */
unsigned int send_to_srv;
@@ -57,6 +60,8 @@ struct encoder_ctx
/* Keep track of whether -UCLA used */
int ucla;
struct ccx_common_timing_ctx *timing; /* Some encoders need access to PTS, such as WebVTT */
/* Flag saying BOM to be written in each output file */
enum ccx_encoding_type encoding;
enum ccx_output_format write_format; // 0=Raw, 1=srt, 2=SMI

View File

@@ -40,7 +40,7 @@ int string_cmp(const void *p1, const void *p2)
return string_cmp2(p1, p2, NULL);
}
void correct_case(int line_num, struct eia608_screen *data)
void correct_case_with_dictionary(int line_num, struct eia608_screen *data)
{
char delim[64] = {
' ', '\n', '\r', 0x89, 0x99,
@@ -73,8 +73,61 @@ void correct_case(int line_num, struct eia608_screen *data)
free(line);
}
void capitalize(struct encoder_ctx *context, int line_num, struct eia608_screen *data)
void telx_correct_case(char *sub_line)
{
char delim[64] = {
' ', '\n', '\r', 0x89, 0x99,
'!', '"', '#', '%', '&',
'\'', '(', ')', ';', '<',
'=', '>', '?', '[', '\\',
']', '*', '+', ',', '-',
'.', '/', ':', '^', '_',
'{', '|', '}', '~', '\0' };
char *line = strdup(((char*)sub_line));
char *oline = (char*)sub_line;
char *c = strtok(line, delim);
if (c == NULL)
{
free(line);
return;
}
do
{
char **index = bsearch(&c, spell_lower, spell_words, sizeof(*spell_lower), string_cmp);
if (index)
{
char *correct_c = *(spell_correct + (index - spell_lower));
size_t len = strlen(correct_c);
memcpy(oline + (c - line), correct_c, len);
}
} while ((c = strtok(NULL, delim)) != NULL);
free(line);
}
int is_all_caps(struct encoder_ctx *context, int line_num, struct eia608_screen *data)
{
int saw_upper = 0, saw_lower = 0;
for (int i = 0; i < CCX_DECODER_608_SCREEN_WIDTH; i++)
{
if (islower(data->characters[line_num][i]))
saw_lower = 1;
else if (isupper(data->characters[line_num][i]))
saw_upper = 1;
}
return (saw_upper && !saw_lower); // 1 if we've seen upper and not lower, 0 otherwise
}
int clever_capitalize(struct encoder_ctx *context, int line_num, struct eia608_screen *data)
{
// CFS: Tried doing to clever (see below) but some channels do all uppercase except for
// notes for deaf people (such as "(narrator)" which messes things up.
// First find out if we actually need to do it, don't mess with lines that come OK
//int doit = is_all_caps(context, line_num, data);
int doit = 1;
for (int i = 0; i < CCX_DECODER_608_SCREEN_WIDTH; i++)
{
switch (data->characters[line_num][i])
@@ -90,14 +143,18 @@ void capitalize(struct encoder_ctx *context, int line_num, struct eia608_screen
context->new_sentence = 1;
break;
default:
if (context->new_sentence)
data->characters[line_num][i] = cctoupper(data->characters[line_num][i]);
else
data->characters[line_num][i] = cctolower(data->characters[line_num][i]);
if (doit)
{
if (context->new_sentence)
data->characters[line_num][i] = cctoupper(data->characters[line_num][i]);
else
data->characters[line_num][i] = cctolower(data->characters[line_num][i]);
}
context->new_sentence = 0;
break;
}
}
return doit;
}
// Encodes a generic string. Note that since we use the encoders for closed caption

View File

@@ -22,8 +22,10 @@ struct ccx_encoders_helpers_settings_t {
};
// Helper functions
void correct_case(int line_num, struct eia608_screen *data);
void capitalize(struct encoder_ctx *context, int line_num, struct eia608_screen *data);
void correct_case_with_dictionary(int line_num, struct eia608_screen *data);
int is_all_caps(struct encoder_ctx *context, int line_num, struct eia608_screen *data);
int clever_capitalize(struct encoder_ctx *context, int line_num, struct eia608_screen *data);
void telx_correct_case(char *sub_line);
unsigned get_decoder_line_encoded_for_gui(unsigned char *buffer, int line_num, struct eia608_screen *data);
unsigned get_decoder_line_encoded(struct encoder_ctx *ctx, unsigned char *buffer, int line_num, struct eia608_screen *data);

View File

@@ -318,7 +318,7 @@ int spupng_write_ccbuffer(struct spupng_t *sp, struct eia608_screen* data,
sp->pngfile, strerror(errno));
}
fclose(sp->fppng);
write_sputag(sp,ms_start,ms_end);
write_sputag_open(sp,ms_start,ms_end);
for (row = 0; row < ROWS; row++)
{
if (data->row_used[row])
@@ -355,6 +355,7 @@ int spupng_write_ccbuffer(struct spupng_t *sp, struct eia608_screen* data,
}
write_spucomment(sp,str);
write_sputag_close(sp);
return 1;
}
@@ -385,8 +386,9 @@ int spupng_write_string(struct spupng_t *sp, char *string, LLONG start_time, LLO
sp->pngfile, strerror(errno));
}
fclose(sp->fppng);
write_sputag(sp,ms_start,ms_end);
write_sputag_open(sp,ms_start,ms_end);
write_spucomment(sp,str);
write_sputag_close(sp);
return 1;
}
int write_cc_subtitle_as_spupng(struct cc_subtitle *sub, struct encoder_ctx *context)

View File

@@ -113,7 +113,7 @@ int write_cc_bitmap_as_srt(struct cc_subtitle *sub, struct encoder_ctx *context)
if(sub->flags & SUB_EOD_MARKER)
context->prev_start = sub->start_time;
str = paraof_ocrtext(sub);
str = paraof_ocrtext(sub, context->encoded_crlf, context->encoded_crlf_length);
if (str)
{
if (context->prev_start != -1 || !(sub->flags & SUB_EOD_MARKER))
@@ -159,6 +159,7 @@ int write_cc_subtitle_as_srt(struct cc_subtitle *sub,struct encoder_ctx *context
ret = write_stringz_as_srt(sub->data, context, sub->start_time, sub->end_time);
freep(&sub->data);
sub->nb_data = 0;
ret = 1;
}
lsub = sub;
sub = sub->next;
@@ -222,8 +223,8 @@ int write_cc_buffer_as_srt(struct eia608_screen *data, struct encoder_ctx *conte
{
if (context->sentence_cap)
{
capitalize (context, i, data);
correct_case(i,data);
if (clever_capitalize (context, i, data))
correct_case_with_dictionary(i, data);
}
if (context->autodash && context->trim_subs)
{

View File

@@ -19,6 +19,13 @@ struct ccx_s_write
int temporarily_closed; // 1 means the file was created OK before but we released the handle
char *filename;
void* spupng_data;
int with_semaphore; // 1 means create a .sem file when the file is open and delete it when it's closed
char *semaphore_filename;
int with_playlist; // For m3u8 /webvtt: If 1, we'll generate a playlist and segments
char *playlist_filename;
int renaming_extension; //Used for file rotations
int append_mode; /* Append the file. Prevent overwriting of files */
};
#endif

View File

@@ -3,7 +3,7 @@
#include "ccx_encoders_common.h"
#include "ccx_encoders_helpers.h"
#include "utility.h"
#include "ocr.h"
/* The timing here is not PTS based, but output based, i.e. user delay must be accounted for
@@ -94,13 +94,95 @@ int write_stringz_as_webvtt(char *string, struct encoder_ctx *context, LLONG ms_
return 0;
}
int write_xtimestamp_header(struct encoder_ctx *context)
{
if (context->wrote_webvtt_sync_header) // Already done
return 1;
if (context->timing->sync_pts2fts_set)
{
char header_string[200];
int used;
unsigned h1, m1, s1, ms1;
mstotime(context->timing->sync_pts2fts_fts, &h1, &m1, &s1, &ms1);
sprintf(header_string, "X-TIMESTAMP-MAP=MPEGTS:%ld, LOCAL %02u:%02u:%02u.%03u\r\n",
context->timing->sync_pts2fts_pts,
h1, m1, s1, ms1);
used = encode_line(context, context->buffer, (unsigned char *)header_string);
write(context->out->fh, context->buffer, used);
}
// Add the additional CRLF to finish the header
write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length);
context->wrote_webvtt_sync_header = 1; // Do it even if couldn't write the header, because it won't be possible anyway
}
int write_cc_bitmap_as_webvtt(struct cc_subtitle *sub, struct encoder_ctx *context)
{
//TODO
int ret = 0;
#ifdef ENABLE_OCR
struct cc_bitmap* rect;
LLONG ms_start, ms_end;
unsigned h1, m1, s1, ms1;
unsigned h2, m2, s2, ms2;
char timeline[128];
int len = 0;
int used;
int i = 0;
char *str;
if (context->prev_start != -1 && (sub->flags & SUB_EOD_MARKER))
{
ms_start = context->prev_start;
ms_end = sub->start_time;
}
else if (!(sub->flags & SUB_EOD_MARKER))
{
ms_start = sub->start_time;
ms_end = sub->end_time;
}
else if (context->prev_start == -1 && (sub->flags & SUB_EOD_MARKER))
{
ms_start = 1;
ms_end = sub->start_time;
}
if (sub->nb_data == 0)
return 0;
write_xtimestamp_header(context);
if (sub->flags & SUB_EOD_MARKER)
context->prev_start = sub->start_time;
str = paraof_ocrtext(sub, context->encoded_crlf, context->encoded_crlf_length);
if (str)
{
if (context->prev_start != -1 || !(sub->flags & SUB_EOD_MARKER))
{
mstotime(ms_start, &h1, &m1, &s1, &ms1);
mstotime(ms_end - 1, &h2, &m2, &s2, &ms2); // -1 To prevent overlapping with next line.
context->srt_counter++; // Not needed for WebVTT but let's keep it around for now
sprintf(timeline, "%02u:%02u:%02u.%03u --> %02u:%02u:%02u.%03u%s",
h1, m1, s1, ms1, h2, m2, s2, ms2, context->encoded_crlf);
used = encode_line(context, context->buffer, (unsigned char *)timeline);
write(context->out->fh, context->buffer, used);
len = strlen(str);
write(context->out->fh, str, len);
write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length);
}
freep(&str);
}
for (i = 0, rect = sub->data; i < sub->nb_data; i++, rect++)
{
freep(rect->data);
freep(rect->data + 1);
}
#endif
sub->nb_data = 0;
freep(&sub->data);
return ret;
}
int write_cc_subtitle_as_webvtt(struct cc_subtitle *sub, struct encoder_ctx *context)
@@ -158,6 +240,8 @@ int write_cc_buffer_as_webvtt(struct eia608_screen *data, struct encoder_ctx *co
if (ms_start<0) // Drop screens that because of subs_delay start too early
return 0;
write_xtimestamp_header(context);
ms_end = data->end_time;
mstotime(ms_start, &h1, &m1, &s1, &ms1);
@@ -180,8 +264,8 @@ int write_cc_buffer_as_webvtt(struct eia608_screen *data, struct encoder_ctx *co
{
if (context->sentence_cap)
{
capitalize(context, i, data);
correct_case(i, data);
if (clever_capitalize(context, i, data))
correct_case_with_dictionary(i, data);
}
if (context->autodash && context->trim_subs)
{

View File

@@ -0,0 +1,9 @@
#ifndef CCX_CCEXTRACTOR_COMPILE_H
#define CCX_CCEXTRACTOR_COMPILE_H
#ifndef VERSION_FILE_PRESENT
#define GIT_COMMIT "Unknown"
#define COMPILE_DATE "Unknown"
#else
#include "compile_info_real.h"
#endif
#endif

View File

@@ -444,11 +444,6 @@ void* dvbsub_init_decoder(struct dvb_config* cfg)
#ifdef ENABLE_OCR
ctx->ocr_ctx = init_ocr(ctx->lang_index);
if(!ctx->ocr_ctx)
{
freep(&ctx);
return NULL;
}
#endif
ctx->version = -1;
@@ -552,7 +547,8 @@ int dvbsub_close_decoder(void **dvb_ctx)
}
#ifdef ENABLE_OCR
delete_ocr(&ctx->ocr_ctx);
if (ctx->ocr_ctx)
delete_ocr(&ctx->ocr_ctx);
#endif
freep(dvb_ctx);
return 0;
@@ -1537,9 +1533,18 @@ static int write_dvb_sub(struct lib_cc_decode *dec_ctx, struct cc_subtitle *sub)
rect->data[0] = malloc(region->buf_size);
memcpy(rect->data[0], region->pbuf, region->buf_size);
#ifdef ENABLE_OCR
ret = ocr_rect(ctx->ocr_ctx, rect, &ocr_str);
if(ret >= 0)
rect->ocr_text = ocr_str;
if (ctx->ocr_ctx)
{
ret = ocr_rect(ctx->ocr_ctx, rect, &ocr_str,region->bgcolor);
if(ret >= 0)
rect->ocr_text = ocr_str;
else
rect->ocr_text = NULL;
}
else
{
rect->ocr_text = NULL;
}
#endif
rect++;
@@ -1690,9 +1695,15 @@ int parse_dvb_description(struct dvb_config* cfg, unsigned char*data,
for (i = 0; i < cfg->n_language; i++, data += i * 8)
{
/* setting language to undefined if not found in language lkup table */
char lang_name[4];
for(int char_index = 0; char_index < 3; char_index++)
{
lang_name[char_index] = cctolower(data[char_index]);
}
for (j = 0, cfg->lang_index[i] = 0; language[j] != NULL; j++)
{
if (!strncmp((const char*) (data), language[j], 3))
if (!strncmp(lang_name, language[j], 3))
cfg->lang_index[i] = j;
}
cfg->sub_type[i] = data[3];
@@ -1701,5 +1712,21 @@ int parse_dvb_description(struct dvb_config* cfg, unsigned char*data,
}
/*
Abhinav95: The way this function is called right now, only cfg->lang_index[0]
gets populated. E.g. for 3 stream languages, it will be called 3 times, and
set the language index in only the first element each time. This works with the
current state of the DVB code.
*/
if(ccx_options.dvblang)
{
if(strcmp(ccx_options.dvblang, language[cfg->lang_index[0]])!=0)
{
mprint("Ignoring stream language '%s' not equal to dvblang '%s'\n",
language[cfg->lang_index[0]], ccx_options.dvblang);
return -1;
}
}
return 0;
}

View File

@@ -24,7 +24,7 @@ int user_data(struct lib_cc_decode *ctx, struct bitstream *ustream, int udtype,
}
// Do something
//ctx->stat_numuserheaders++;
ctx->stat_numuserheaders++;
//header+=4;
unsigned char *ud_header = next_bytes(ustream, 4);
@@ -39,7 +39,7 @@ int user_data(struct lib_cc_decode *ctx, struct bitstream *ustream, int udtype,
// <http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/SCC_FORMAT.HTML>
if ( !memcmp(ud_header,"\x43\x43", 2 ) )
{
// ctx->stat_dvdccheaders++;
ctx->stat_dvdccheaders++;
// Probably unneeded, but keep looking for extra caption blocks
int maybeextracb = 1;
@@ -145,7 +145,7 @@ int user_data(struct lib_cc_decode *ctx, struct bitstream *ustream, int udtype,
{
unsigned char cc_data[3*31+1]; // Maximum cc_count is 31
// ctx->stat_scte20ccheaders++;
ctx->stat_scte20ccheaders++;
read_bytes(ustream, 2); // "03 01"
unsigned cc_count = (unsigned int) read_bits(ustream,5);
@@ -206,12 +206,12 @@ int user_data(struct lib_cc_decode *ctx, struct bitstream *ustream, int udtype,
&& ud_header[1] == 0x02 )
{
unsigned char data[3];
#if 0
if (ud_header[0]==0xbb)
ctx->stat_replay4000headers++;
else
ctx->stat_replay5000headers++;
#endif
read_bytes(ustream, 2); // "BB 02" or "99 02"
data[0]=0x05; // Field 2
@@ -227,7 +227,7 @@ int user_data(struct lib_cc_decode *ctx, struct bitstream *ustream, int udtype,
// HDTV - see A/53 Part 4 (Video)
else if ( !memcmp(ud_header,"\x47\x41\x39\x34", 4 ) )
{
// ctx->stat_hdtv++;
ctx->stat_hdtv++;
read_bytes(ustream, 4); // "47 41 39 34"
@@ -288,7 +288,7 @@ int user_data(struct lib_cc_decode *ctx, struct bitstream *ustream, int udtype,
dbg_print(CCX_DMT_VERBOSE, "Reading Dish Network user data\n");
// ctx->stat_dishheaders++;
ctx->stat_dishheaders++;
read_bytes(ustream, 2); // "05 02"
@@ -453,7 +453,7 @@ int user_data(struct lib_cc_decode *ctx, struct bitstream *ustream, int udtype,
else if ( !memcmp(ud_header,"\x02\x09", 2 ) )
{
// Either a documentation or more examples are needed.
// ctx->stat_divicom++;
ctx->stat_divicom++;
unsigned char data[3];

View File

@@ -83,18 +83,21 @@ void prepare_for_new_file (struct lib_ccx_ctx *ctx)
pts_big_change = 0;
firstcall = 1;
for(int x = 0; x < 0xfff; x++)
if(ctx->epg_inited)
{
ctx->epg_buffers[x].buffer = NULL;
ctx->epg_buffers[x].ccounter = 0;
for(int x = 0; x < 0xfff; x++)
{
ctx->epg_buffers[x].buffer = NULL;
ctx->epg_buffers[x].ccounter = 0;
}
for (int i = 0; i < TS_PMT_MAP_SIZE; i++)
{
ctx->eit_programs[i].array_len = 0;
ctx->eit_current_events[i] = -1;
}
ctx->epg_last_output = -1;
ctx->epg_last_live_output = -1;
}
for (int i = 0; i < TS_PMT_MAP_SIZE; i++)
{
ctx->eit_programs[i].array_len = 0;
ctx->eit_current_events[i] = -1;
}
ctx->epg_last_output = -1;
ctx->epg_last_live_output = -1;
}
/* Close input file if there is one and let the GUI know */
@@ -135,6 +138,7 @@ int switch_to_next_file (struct lib_ccx_ctx *ctx, LLONG bytesinbuffer)
/* Close current and make sure things are still sane */
if (ctx->demux_ctx->is_open(ctx->demux_ctx))
{
dbg_print(CCX_DMT_708, "[CEA-708] The 708 decoder was reset [%d] times.\n", ctx->freport.data_from_708->reset_count);
if (ccx_options.print_file_reports)
print_file_report(ctx);
@@ -298,6 +302,7 @@ void return_to_buffer (struct ccx_demuxer *ctx, unsigned char *buffer, unsigned
*/
size_t buffered_read_opt (struct ccx_demuxer *ctx, unsigned char *buffer, size_t bytes)
{
size_t origin_buffer_size = bytes;
size_t copied = 0;
time_t seconds = 0;
@@ -390,7 +395,7 @@ size_t buffered_read_opt (struct ccx_demuxer *ctx, unsigned char *buffer, size_t
{
/* If live stream, don't try to switch - acknowledge eof here as it won't
cause a loop end */
if (ccx_options.live_stream || !(ccx_options.binary_concat && switch_to_next_file(ctx->parent, copied)))
if (ccx_options.live_stream || ((struct lib_ccx_ctx *)ctx->parent)->inputsize <= origin_buffer_size || !(ccx_options.binary_concat && switch_to_next_file(ctx->parent, copied)))
eof = 1;
}
ctx->filebuffer_pos = keep;

View File

@@ -582,7 +582,7 @@ int process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, str
else if (data_node->bufferdatatype == CCX_TELETEXT)
{
//telxcc_update_gt(dec_ctx->private_data, ctx->demux_ctx->global_timestamp);
ret = tlt_process_pes_packet (dec_ctx, data_node->buffer, data_node->len, dec_sub);
ret = tlt_process_pes_packet (dec_ctx, data_node->buffer, data_node->len, dec_sub, enc_ctx->sentence_cap);
if(ret == CCX_EINVAL)
return ret;
got = data_node->len;
@@ -787,6 +787,8 @@ void general_loop(struct lib_ccx_ctx *ctx)
enc_ctx = update_encoder_list_cinfo(ctx, cinfo);
dec_ctx = update_decoder_list_cinfo(ctx, cinfo);
dec_ctx->dtvcc->encoder = (void *)enc_ctx; //WARN: otherwise cea-708 will not work
enc_ctx->timing = dec_ctx->timing;
if(data_node->pts != CCX_NOPTS)
{
struct ccx_rational tb = {1,MPEG_CLOCK_FREQ};
@@ -844,6 +846,7 @@ void general_loop(struct lib_ccx_ctx *ctx)
enc_ctx = update_encoder_list_cinfo(ctx, cinfo);
dec_ctx = update_decoder_list_cinfo(ctx, cinfo);
dec_ctx->dtvcc->encoder = (void *)enc_ctx; //WARN: otherwise cea-708 will not work
dec_ctx->timing = enc_ctx->timing;
if(data_node->pts != CCX_NOPTS)
set_current_pts(dec_ctx->timing, data_node->pts);
process_data(enc_ctx, dec_ctx, data_node);

291
src/lib_ccx/hardsubx.c Normal file
View File

@@ -0,0 +1,291 @@
#ifdef ENABLE_HARDSUBX
#include "hardsubx.h"
#include "capi.h"
#include "allheaders.h"
#include "ocr.h"
#include "utility.h"
//TODO: Correct FFMpeg integration
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
{
// Get the required media attributes and initialize structures
av_register_all();
if(avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL)!=0)
{
fatal (EXIT_READ_ERROR, "Error reading input file!\n");
}
if(avformat_find_stream_info(ctx->format_ctx, NULL)<0)
{
fatal (EXIT_READ_ERROR, "Error reading input stream!\n");
}
// Important call in order to determine media information using ffmpeg
// TODO: Handle multiple inputs
av_dump_format(ctx->format_ctx, 0, ctx->inputfile[0], 0);
ctx->video_stream_id = -1;
for(int i = 0; i < ctx->format_ctx->nb_streams; i++)
{
if(ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
{
ctx->video_stream_id = i;
break;
}
}
if(ctx->video_stream_id == -1)
{
fatal (EXIT_READ_ERROR, "Video Stream not found!\n");
}
ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
if(ctx->codec == NULL)
{
fatal (EXIT_READ_ERROR, "Input codec is not supported!\n");
}
if(avcodec_open2(ctx->codec_ctx, ctx->codec, &ctx->options_dict) < 0)
{
fatal (EXIT_READ_ERROR, "Error opening input codec!\n");
}
ctx->frame = av_frame_alloc();
ctx->rgb_frame = av_frame_alloc();
if(!ctx->frame || !ctx->rgb_frame)
{
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory to initialize frame!");
}
int frame_bytes = av_image_get_buffer_size(AV_PIX_FMT_RGB24, ctx->codec_ctx->width, ctx->codec_ctx->height, 16);
ctx->rgb_buffer = (uint8_t *)av_malloc(frame_bytes*sizeof(uint8_t));
ctx->sws_ctx = sws_getContext(
ctx->codec_ctx->width,
ctx->codec_ctx->height,
ctx->codec_ctx->pix_fmt,
ctx->codec_ctx->width,
ctx->codec_ctx->height,
AV_PIX_FMT_RGB24,
SWS_BILINEAR,
NULL,NULL,NULL
);
av_image_fill_arrays(ctx->rgb_frame->data, ctx->rgb_frame->linesize, ctx->rgb_buffer, AV_PIX_FMT_RGB24, ctx->codec_ctx->width, ctx->codec_ctx->height, 1);
// int frame_bytes = av_image_get_buffer_size(AV_PIX_FMT_RGB24, 1280, 720, 16);
// ctx->rgb_buffer = (uint8_t *)av_malloc(frame_bytes*sizeof(uint8_t));
// ctx->sws_ctx = sws_getContext(
// ctx->codec_ctx->width,
// ctx->codec_ctx->height,
// ctx->codec_ctx->pix_fmt,
// 1280,
// 720,
// AV_PIX_FMT_RGB24,
// SWS_BILINEAR,
// NULL,NULL,NULL
// );
// avpicture_fill((AVPicture*)ctx->rgb_frame, ctx->rgb_buffer, AV_PIX_FMT_RGB24, 1280, 720);
// av_image_fill_arrays(ctx->rgb_frame->data, ctx->rgb_frame->linesize, ctx->rgb_buffer, AV_PIX_FMT_RGB24, 1280, 720, 1);
// Pass on the processing context to the appropriate functions
struct encoder_ctx *enc_ctx;
enc_ctx = init_encoder(&ccx_options.enc_cfg);
mprint("Beginning burned-in subtitle detection...\n");
hardsubx_process_frames_linear(ctx, enc_ctx);
dinit_encoder(&enc_ctx, 0); //TODO: Replace 0 with end timestamp
// Free the allocated memory for frame processing
av_free(ctx->rgb_buffer);
av_free(ctx->rgb_frame);
av_free(ctx->frame);
avcodec_close(ctx->codec_ctx);
avformat_close_input(&ctx->format_ctx);
}
void _hardsubx_params_dump(struct ccx_s_options *options, struct lib_hardsubx_ctx *ctx)
{
// Print the relevant passed parameters onto the screen
mprint("Input : %s\n", ctx->inputfile[0]);
switch(ctx->subcolor)
{
case HARDSUBX_COLOR_WHITE:
mprint("Subtitle Color : White\n");
break;
case HARDSUBX_COLOR_YELLOW:
mprint("Subtitle Color : Yellow\n");
break;
case HARDSUBX_COLOR_GREEN:
mprint("Subtitle Color : Green\n");
break;
case HARDSUBX_COLOR_CYAN:
mprint("Subtitle Color : Cyan\n");
break;
case HARDSUBX_COLOR_BLUE:
mprint("Subtitle Color : Blue\n");
break;
case HARDSUBX_COLOR_MAGENTA:
mprint("Subtitle Color : Magenta\n");
break;
case HARDSUBX_COLOR_RED:
mprint("Subtitle Color : Red\n");
break;
case HARDSUBX_COLOR_CUSTOM:
mprint("Subtitle Color : Custom Hue - %0.2f\n",ctx->hue);
break;
default:
fatal(EXIT_MALFORMED_PARAMETER,"Invalid Subtitle Color");
}
switch(ctx->ocr_mode)
{
case HARDSUBX_OCRMODE_WORD:
mprint("OCR Mode : Word-wise\n");
break;
case HARDSUBX_OCRMODE_LETTER:
mprint("OCR Mode : Letter-wise\n");
break;
case HARDSUBX_OCRMODE_FRAME:
mprint("OCR Mode : Frame-wise (simple)\n");
break;
default:
fatal(EXIT_MALFORMED_PARAMETER,"Invalid OCR Mode");
}
if(ctx->conf_thresh > 0)
{
mprint("OCR Confidence Threshold : %.2f\n",ctx->conf_thresh);
}
else
{
mprint("OCR Confidence Threshold : %.2f (Default)\n",ctx->conf_thresh);
}
if(ctx->subcolor == HARDSUBX_COLOR_WHITE)
{
if(ctx->lum_thresh != 95.0)
{
mprint("OCR Luminance Threshold : %.2f\n",ctx->lum_thresh);
}
else
{
mprint("OCR Luminance Threshold : %.2f (Default)\n",ctx->lum_thresh);
}
}
if(ctx->detect_italics == 1)
{
mprint("OCR Italic Detection : On\n");
}
else
{
mprint("OCR Italic Detection : Off\n");
}
if(ctx->min_sub_duration == 0.5)
{
mprint("Minimum subtitle duration : 0.5 seconds (Default)\n");
}
else
{
mprint("Minimum subtitle duration : %0.2f seconds (Default)\n",ctx->min_sub_duration);
}
mprint("FFMpeg Media Information:-\n");
}
struct lib_hardsubx_ctx* _init_hardsubx(struct ccx_s_options *options)
{
// Initialize HardsubX data structures
struct lib_hardsubx_ctx *ctx = (struct lib_hardsubx_ctx *)malloc(sizeof(struct lib_hardsubx_ctx));
if(!ctx)
fatal(EXIT_NOT_ENOUGH_MEMORY, "lib_hardsubx_ctx");
memset(ctx, 0, sizeof(struct lib_hardsubx_ctx));
ctx->tess_handle = TessBaseAPICreate();
if(TessBaseAPIInit3(ctx->tess_handle, NULL, "eng") != 0)
{
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory to initialize Tesseract!");
}
//Initialize attributes common to lib_ccx context
ctx->basefilename = get_basename(options->output_filename);//TODO: Check validity, add stdin, network
ctx->current_file = -1;
ctx->inputfile = options->inputfile;
ctx->num_input_files = options->num_input_files;
ctx->extension = get_file_extension(options->write_format);
ctx->write_format = options->write_format;
ctx->subs_delay = options->subs_delay;
ctx->cc_to_stdout = options->cc_to_stdout;
//Initialize subtitle text parameters
ctx->ocr_mode = options->hardsubx_ocr_mode;
ctx->subcolor = options->hardsubx_subcolor;
ctx->min_sub_duration = options->hardsubx_min_sub_duration;
ctx->detect_italics = options->hardsubx_detect_italics;
ctx->conf_thresh = options->hardsubx_conf_thresh;
ctx->hue = options->hardsubx_hue;
ctx->lum_thresh = options->hardsubx_lum_thresh;
//Initialize subtitle structure memory
ctx->dec_sub = (struct cc_subtitle *)malloc(sizeof(struct cc_subtitle));
memset (ctx->dec_sub, 0,sizeof(struct cc_subtitle));
return ctx;
}
void _dinit_hardsubx(struct lib_hardsubx_ctx **ctx)
{
struct lib_hardsubx_ctx *lctx = *ctx;
// Free all memory allocated to everything in the context
// Free OCR
TessBaseAPIEnd(lctx->tess_handle);
TessBaseAPIDelete(lctx->tess_handle);
//Free subtitle
freep(lctx->dec_sub);
freep(ctx);
}
void hardsubx(struct ccx_s_options *options)
{
// This is similar to the 'main' function in ccextractor.c, but for hard subs
mprint("HardsubX (Hard Subtitle Extractor) - Burned-in subtitle extraction subsystem\n");
// Initialize HardsubX data structures
struct lib_hardsubx_ctx *ctx;
ctx = _init_hardsubx(options);
// Dump parameters (Not using params_dump since completely different parameters)
_hardsubx_params_dump(options, ctx);
// Configure output settings
// Data processing loop
time_t start, end;
time(&start);
hardsubx_process_data(ctx);
// Show statistics (time taken, frames processed, mode etc)
time(&end);
long processing_time=(long) (end-start);
mprint ("\rDone, processing time = %ld seconds\n", processing_time);
// Free all allocated memory for the data structures
_dinit_hardsubx(&ctx);
}
#endif

107
src/lib_ccx/hardsubx.h Normal file
View File

@@ -0,0 +1,107 @@
#ifndef HARDSUBX_H
#define HARDSUBX_H
#include "lib_ccx.h"
#include "utility.h"
#ifdef ENABLE_HARDSUBX
//TODO: Correct FFMpeg integration
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#include "allheaders.h"
#include "capi.h"
enum hardsubx_color_type
{
HARDSUBX_COLOR_WHITE = 0,
HARDSUBX_COLOR_YELLOW = 1,
HARDSUBX_COLOR_GREEN = 2,
HARDSUBX_COLOR_CYAN = 3,
HARDSUBX_COLOR_BLUE = 4,
HARDSUBX_COLOR_MAGENTA = 5,
HARDSUBX_COLOR_RED = 6,
HARDSUBX_COLOR_CUSTOM = 7,
};
enum hardsubx_ocr_mode
{
HARDSUBX_OCRMODE_FRAME = 0,
HARDSUBX_OCRMODE_WORD = 1,
HARDSUBX_OCRMODE_LETTER = 2,
};
struct lib_hardsubx_ctx
{
// The main context for hard subtitle extraction
// Attributes common to the lib_ccx context
int cc_to_stdout;
LLONG subs_delay;
LLONG last_displayed_subs_ms;
char *basefilename;
const char *extension;
int current_file;
char **inputfile;
int num_input_files;
LLONG system_start_time;
enum ccx_output_format write_format;
// Media file context
AVFormatContext *format_ctx;
AVCodecContext *codec_ctx;
AVCodec *codec;
AVFrame *frame;
AVFrame *rgb_frame;
AVPacket packet;
AVDictionary *options_dict;
struct SwsContext *sws_ctx;
uint8_t *rgb_buffer;
int video_stream_id;
// Leptonica Image and Tesseract Context
PIX *im;
TessBaseAPI *tess_handle;
// Classifier parameters
// Subtitle text parameters
struct cc_subtitle *dec_sub;
int ocr_mode;
int subcolor;
float min_sub_duration;
int detect_italics;
float conf_thresh;
float hue;
float lum_thresh;
};
struct lib_hardsubx_ctx* _init_hardsubx(struct ccx_s_options *options);
void _hardsubx_params_dump(struct ccx_s_options *options, struct lib_hardsubx_ctx *ctx);
void hardsubx(struct ccx_s_options *options);
//hardsubx_decoder.c
int hardsubx_process_frames_linear(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx);
int hardsubx_process_frames_binary(struct lib_hardsubx_ctx *ctx);
//hardsubx_imgops.c
void rgb2hsv(float R, float G, float B,float *H, float *S, float *V);
void rgb2lab(float R, float G, float B,float *L, float *a, float *b);
//hardsubx_classifier.c
char *get_ocr_text_simple(struct lib_hardsubx_ctx *ctx, PIX *image);
char *get_ocr_text_wordwise(struct lib_hardsubx_ctx *ctx, PIX *image);
char *get_ocr_text_letterwise(struct lib_hardsubx_ctx *ctx, PIX *image);
char *get_ocr_text_simple_threshold(struct lib_hardsubx_ctx *ctx, PIX *image, float threshold);
char *get_ocr_text_wordwise_threshold(struct lib_hardsubx_ctx *ctx, PIX *image, float threshold);
char *get_ocr_text_letterwise_threshold(struct lib_hardsubx_ctx *ctx, PIX *image, float threshold);
//hardsubx_utility.c
int edit_distance(char * word1, char * word2, int len1, int len2);
int64_t convert_pts_to_ms(int64_t pts, AVRational time_base);
int64_t convert_pts_to_ns(int64_t pts, AVRational time_base);
int64_t convert_pts_to_s(int64_t pts, AVRational time_base);
#endif
#endif

View File

@@ -0,0 +1,317 @@
#include "lib_ccx.h"
#include "utility.h"
#ifdef ENABLE_HARDSUBX
//TODO: Correct FFMpeg integration
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
#include "allheaders.h"
#include "hardsubx.h"
char *get_ocr_text_simple(struct lib_hardsubx_ctx *ctx, PIX *image)
{
char *text_out=NULL;
TessBaseAPISetImage2(ctx->tess_handle, image);
if(TessBaseAPIRecognize(ctx->tess_handle, NULL) != 0)
{
//TODO: Display error message
printf("Error in Tesseract recognition\n");
return NULL;
}
if((text_out = TessBaseAPIGetUTF8Text(ctx->tess_handle)) == NULL)
{
//TODO: Display error message
printf("Error getting text\n");
}
return text_out;
}
char *get_ocr_text_wordwise(struct lib_hardsubx_ctx *ctx, PIX *image)
{
char *text_out=NULL;
TessBaseAPISetImage2(ctx->tess_handle, image);
if(TessBaseAPIRecognize(ctx->tess_handle, NULL) != 0)
{
//TODO: Display error message
printf("Error in Tesseract recognition\n");
return NULL;
}
TessResultIterator *it = TessBaseAPIGetIterator(ctx->tess_handle);
TessPageIteratorLevel level = RIL_WORD;
int prev_ital = 0;
if(it!=0)
{
do
{
char* word = TessResultIteratorGetUTF8Text(it, level);
if(word==NULL || strlen(word)==0)
continue;
if(text_out == NULL)
{
if(ctx->detect_italics)
{
int italic=0;
int dummy=0;
TessResultIteratorWordFontAttributes(it, &dummy, &italic,&dummy, &dummy, &dummy,&dummy, &dummy, &dummy);
if(italic==1 && prev_ital==0)
{
char *word_copy = strdup(word);
word = realloc(word, strlen(word)+strlen("<i>")+2);
strcpy(word,"<i>");
strcat(word, word_copy);
free(word_copy);
prev_ital = 1;
}
else if(italic == 0 && prev_ital == 1)
{
word = realloc(word, strlen(word)+strlen("</i>")+2);
strcat(word, "</i>");
prev_ital = 0;
}
}
text_out = strdup(word);
text_out = realloc(text_out, strlen(text_out)+2);
strcat(text_out, " ");
continue;
}
if(ctx->detect_italics)
{
int italic=0;
int dummy=0;
TessResultIteratorWordFontAttributes(it, &dummy, &italic,&dummy, &dummy, &dummy,&dummy, &dummy, &dummy);
if(italic==1 && prev_ital==0)
{
char *word_copy = strdup(word);
word = realloc(word, strlen(word)+strlen("<i>")+2);
strcpy(word,"<i>");
strcat(word, word_copy);
free(word_copy);
prev_ital = 1;
}
else if(italic == 0 && prev_ital == 1)
{
word = realloc(word, strlen(word)+strlen("</i>")+2);
strcat(word, "</i>");
prev_ital = 0;
}
}
text_out = realloc(text_out, strlen(text_out)+strlen(word)+2);
strcat(text_out, word);
strcat(text_out, " ");
free(word);
} while(TessPageIteratorNext((TessPageIterator *)it, level));
}
if(ctx->detect_italics && prev_ital == 1)
{
text_out = realloc(text_out, strlen(text_out)+strlen("</i>")+2);
strcat(text_out, "</i>");
}
TessResultIteratorDelete(it);
return text_out;
}
char *get_ocr_text_letterwise(struct lib_hardsubx_ctx *ctx, PIX *image)
{
char *text_out=NULL;
TessBaseAPISetImage2(ctx->tess_handle, image);
if(TessBaseAPIRecognize(ctx->tess_handle, NULL) != 0)
{
//TODO: Display error message
printf("Error in Tesseract recognition\n");
return NULL;
}
TessResultIterator *it = TessBaseAPIGetIterator(ctx->tess_handle);
TessPageIteratorLevel level = RIL_SYMBOL;
if(it!=0)
{
do
{
char* letter = TessResultIteratorGetUTF8Text(it, level);
if(letter==NULL || strlen(letter)==0)
continue;
if(text_out==NULL)
{
text_out = strdup(letter);
continue;
}
text_out = realloc(text_out, strlen(text_out) + strlen(letter) + 1);
strcat(text_out, letter);
free(letter);
} while(TessPageIteratorNext((TessPageIterator *)it, level));
}
TessResultIteratorDelete(it);
return text_out;
}
char *get_ocr_text_simple_threshold(struct lib_hardsubx_ctx *ctx, PIX *image, float threshold)
{
char *text_out=NULL;
TessBaseAPISetImage2(ctx->tess_handle, image);
if(TessBaseAPIRecognize(ctx->tess_handle, NULL) != 0)
{
//TODO: Display error message
printf("Error in Tesseract recognition\n");
return NULL;
}
int conf = TessBaseAPIMeanTextConf(ctx->tess_handle);
if(conf < threshold)
return NULL;
return text_out;
}
char *get_ocr_text_wordwise_threshold(struct lib_hardsubx_ctx *ctx, PIX *image, float threshold)
{
char *text_out=NULL;
TessBaseAPISetImage2(ctx->tess_handle, image);
if(TessBaseAPIRecognize(ctx->tess_handle, NULL) != 0)
{
//TODO: Display error message
printf("Error in Tesseract recognition\n");
return NULL;
}
TessResultIterator *it = TessBaseAPIGetIterator(ctx->tess_handle);
TessPageIteratorLevel level = RIL_WORD;
int prev_ital = 0;
if(it!=0)
{
do
{
char* word = TessResultIteratorGetUTF8Text(it, level);
if(word==NULL || strlen(word)==0)
continue;
float conf = TessResultIteratorConfidence(it,level);
if(conf < threshold)
continue;
if(text_out == NULL)
{
if(ctx->detect_italics)
{
int italic=0;
int dummy=0;
TessResultIteratorWordFontAttributes(it, &dummy, &italic,&dummy, &dummy, &dummy,&dummy, &dummy, &dummy);
if(italic==1 && prev_ital==0)
{
char *word_copy = strdup(word);
word = realloc(word, strlen(word)+strlen("<i>")+2);
strcpy(word,"<i>");
strcat(word, word_copy);
free(word_copy);
prev_ital = 1;
}
else if(italic == 0 && prev_ital == 1)
{
word = realloc(word, strlen(word)+strlen("</i>")+2);
strcat(word, "</i>");
prev_ital = 0;
}
}
text_out = strdup(word);
text_out = realloc(text_out, strlen(text_out)+2);
strcat(text_out, " ");
continue;
}
if(ctx->detect_italics)
{
int italic=0;
int dummy=0;
TessResultIteratorWordFontAttributes(it, &dummy, &italic,&dummy, &dummy, &dummy,&dummy, &dummy, &dummy);
if(italic==1 && prev_ital==0)
{
char *word_copy = strdup(word);
word = realloc(word, strlen(word)+strlen("<i>")+2);
strcpy(word,"<i>");
strcat(word, word_copy);
free(word_copy);
prev_ital = 1;
}
else if(italic == 0 && prev_ital == 1)
{
word = realloc(word, strlen(word)+strlen("</i>")+2);
strcat(word, "</i>");
prev_ital = 0;
}
}
text_out = realloc(text_out, strlen(text_out)+strlen(word)+2);
strcat(text_out, word);
strcat(text_out, " ");
free(word);
} while(TessPageIteratorNext((TessPageIterator *)it, level));
}
if(ctx->detect_italics && prev_ital == 1)
{
text_out = realloc(text_out, strlen(text_out)+strlen("</i>")+2);
strcat(text_out, "</i>");
}
TessResultIteratorDelete(it);
return text_out;
}
char *get_ocr_text_letterwise_threshold(struct lib_hardsubx_ctx *ctx, PIX *image, float threshold)
{
char *text_out=NULL;
TessBaseAPISetImage2(ctx->tess_handle, image);
if(TessBaseAPIRecognize(ctx->tess_handle, NULL) != 0)
{
//TODO: Display error message
printf("Error in Tesseract recognition\n");
return NULL;
}
TessResultIterator *it = TessBaseAPIGetIterator(ctx->tess_handle);
TessPageIteratorLevel level = RIL_SYMBOL;
if(it!=0)
{
do
{
char* letter = TessResultIteratorGetUTF8Text(it, level);
if(letter==NULL || strlen(letter)==0)
continue;
float conf = TessResultIteratorConfidence(it,level);
if(conf < threshold)
continue;
if(text_out==NULL)
{
text_out = strdup(letter);
continue;
}
text_out = realloc(text_out, strlen(text_out) + strlen(letter) + 1);
strcat(text_out, letter);
free(letter);
} while(TessPageIteratorNext((TessPageIterator *)it, level));
}
TessResultIteratorDelete(it);
return text_out;
}
#endif

View File

@@ -0,0 +1,370 @@
#include "lib_ccx.h"
#include "utility.h"
#ifdef ENABLE_HARDSUBX
//TODO: Correct FFMpeg integration
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
#include "allheaders.h"
#include "hardsubx.h"
#include "capi.h"
char* _process_frame_white_basic(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int height, int index)
{
//printf("frame : %04d\n", index);
PIX *im;
// PIX *edge_im;
PIX *lum_im;
char *subtitle_text=NULL;
im = pixCreate(width,height,32);
lum_im = pixCreate(width,height,32);
// edge_im = pixCreate(width,height,8);
int i,j;
for(i=(3*height)/4;i<height;i++)
{
for(j=0;j<width;j++)
{
int p=j*3+i*frame->linesize[0];
int r=frame->data[0][p];
int g=frame->data[0][p+1];
int b=frame->data[0][p+2];
pixSetRGBPixel(im,j,i,r,g,b);
float L,A,B;
rgb2lab((float)r,(float)g,(float)b,&L,&A,&B);
if(L > ctx->lum_thresh)
pixSetRGBPixel(lum_im,j,i,255,255,255);
else
pixSetRGBPixel(lum_im,j,i,0,0,0);
}
}
if(ctx->detect_italics)
{
ctx->ocr_mode = HARDSUBX_OCRMODE_WORD;
}
// TESSERACT OCR FOR THE FRAME HERE
switch(ctx->ocr_mode)
{
case HARDSUBX_OCRMODE_WORD:
if(ctx->conf_thresh > 0)
subtitle_text = get_ocr_text_wordwise_threshold(ctx, lum_im, ctx->conf_thresh);
else
subtitle_text = get_ocr_text_wordwise(ctx, lum_im);
break;
case HARDSUBX_OCRMODE_LETTER:
if(ctx->conf_thresh > 0)
subtitle_text = get_ocr_text_letterwise_threshold(ctx, lum_im, ctx->conf_thresh);
else
subtitle_text = get_ocr_text_letterwise(ctx, lum_im);
break;
case HARDSUBX_OCRMODE_FRAME:
if(ctx->conf_thresh > 0)
subtitle_text = get_ocr_text_simple_threshold(ctx, lum_im, ctx->conf_thresh);
else
subtitle_text = get_ocr_text_simple(ctx, lum_im);
break;
default:
fatal(EXIT_MALFORMED_PARAMETER,"Invalid OCR Mode");
}
pixDestroy(&lum_im);
pixDestroy(&im);
return subtitle_text;
}
char *_process_frame_color_basic(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int height, int index)
{
PIX *im;
PIX *edge_im;
PIX *hue_im;
PIX *feat_im;
char *subtitle_text=NULL;
im = pixCreate(width,height,32);
hue_im = pixCreate(width,height,32);
feat_im = pixCreate(width,height,32);
edge_im = pixCreate(width,height,8);
int i,j;
for(i=(3*height)/4;i<height;i++)
{
for(j=0;j<width;j++)
{
int p=j*3+i*frame->linesize[0];
int r=frame->data[0][p];
int g=frame->data[0][p+1];
int b=frame->data[0][p+2];
pixSetRGBPixel(im,j,i,r,g,b);
float H,S,V;
rgb2lab((float)r,(float)g,(float)b,&H,&S,&V);
if(abs(H - ctx->hue)>20)
pixSetRGBPixel(hue_im,j,i,255,255,255);
else
pixSetRGBPixel(hue_im,j,i,0,0,0);
}
}
// Based on hue image and edge image, create feature image
for(i=3*(height/4);i<height;i++)
{
for(j=0;j<width;j++)
{
unsigned int p1,p2,p3;
// pixGetPixel(edge_im,j,i,&p1);
// pixGetPixel(pixd,j,i,&p2);
pixGetPixel(hue_im,j,i,&p3);
if(p3>0)//if(p2==0&&p1==0&&p3>0)
{
pixSetRGBPixel(feat_im,j,i,255,255,255);
}
}
}
if(ctx->detect_italics)
{
ctx->ocr_mode = HARDSUBX_OCRMODE_WORD;
}
// TESSERACT OCR FOR THE FRAME HERE
switch(ctx->ocr_mode)
{
case HARDSUBX_OCRMODE_WORD:
if(ctx->conf_thresh > 0)
subtitle_text = get_ocr_text_wordwise_threshold(ctx, feat_im, ctx->conf_thresh);
else
subtitle_text = get_ocr_text_wordwise(ctx, feat_im);
break;
case HARDSUBX_OCRMODE_LETTER:
if(ctx->conf_thresh > 0)
subtitle_text = get_ocr_text_letterwise_threshold(ctx, feat_im, ctx->conf_thresh);
else
subtitle_text = get_ocr_text_letterwise(ctx, feat_im);
break;
case HARDSUBX_OCRMODE_FRAME:
if(ctx->conf_thresh > 0)
subtitle_text = get_ocr_text_simple_threshold(ctx, feat_im, ctx->conf_thresh);
else
subtitle_text = get_ocr_text_simple(ctx, feat_im);
break;
default:
fatal(EXIT_MALFORMED_PARAMETER,"Invalid OCR Mode");
}
pixDestroy(&feat_im);
pixDestroy(&im);
pixDestroy(&edge_im);
pixDestroy(&hue_im);
return subtitle_text;
}
void _display_frame(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int height, int timestamp)
{
// Debug: Display the frame after processing
PIX *im;
im = pixCreate(width,height,32);
PIX *hue_im = pixCreate(width,height,32);
int i,j;
for(i=0;i<height;i++)
{
for(j=0;j<width;j++)
{
int p=j*3+i*frame->linesize[0];
int r=frame->data[0][p];
int g=frame->data[0][p+1];
int b=frame->data[0][p+2];
pixSetRGBPixel(im,j,i,r,g,b);
float H,S,V;
rgb2hsv((float)r,(float)g,(float)b,&H,&S,&V);
if(abs(H-60)<20)
{
pixSetRGBPixel(hue_im,j,i,255,255,255);
}
}
}
PIX *edge_im = pixCreate(width,height,8),*edge_im_2 = pixCreate(width,height,8);
edge_im = pixConvertRGBToGray(im,0.0,0.0,0.0);
pixCopy(edge_im_2,edge_im);
edge_im = pixSobelEdgeFilter(edge_im, L_VERTICAL_EDGES);
edge_im = pixDilateGray(edge_im, 21, 11);
edge_im = pixThresholdToBinary(edge_im,50);
PIX *pixd = pixCreate(width,height,1);
pixSauvolaBinarize(edge_im_2, 11, 0.3, 1, NULL, NULL, NULL, &pixd);
PIX *feat_im = pixCreate(width,height,32);
for(i=3*(height/4);i<height;i++)
{
for(j=0;j<width;j++)
{
unsigned int p1,p2,p3;
pixGetPixel(edge_im,j,i,&p1);
pixGetPixel(pixd,j,i,&p2);
pixGetPixel(hue_im,j,i,&p3);
if(p1==0)//if(p2==0&&p1==0&&p3>0)
{
pixSetRGBPixel(feat_im,j,i,255,255,255);
}
}
}
char *txt=NULL;
// txt = get_ocr_text_simple(ctx, feat_im);
// txt=get_ocr_text_wordwise_threshold(ctx, feat_im, ctx->conf_thresh);
// if(txt != NULL)printf("%s\n", txt);
char write_path[100];
sprintf(write_path,"./ffmpeg-examples/frames/temp%04d.jpg",timestamp);
pixWrite(write_path,feat_im,IFF_JFIF_JPEG);
pixDestroy(&im);
pixDestroy(&edge_im);
pixDestroy(&feat_im);
pixDestroy(&edge_im_2);
pixDestroy(&pixd);
}
int hardsubx_process_frames_linear(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
{
// Do an exhaustive linear search over the video
int got_frame;
int dist;
int cur_sec,total_sec,progress;
int frame_number = 0;
int64_t begin_time = 0,end_time = 0,prev_packet_pts = 0;
char *subtitle_text=NULL;
char *prev_subtitle_text=NULL;
while(av_read_frame(ctx->format_ctx, &ctx->packet)>=0)
{
if(ctx->packet.stream_index == ctx->video_stream_id)
{
frame_number++;
//Decode the video stream packet
avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
if(got_frame && frame_number % 25 == 0)
{
float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
if(abs(diff) < 1000*ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
continue;
// sws_scale is used to convert the pixel format to RGB24 from all other cases
sws_scale(
ctx->sws_ctx,
(uint8_t const * const *)ctx->frame->data,
ctx->frame->linesize,
0,
ctx->codec_ctx->height,
ctx->rgb_frame->data,
ctx->rgb_frame->linesize
);
// Send the frame to other functions for processing
if(ctx->subcolor==HARDSUBX_COLOR_WHITE)
{
subtitle_text = _process_frame_white_basic(ctx,ctx->rgb_frame,ctx->codec_ctx->width,ctx->codec_ctx->height,frame_number);
}
else
{
subtitle_text = _process_frame_color_basic(ctx, ctx->rgb_frame, ctx->codec_ctx->width,ctx->codec_ctx->height,frame_number);
}
_display_frame(ctx, ctx->rgb_frame,ctx->codec_ctx->width,ctx->codec_ctx->height,frame_number);
cur_sec = (int)convert_pts_to_s(ctx->packet.pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
total_sec = (int)convert_pts_to_s(ctx->format_ctx->duration, AV_TIME_BASE_Q);
progress = (cur_sec*100)/total_sec;
activity_progress(progress,cur_sec/60,cur_sec%60);
if(subtitle_text==NULL)
continue;
if(!strlen(subtitle_text))
continue;
subtitle_text = strtok(subtitle_text,"\n");
end_time = convert_pts_to_ms(ctx->packet.pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
if(prev_subtitle_text)
{
//TODO: Encode text with highest confidence
dist = edit_distance(subtitle_text, prev_subtitle_text, strlen(subtitle_text), strlen(prev_subtitle_text));
if(dist > (0.2 * fmin(strlen(subtitle_text), strlen(prev_subtitle_text))))
{
add_cc_sub_text(ctx->dec_sub, prev_subtitle_text, begin_time, end_time, "", "BURN", CCX_ENC_UTF_8);
encode_sub(enc_ctx, ctx->dec_sub);
begin_time = end_time + 1;
}
}
prev_subtitle_text = strdup(subtitle_text);
prev_packet_pts = ctx->packet.pts;
}
}
av_packet_unref(&ctx->packet);
}
add_cc_sub_text(ctx->dec_sub, prev_subtitle_text, begin_time, end_time, "", "BURN", CCX_ENC_UTF_8);
encode_sub(enc_ctx, ctx->dec_sub);
activity_progress(100,cur_sec/60,cur_sec%60);
}
int hardsubx_process_frames_binary(struct lib_hardsubx_ctx *ctx)
{
// Do a binary search over the input video for faster processing
// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
int got_frame;
int seconds_time = 0;
for(seconds_time=0;seconds_time<20;seconds_time++){
int64_t seek_time = (int64_t)(seconds_time*AV_TIME_BASE);
seek_time = av_rescale_q(seek_time, AV_TIME_BASE_Q, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
int ret = av_seek_frame(ctx->format_ctx, ctx->video_stream_id, seek_time, AVSEEK_FLAG_BACKWARD);
// printf("%d\n", ret);
// if(ret < 0)
// {
// printf("seeking back\n");
// ret = av_seek_frame(ctx->format_ctx, -1, seek_time, AVSEEK_FLAG_BACKWARD);
// }
if(ret >= 0)
{
while(av_read_frame(ctx->format_ctx, &ctx->packet)>=0)
{
if(ctx->packet.stream_index == ctx->video_stream_id)
{
avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
if(got_frame)
{
// printf("%d\n", seek_time);
if(ctx->packet.pts < seek_time)
continue;
// printf("GOT FRAME: %d\n",ctx->packet.pts);
// sws_scale is used to convert the pixel format to RGB24 from all other cases
sws_scale(
ctx->sws_ctx,
(uint8_t const * const *)ctx->frame->data,
ctx->frame->linesize,
0,
ctx->codec_ctx->height,
ctx->rgb_frame->data,
ctx->rgb_frame->linesize
);
// Send the frame to other functions for processing
_display_frame(ctx, ctx->rgb_frame,ctx->codec_ctx->width,ctx->codec_ctx->height,seconds_time);
break;
}
}
}
}
else
{
printf("Seeking to timestamp failed\n");
}
}
}
#endif

View File

@@ -0,0 +1,108 @@
#include "lib_ccx.h"
#include "utility.h"
#ifdef ENABLE_HARDSUBX
//TODO: Correct FFMpeg integration
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
#include "allheaders.h"
#include "hardsubx.h"
#define BLACK 20.0
#define YELLOW 70.0
#define min_f(a, b, c) (fminf(a, fminf(b, c)))
#define max_f(a, b, c) (fmaxf(a, fmaxf(b, c)))
void rgb2hsv(float R, float G, float B,float *H, float *S, float *V)
{
//Conversion into HSV color space to get Hue
float r = R / 255.0f;
float g = G / 255.0f;
float b = B / 255.0f;
float h, s, v; // h:0-360.0, s:0.0-1.0, v:0.0-1.0
float max = max_f(r, g, b);
float min = min_f(r, g, b);
v = max;
if (max == 0.0f) {
s = 0;
h = 0;
}
else if (max - min == 0.0f) {
s = 0;
h = 0;
}
else {
s = (max - min) / max;
if (max == r) {
h = 60 * ((g - b) / (max - min)) + 0;
}
else if (max == g) {
h = 60 * ((b - r) / (max - min)) + 120;
}
else {
h = 60 * ((r - g) / (max - min)) + 240;
}
}
if (h < 0) h += 360.0f;
*H = (unsigned char)(h); // dst_h : 0-360
*S = (unsigned char)(s * 255); // dst_s : 0-255
*V = (unsigned char)(v * 255); // dst_v : 0-255
}
void rgb2lab(float R, float G, float B,float *L, float *a, float *b)
{
//Conversion to the CIE-LAB color space to get the Luminance
float X, Y, Z, fX, fY, fZ;
X = 0.412453*R + 0.357580*G + 0.180423*B;
Y = 0.212671*R + 0.715160*G + 0.072169*B;
Z = 0.019334*R + 0.119193*G + 0.950227*B;
X /= (255 * 0.950456);
Y /= 255;
Z /= (255 * 1.088754);
if (Y > 0.008856)
{
fY = pow(Y, 1.0/3.0);
*L = 116.0*fY - 16.0;
}
else
{
fY = 7.787*Y + 16.0/116.0;
*L = 903.3*Y;
}
if (X > 0.008856)
fX = pow(X, 1.0/3.0);
else
fX = 7.787*X + 16.0/116.0;
if (Z > 0.008856)
fZ = pow(Z, 1.0/3.0);
else
fZ = 7.787*Z + 16.0/116.0;
*a = 500.0*(fX - fY);
*b = 200.0*(fY - fZ);
if (*L < BLACK) {
*a *= exp((*L - BLACK) / (BLACK / 4));
*b *= exp((*L - BLACK) / (BLACK / 4));
*L = BLACK;
}
if (*b > YELLOW)
*b = YELLOW;
}
#endif

View File

@@ -0,0 +1,68 @@
#include "lib_ccx.h"
#include "utility.h"
#ifdef ENABLE_HARDSUBX
//TODO: Correct FFMpeg integration
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
#include "allheaders.h"
#include "hardsubx.h"
int64_t convert_pts_to_ms(int64_t pts, AVRational time_base)
{
return av_rescale_q(pts, time_base, AV_TIME_BASE_Q)/1000;
}
int64_t convert_pts_to_ns(int64_t pts, AVRational time_base)
{
return av_rescale_q(pts, time_base, AV_TIME_BASE_Q);
}
int64_t convert_pts_to_s(int64_t pts, AVRational time_base)
{
return av_rescale_q(pts, time_base, AV_TIME_BASE_Q)/1000000;
}
int edit_distance(char * word1, char * word2, int len1, int len2)
{
int matrix[len1 + 1][len2 + 1];
int i,delete,insert,substitute,minimum;
for (i = 0; i <= len1; i++)matrix[i][0] = i;
for (i = 0; i <= len2; i++)matrix[0][i] = i;
for (i = 1; i <= len1; i++)
{
int j;
char c1;
c1 = word1[i-1];
for (j = 1; j <= len2; j++)
{
char c2;
c2 = word2[j-1];
if (c1 == c2)
{
matrix[i][j] = matrix[i-1][j-1];
}
else
{
delete = matrix[i-1][j] + 1;
insert = matrix[i][j-1] + 1;
substitute = matrix[i-1][j-1] + 1;
minimum = delete;
if (insert < minimum)
{
minimum = insert;
}
if (substitute < minimum)
{
minimum = substitute;
}
matrix[i][j] = minimum;
}
}
}
return matrix[len1][len2];
}
#endif

View File

@@ -98,6 +98,29 @@ struct lib_ccx_ctx* init_libraries(struct ccx_s_options *opt)
ccx_common_logging.fatal_ftn(EXIT_NOT_ENOUGH_MEMORY, "lib_ccx_ctx");
memset(ctx, 0, sizeof(struct lib_ccx_ctx));
if(opt->xmltv)
{
ctx->epg_inited = 1;
ctx->epg_buffers = (struct PSI_buffer *)malloc(sizeof(struct PSI_buffer)*(0xfff+1));
ctx->eit_programs = (struct EIT_program *)malloc(sizeof(struct EIT_program)*(TS_PMT_MAP_SIZE+1));
ctx->eit_current_events = (int32_t *)malloc(sizeof(int32_t)*(TS_PMT_MAP_SIZE+1));
ctx->ATSC_source_pg_map = (int16_t *)malloc(sizeof(int16_t)*(0xffff));
memset(ctx->epg_buffers, 0, sizeof(struct PSI_buffer)*(0xfff+1));
memset(ctx->eit_programs, 0, sizeof(struct EIT_program)*(TS_PMT_MAP_SIZE+1));
memset(ctx->eit_current_events, 0, sizeof(int32_t)*(TS_PMT_MAP_SIZE+1));
memset(ctx->ATSC_source_pg_map, 0, sizeof(int16_t)*(0xffff));
if(!ctx->epg_buffers || !ctx->eit_programs || !ctx->eit_current_events || !ctx->ATSC_source_pg_map)
ccx_common_logging.fatal_ftn(EXIT_NOT_ENOUGH_MEMORY, "lib_ccx_ctx");
}
else
{
ctx->epg_inited = 0;
ctx->epg_buffers = NULL;
ctx->eit_programs = NULL;
ctx->eit_current_events = NULL;
ctx->ATSC_source_pg_map = NULL;
}
struct ccx_decoder_608_report *report_608 = malloc(sizeof(struct ccx_decoder_608_report));
if (!report_608)
ccx_common_logging.fatal_ftn(EXIT_NOT_ENOUGH_MEMORY, "report_608");

View File

@@ -1,7 +1,7 @@
#ifndef CCX_CCEXTRACTOR_H
#define CCX_CCEXTRACTOR_H
#define VERSION "0.79"
#define VERSION "0.82"
// Load common includes and constants for library usage
#include "ccx_common_platform.h"
@@ -115,10 +115,11 @@ struct lib_ccx_ctx
unsigned teletext_warning_shown; // Did we detect a possible PAL (with teletext subs) and told the user already?
struct PSI_buffer epg_buffers[0xfff+1];
struct EIT_program eit_programs[TS_PMT_MAP_SIZE+1];
int32_t eit_current_events[TS_PMT_MAP_SIZE+1];
int16_t ATSC_source_pg_map[0xffff];
int epg_inited;
struct PSI_buffer *epg_buffers;
struct EIT_program *eit_programs;
int32_t *eit_current_events;
int16_t *ATSC_source_pg_map;
int epg_last_output;
int epg_last_live_output;
struct file_report freport;
@@ -201,7 +202,7 @@ void print_file_report(struct lib_ccx_ctx *ctx);
void dinit_write(struct ccx_s_write *wb);
int temporarily_open_output(struct ccx_s_write *wb);
int temporarily_close_output(struct ccx_s_write *wb);
int init_write (struct ccx_s_write *wb,char *filename);
int init_write(struct ccx_s_write *wb, char *filename, int with_semaphore);
int writeraw (const unsigned char *data, int length, void *private_data, struct cc_subtitle *sub);
void flushbuffer (struct lib_ccx_ctx *ctx, struct ccx_s_write *wb, int closefile);
void writercwtdata (struct lib_cc_decode *ctx, const unsigned char *data, struct cc_subtitle *sub);
@@ -240,6 +241,9 @@ void timestamp_to_srttime(uint64_t timestamp, char *buffer);
void timestamp_to_smptetttime(uint64_t timestamp, char *buffer);
int levenshtein_dist (const uint64_t *s1, const uint64_t *s2, unsigned s1len, unsigned s2len);
void millis_to_date (uint64_t timestamp, char *buffer, enum ccx_output_date_format date_format, char millis_separator);
void create_signal(void);
void signal_handler(int sig_type);
struct encoder_ctx* change_filename(struct encoder_ctx*);
#ifndef _WIN32
void m_signal(int sig, void (*func)(int));
#endif
@@ -248,7 +252,7 @@ void m_signal(int sig, void (*func)(int));
void buffered_seek (struct ccx_demuxer *ctx, int offset);
extern void build_parity_table(void);
int tlt_process_pes_packet(struct lib_cc_decode *dec_ctx, uint8_t *buffer, uint16_t size, struct cc_subtitle *sub);
int tlt_process_pes_packet(struct lib_cc_decode *dec_ctx, uint8_t *buffer, uint16_t size, struct cc_subtitle *sub, int sentence_cap);
void* telxcc_init(void);
void telxcc_close(void **ctx, struct cc_subtitle *sub);
void tlt_read_rcwt(void *codec, unsigned char *buf, struct cc_subtitle *sub);

View File

@@ -7,6 +7,7 @@
#include <dirent.h>
#include "spupng_encoder.h"
#include "ccx_encoders_helpers.h"
#include "ocr.h"
#undef OCR_DEBUG
struct ocrCtx
{
@@ -18,6 +19,7 @@ struct transIntensity
uint8_t *t;
png_color *palette;
};
static int check_trans_tn_intensity(const void *p1, const void *p2, void *arg)
{
struct transIntensity *ti = arg;
@@ -27,8 +29,8 @@ static int check_trans_tn_intensity(const void *p1, const void *p2, void *arg)
unsigned char act_i;
/** TODO verify that RGB follow ITU-R BT.709
* Below fomula is valid only for 709 standurd
* Y = 0.2126 R + 0.7152 G + 0.0722 B
*/
* Y = 0.2126 R + 0.7152 G + 0.0722 B
*/
tmp_i = (0.2126 * ti->palette[*tmp].red) + (0.7152 * ti->palette[*tmp].green) + (0.0722 * ti->palette[*tmp].blue);
act_i = (0.2126 * ti->palette[*act].red) + (0.7152 * ti->palette[*act].green) + (0.0722 * ti->palette[*act].blue);;
@@ -41,8 +43,14 @@ static int check_trans_tn_intensity(const void *p1, const void *p2, void *arg)
return 1;
}
static int search_language_pack(const char *dirname,const char *lang)
static int search_language_pack(const char *dir_name,const char *lang_name)
{
//Search for a tessdata folder in the specified directory
char *lang = strdup(lang_name);
char *dirname = strdup(dir_name);
dirname = realloc(dirname,strlen(dirname)+strlen("/tessdata/")+1);
strcat(dirname,"/tessdata/");
DIR *dp;
struct dirent *dirp;
char filename[256];
@@ -66,13 +74,13 @@ static int search_language_pack(const char *dirname,const char *lang)
void delete_ocr (void** arg)
{
struct ocrCtx* ctx = *arg;
TessBaseAPIEnd(ctx->api);
TessBaseAPIDelete(ctx->api);
TessBaseAPIEnd(ctx->api);
TessBaseAPIDelete(ctx->api);
freep(arg);
}
void* init_ocr(int lang_index)
{
int ret;
int ret = -1;
struct ocrCtx* ctx;
ctx = (struct ocrCtx*)malloc(sizeof(struct ocrCtx));
@@ -87,15 +95,44 @@ void* init_ocr(int lang_index)
lang_index = 1;
}
/* if langauge pack not found use english */
ret = search_language_pack("tessdata",language[lang_index]);
if(ret < 0 )
if(ccx_options.dvblang)
{
if(strcmp(language[lang_index],ccx_options.dvblang)!=0)
goto fail;
}
/*Priority of Tesseract traineddata file search paths:-
1. tessdata in TESSDATA_PREFIX, if it is specified. Overrides others
2. tessdata in current working directory
*/
int data_location = 0;
char *tessdata_dir_path=".";
if(!getenv("TESSDATA_PREFIX"))
{
ret = search_language_pack(tessdata_dir_path,language[lang_index]);
}
if(ret < 0)
{
data_location = 1;
if(getenv("TESSDATA_PREFIX"))
ret = search_language_pack(getenv("TESSDATA_PREFIX"), language[lang_index]);
else
ret = -1;
}
if(ret < 0 && lang_index != 1 && ccx_options.ocrlang==NULL)
{
mprint("%s.traineddata not found! Switching to English\n",language[lang_index]);
/* select english */
lang_index = 1;
}
ret = TessBaseAPIInit3(ctx->api, NULL, language[lang_index]);
if(ccx_options.ocrlang)
ret = TessBaseAPIInit3(ctx->api, NULL, ccx_options.ocrlang);
else if(data_location == 1)
ret = TessBaseAPIInit3(ctx->api, NULL, language[lang_index]);
else
ret = TessBaseAPIInit3(ctx->api, tessdata_dir_path, language[lang_index]);
if(ret < 0)
{
goto fail;
@@ -107,7 +144,7 @@ fail:
}
int ignore_alpha_at_edge(png_byte *alpha, unsigned char* indata, int w, int h, PIX *in, PIX **out)
BOX* ignore_alpha_at_edge(png_byte *alpha, unsigned char* indata, int w, int h, PIX *in, PIX **out)
{
int i, j, index, start_y, end_y;
int find_end_x = CCX_FALSE;
@@ -133,14 +170,16 @@ int ignore_alpha_at_edge(png_byte *alpha, unsigned char* indata, int w, int h, P
}
cropWindow = boxCreate(start_y, 0, (w - (start_y + ( w - end_y) )), h - 1);
*out = pixClipRectangle(in, cropWindow, NULL);
boxDestroy(&cropWindow);
//boxDestroy(&cropWindow);
return 0;
return cropWindow;
}
char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* indata,int w, int h)
char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* indata,int w, int h, struct image_copy *copy)
{
PIX *pix = NULL;
PIX *cpix = NULL;
PIX *color_pix = NULL;
PIX *color_pix_out = NULL;
char*text_out= NULL;
int i,j,index;
unsigned int wpl;
@@ -148,7 +187,8 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i
BOOL tess_ret = FALSE;
struct ocrCtx* ctx = arg;
pix = pixCreate(w, h, 32);
if(pix == NULL)
color_pix = pixCreate(w, h, 32);
if(pix == NULL||color_pix == NULL)
{
return NULL;
}
@@ -156,6 +196,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i
data = pixGetData(pix);
#if LEPTONICA_VERSION > 69
pixSetSpp(pix, 4);
pixSetSpp(color_pix, 4);
#endif
for (i = 0; i < h; i++)
{
@@ -169,12 +210,27 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i
}
}
ignore_alpha_at_edge(alpha, indata, w, h, pix, &cpix);
// For the unquantized bitmap
wpl = pixGetWpl(color_pix);
data = pixGetData(color_pix);
for (i = 0; i < h; i++)
{
ppixel = data + i * wpl;
for (j = 0; j < w; j++)
{
index = copy->data[i * w + (j)];
composeRGBPixel(copy->palette[index].red, copy->palette[index].green,copy->palette[index].blue, ppixel);
SET_DATA_BYTE(ppixel, L_ALPHA_CHANNEL,copy->alpha[index]);
ppixel++;
}
}
BOX *crop_points = ignore_alpha_at_edge(copy->alpha, copy->data, w, h, color_pix, &color_pix_out);
#ifdef OCR_DEBUG
{
char str[128] = "";
static int i = 0;
sprintf(str,"temp/file_c_%d.png",i);
pixWrite(str, cpix, IFF_PNG);
sprintf(str,"temp/file_c_%d.jpg",i);
pixWrite(str, color_pix_out, IFF_JFIF_JPEG);
i++;
}
#endif
@@ -184,8 +240,242 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i
printf("\nsomething messy\n");
text_out = TessBaseAPIGetUTF8Text(ctx->api);
// Begin color detection
if(ccx_options.dvbcolor && strlen(text_out)>0)
{
float h0 = -100;
int written_tag = 0;
TessBaseAPISetImage2(ctx->api, color_pix_out);
tess_ret = TessBaseAPIRecognize(ctx->api, NULL);
if( tess_ret != 0)
printf("\nsomething messy\n");
TessResultIterator* ri = TessBaseAPIGetIterator(ctx->api);
TessPageIteratorLevel level = RIL_WORD;
if(ri!=0)
{
do
{
char* word = TessResultIteratorGetUTF8Text(ri,level);
float conf = TessResultIteratorConfidence(ri,level);
int x1, y1, x2, y2;
TessPageIteratorBoundingBox((TessPageIterator *)ri,level, &x1, &y1, &x2, &y2);
// printf("word: '%s'; \tconf: %.2f; BoundingBox: %d,%d,%d,%d;",word, conf, x1, y1, x2, y2);
// printf("word: '%s';", word);
// {
// char str[128] = "";
// static int i = 0;
// sprintf(str,"temp/file_c_%d.jpg",i);
// pixWrite(str, pixClipRectangle(color_pix_out, boxCreate(x1,y1,x2-x1,y2-y1) ,NULL), IFF_JFIF_JPEG);
// i++;
// }
uint32_t *histogram = NULL;
uint8_t *iot = NULL;
uint32_t *mcit = NULL;
int ret = 0;
int max_color=2;
histogram = (uint32_t*) malloc(copy->nb_colors * sizeof(uint32_t));
iot = (uint8_t*) malloc(copy->nb_colors * sizeof(uint8_t));
mcit = (uint32_t*) malloc(copy->nb_colors * sizeof(uint32_t));
struct transIntensity ti = {copy->alpha,copy->palette};
memset(histogram, 0, copy->nb_colors * sizeof(uint32_t));
/* initializing intensity ordered table with serial order of unsorted color table */
for (int i = 0; i < copy->nb_colors; i++)
{
iot[i] = i;
}
memset(mcit, 0, copy->nb_colors * sizeof(uint32_t));
/* calculate histogram of image */
int firstpixel = copy->data[0]; //TODO: Verify this border pixel assumption holds
for(int i=y1;i<=y2;i++)
{
for(int j=x1;j<=x2;j++)
{
if(copy->data[(crop_points->y+i)*w + (crop_points->x+j)]!=firstpixel)
histogram[copy->data[(crop_points->y+i)*w + (crop_points->x+j)]]++;
}
}
/* sorted in increasing order of intensity */
shell_sort((void*)iot, copy->nb_colors, sizeof(*iot), check_trans_tn_intensity, (void*)&ti);
// ccx_common_logging.log_ftn("Intensity ordered table\n");
// for (int i = 0; i < copy->nb_colors; i++)
// {
// ccx_common_logging.log_ftn("%02d) map %02d hist %02d\n",
// i, iot[i], histogram[iot[i]]);
// }
/**
* using selection sort since need to find only max_color
* Histogram becomes invalid in this loop
*/
for (int i = 0; i < max_color; i++)
{
uint32_t max_val = 0;
uint32_t max_ind = 0;
int j;
for (j = 0; j < copy->nb_colors; j++)
{
if (max_val < histogram[iot[j]])
{
max_val = histogram[iot[j]];
max_ind = j;
}
}
for (j = i; j > 0 && max_ind < mcit[j - 1]; j--)
{
mcit[j] = mcit[j - 1];
}
mcit[j] = max_ind;
histogram[iot[max_ind]] = 0;
}
for (int i = 0; i < copy->nb_colors; i++)
{
palette[i].red = copy->palette[i].red;
palette[i].green = copy->palette[i].green;
palette[i].blue = copy->palette[i].blue;
alpha[i]=copy->alpha[i];
}
for (int i = 0, mxi = 0; i < copy->nb_colors; i++)
{
int step, inc;
if (i == mcit[mxi])
{
mxi = (mxi < max_color) ? mxi + 1 : mxi;
continue;
}
inc = (mxi) ? -1 : 0;
step = mcit[mxi + inc] + ((mcit[mxi] - mcit[mxi + inc]) / 2);
if (i <= step)
{
int index = iot[mcit[mxi + inc]];
alpha[iot[i]] = alpha[index];
palette[iot[i]].red = palette[index].red;
palette[iot[i]].blue = palette[index].blue;
palette[iot[i]].green = palette[index].green;
}
else
{
int index = iot[mcit[mxi]];
alpha[iot[i]] = alpha[index];
palette[iot[i]].red = palette[index].red;
palette[iot[i]].blue = palette[index].blue;
palette[iot[i]].green = palette[index].green;
}
}
// Detecting the color present in quantized word image
int r_avg=0,g_avg=0,b_avg=0,denom=0;
for (int i = 0; i < copy->nb_colors; i++)
{
if(palette[i].red == ((copy->bgcolor >> 16) & 0xff) &&
palette[i].green == ((copy->bgcolor >> 8) & 0xff) &&
palette[i].blue == ((copy->bgcolor >> 0) & 0xff))
continue;
denom++;
r_avg+=palette[i].red;
g_avg+=palette[i].green;
b_avg+=palette[i].blue;
}
if(denom!=0)
{
r_avg/=denom;
g_avg/=denom;
b_avg/=denom;
}
// Getting the hue value
float h;
float max = (((r_avg > g_avg) && (r_avg > b_avg)) ? r_avg : (g_avg > b_avg) ? g_avg : b_avg);
float min = (((r_avg < g_avg) && (r_avg < b_avg)) ? r_avg : (g_avg < b_avg) ? g_avg : b_avg);
if(max==0.0f||max-min==0.0f) h = 0;
else if(max==r_avg) h = 60 * ((g_avg - b_avg)/(max - min)) + 0;
else if(max==g_avg) h = 60 * ((b_avg - r_avg)/(max - min)) + 120;
else h = 60 * ((r_avg - g_avg)/(max - min)) + 240;
if(abs(h-h0)>50) // Color has changed
{
// Write <font> tags for SRT and WebVTT
if(ccx_options.write_format==CCX_OF_SRT ||
ccx_options.write_format==CCX_OF_WEBVTT)
{
char *substr;
if(written_tag)
{
substr = (char*)malloc(sizeof("</font><font color=\"#000000\">"));
sprintf(substr,"</font><font color=\"#%02x%02x%02x\">",r_avg,g_avg,b_avg);
}
else
{
substr = (char*)malloc(sizeof("<font color=\"#000000\">"));
sprintf(substr,"<font color=\"#%02x%02x%02x\">",r_avg,g_avg,b_avg);
}
if(strstr(text_out,word))
{
char *text_out_copy = strdup(text_out);
free(text_out);
text_out = malloc(strlen(text_out_copy)+strlen(substr)+1);
memset(text_out,0,strlen(text_out_copy)+strlen(substr)+1);
int pos = (int)(strstr(text_out_copy,word)-text_out_copy);
strncpy(text_out,text_out_copy,pos);
int len = strlen(text_out);
strcpy(text_out+len,substr);
strcpy(text_out+len+strlen(substr),text_out_copy+len);
free(text_out_copy);
written_tag = 1;
}
else if(!written_tag)
{
char *text_out_copy = strdup(text_out);
free(text_out);
text_out = malloc(strlen(text_out_copy)+strlen(substr)+1);
memset(text_out,0,strlen(text_out_copy)+strlen(substr)+1);
strcpy(text_out,substr);
strcpy(text_out+strlen(substr),text_out_copy);
written_tag = 1;
}
free(substr);
}
}
h0=h;
freep(&histogram);
freep(&mcit);
freep(&iot);
} while (TessPageIteratorNext((TessPageIterator *)ri,level));
//Write closing </font> at the end of the line
if(ccx_options.write_format==CCX_OF_SRT ||
ccx_options.write_format==CCX_OF_WEBVTT)
{
char *substr = "</font>";
char *text_out_copy = strdup(text_out);
free(text_out);
text_out = malloc(strlen(text_out_copy)+strlen(substr)+1);
memset(text_out,0,strlen(text_out_copy)+strlen(substr)+1);
char *str = strtok(text_out_copy,"\n");
strcpy(text_out,str);
strcpy(text_out+strlen(str),substr);
// printf("%s\n", text_out);
}
}
TessResultIteratorDelete(ri);
}
// End Color Detection
pixDestroy(&pix);
pixDestroy(&cpix);
pixDestroy(&color_pix);
pixDestroy(&color_pix_out);
return text_out;
}
@@ -336,33 +626,53 @@ static int quantize_map(png_byte *alpha, png_color *palette,
return ret;
}
int ocr_rect(void* arg, struct cc_bitmap *rect, char **str)
int ocr_rect(void* arg, struct cc_bitmap *rect, char **str, int bgcolor)
{
int ret = 0;
png_color *palette = NULL;
png_byte *alpha = NULL;
struct image_copy *copy;
copy = (struct image_copy *)malloc(sizeof(struct image_copy));
copy->nb_colors = rect->nb_colors;
copy->palette = (png_color*) malloc(rect->nb_colors * sizeof(png_color));
copy->alpha = (png_byte*) malloc(rect->nb_colors * sizeof(png_byte));
copy->bgcolor = bgcolor;
palette = (png_color*) malloc(rect->nb_colors * sizeof(png_color));
if(!palette)
if(!palette||!copy->palette)
{
ret = -1;
goto end;
}
alpha = (png_byte*) malloc(rect->nb_colors * sizeof(png_byte));
if(!alpha)
{
ret = -1;
goto end;
}
alpha = (png_byte*) malloc(rect->nb_colors * sizeof(png_byte));
if(!alpha||!copy->alpha)
{
ret = -1;
goto end;
}
mapclut_paletee(palette, alpha, (uint32_t *)rect->data[1],rect->nb_colors);
mapclut_paletee(palette, alpha, (uint32_t *)rect->data[1],rect->nb_colors);
mapclut_paletee(copy->palette, copy->alpha, (uint32_t *)rect->data[1],rect->nb_colors);
quantize_map(alpha, palette, rect->data[0], rect->w * rect->h, 3, rect->nb_colors);
*str = ocr_bitmap(arg, palette, alpha, rect->data[0], rect->w, rect->h);
int size = rect->w * rect->h;
copy->data = (unsigned char *)malloc(sizeof(unsigned char)*size);
for(int i = 0; i < size; i++)
{
copy->data[i] = rect->data[0][i];
}
quantize_map(alpha, palette, rect->data[0], size, 3, rect->nb_colors);
*str = ocr_bitmap(arg, palette, alpha, rect->data[0], rect->w, rect->h, copy);
end:
freep(&palette);
freep(&alpha);
freep(&copy->palette);
freep(&copy->alpha);
freep(&copy->data);
freep(&copy);
return ret;
}
@@ -390,11 +700,29 @@ int compare_rect_by_ypos(const void*p1, const void *p2, void*arg)
}
}
void add_ocrtext2str(char *dest, char *src, const char *crlf, unsigned crlf_length)
{
while (*dest != '\0')
dest++;
while(*src != '\0' && *src != '\n')
{
*dest = *src;
src++;
dest++;
}
memcpy(dest, crlf, crlf_length);
dest[crlf_length] = 0;
/*
*dest++ = '\n';
*dest = '\0'; */
}
/**
* Check multiple rectangles and combine them to give one paragraph
* for all text detected from rectangles
*/
char *paraof_ocrtext(struct cc_subtitle *sub)
char *paraof_ocrtext(struct cc_subtitle *sub, const char *crlf, unsigned crlf_length)
{
int i;
int len = 0;
@@ -411,7 +739,7 @@ char *paraof_ocrtext(struct cc_subtitle *sub)
return NULL;
else
{
str = malloc(len+1);
str = malloc(len+1+10); //Extra space for possible trailing '/n's at the end of tesseract UTF8 text
if(!str)
return NULL;
*str = '\0';
@@ -419,13 +747,13 @@ char *paraof_ocrtext(struct cc_subtitle *sub)
for(i = 0, rect = sub->data; i < sub->nb_data; i++, rect++)
{
strcat(str, rect->ocr_text);
freep(&rect->ocr_text);
add_ocrtext2str(str, rect->ocr_text, crlf, crlf_length);
TessDeleteText(rect->ocr_text);
}
return str;
}
#else
char* ocr_bitmap(png_color *palette,png_byte *alpha, unsigned char* indata,unsigned char d,int w, int h)
char* ocr_bitmap(png_color *palette,png_byte *alpha, unsigned char* indata,unsigned char d,int w, int h, struct image_copy *copy)
{
mprint("ocr not supported without tesseract\n");
return NULL;

View File

@@ -2,10 +2,19 @@
#define OCR_H
#include <png.h>
struct image_copy //A copy of the original OCR image, used for color detection
{
int nb_colors;
png_color *palette;
png_byte *alpha;
unsigned char *data;
int bgcolor;
};
void delete_ocr (void** arg);
void* init_ocr(int lang_index);
char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* indata,int w, int h);
int ocr_rect(void* arg, struct cc_bitmap *rect, char **str);
char *paraof_ocrtext(struct cc_subtitle *sub);
char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* indata,int w, int h, struct image_copy *copy);
int ocr_rect(void* arg, struct cc_bitmap *rect, char **str, int bgcolor);
char *paraof_ocrtext(struct cc_subtitle *sub, const char *crlf, unsigned crlf_length);
#endif

View File

@@ -11,6 +11,9 @@ void dinit_write(struct ccx_s_write *wb)
if (wb->fh > 0)
close(wb->fh);
freep(&wb->filename);
if (wb->with_semaphore && wb->semaphore_filename)
unlink(wb->semaphore_filename);
freep(&wb->semaphore_filename);
}
int temporarily_close_output(struct ccx_s_write *wb)
@@ -18,6 +21,7 @@ int temporarily_close_output(struct ccx_s_write *wb)
close(wb->fh);
wb->fh = -1;
wb->temporarily_closed = 1;
return 0;
}
int temporarily_open_output(struct ccx_s_write *wb)
@@ -41,18 +45,38 @@ int temporarily_open_output(struct ccx_s_write *wb)
int init_write (struct ccx_s_write *wb, char *filename)
int init_write (struct ccx_s_write *wb, char *filename, int with_semaphore)
{
memset(wb, 0, sizeof(struct ccx_s_write));
wb->fh=-1;
wb->temporarily_closed = 0;
wb->filename = filename;
wb->with_semaphore = with_semaphore;
wb->append_mode = ccx_options.enc_cfg.append_mode;
mprint ("Creating %s\n", filename);
wb->fh = open (filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
if(!(wb->append_mode))
wb->fh = open (filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
else
wb->fh = open (filename, O_RDWR | O_CREAT | O_APPEND | O_BINARY, S_IREAD | S_IWRITE);
wb->renaming_extension = 0;
if (wb->fh == -1)
{
return CCX_COMMON_EXIT_FILE_CREATION_FAILED;
}
if (with_semaphore)
{
wb->semaphore_filename = (char *)malloc(strlen(filename) + 6);
if (!wb->semaphore_filename)
return EXIT_NOT_ENOUGH_MEMORY;
sprintf(wb->semaphore_filename, "%s.sem", filename);
int t = open(wb->semaphore_filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
if (t == -1)
{
close(wb->fh);
return CCX_COMMON_EXIT_FILE_CREATION_FAILED;
}
close(t);
}
return EXIT_OK;
}

View File

@@ -5,6 +5,11 @@
#include "ccx_encoders_helpers.h"
#include "ccx_common_common.h"
#include "ccx_decoders_708.h"
#include "compile_info.h"
#include "../lib_hash/sha2.h"
#ifdef ENABLE_HARDSUBX
#include "hardsubx.h"
#endif
static int inputfile_capacity=0;
@@ -274,7 +279,7 @@ void usage (void)
mprint (" .mp4, HDHomeRun are known to work).\n\n");
mprint (" Syntax:\n");
mprint (" ccextractor [options] inputfile1 [inputfile2...] [-o outputfilename]\n");
mprint (" [-o1 outputfilename1] [-o2 outputfilename2]\n\n");
mprint ("\n");
mprint ("To see This Help Message: -h or --help\n\n");
mprint ("File name related options:\n");
mprint (" inputfile: file(s) to process\n");
@@ -307,17 +312,21 @@ void usage (void)
mprint (" port) instead of reading a file. Host can be a\n");
mprint (" hostname or IPv4 address. If host is not specified\n");
mprint (" then listens on the local host.\n\n");
mprint (" -sendto host[:port]: Sends data in BIN format to the server according\n");
mprint (" to the CCExtractor's protocol over TCP. For IPv6\n");
mprint (" use [addres]:port\n");
mprint (" -tcp port: Reads the input data in BIN format according to CCExtractor's\n");
mprint (" protocol, listening specified port on the local host\n");
mprint (" -tcppassword password: Sets server password for new connections to tcp server\n");
mprint (" -tcpdesc description: Sends to the server short description about captions e.g.\n");
mprint (" channel name or file name\n");
mprint (" -sendto host[:port]: Sends data in BIN format to the server\n");
mprint (" according to the CCExtractor's protocol over\n");
mprint (" TCP. For IPv6 use [address]:port\n");
mprint (" -tcp port: Reads the input data in BIN format according to\n");
mprint (" CCExtractor's protocol, listening specified port on the\n");
mprint (" local host\n");
mprint (" -tcppassword password: Sets server password for new connections to\n");
mprint (" tcp server\n");
mprint (" -tcpdesc description: Sends to the server short description about\n");
mprint (" captions e.g. channel name or file name\n");
mprint ("Options that affect what will be processed:\n");
mprint (" -1, -2, -12: Output Field 1 data, Field 2 data, or both\n");
mprint (" (DEFAULT is -1)\n");
mprint ("Use --append to prevent overwriting of existing files. The output will be\n");
mprint (" appended instead.\n");
mprint (" -cc2: When in srt/sami mode, process captions in channel 2\n");
mprint (" instead of channel 1.\n");
mprint ("-svc --service N1[cs1],N2[cs2]...:\n");
@@ -327,11 +336,12 @@ void usage (void)
mprint (" primary and secondary language services.\n");
mprint (" Pass \"all\" to process all services found.\n");
mprint ("\n");
mprint (" If captions in a service are stored in 16-bit encoding, you can\n");
mprint (" specify what charset or encoding was used. Pass its name after\n");
mprint (" service number (e.g. \"1[EUC-KR],3\" or \"all[EUC-KR]\") and it will\n");
mprint (" encode specified charset to UTF-8 using iconv. See iconv documentation\n");
mprint (" to check if required encoding/charset is supported.\n");
mprint (" If captions in a service are stored in 16-bit encoding,\n");
mprint (" you can specify what charset or encoding was used. Pass\n");
mprint (" its name after service number (e.g. \"1[EUC-KR],3\" or\n");
mprint (" \"all[EUC-KR]\") and it will encode specified charset to\n");
mprint (" UTF-8 using iconv. See iconv documentation to check if\n");
mprint (" required encoding/charset is supported.\n");
mprint ("\n");
mprint ("In general, if you want English subtitles you don't need to use these options\n");
mprint ("as they are broadcast in field 1, channel 1. If you want the second language\n");
@@ -458,13 +468,13 @@ void usage (void)
mprint (" --noscte20: Ignore SCTE-20 data if present.\n");
mprint ("\n");
mprint ("Options that affect what kind of output will be produced:\n");
mprint(" -bom: Append a BOM (Byte Order Mark) to output files.\n");
mprint(" Note that most text processing tools in linux will not\n");
mprint(" like BOM.\n");
mprint(" This is the default in Windows builds.\n");
mprint(" -nobom: Do not append a BOM (Byte Order Mark) to output files.\n");
mprint(" Note that this may break files when using Windows.\n");
mprint(" This is the default in non-Windows builds.\n");
mprint (" -bom: Append a BOM (Byte Order Mark) to output files.\n");
mprint (" Note that most text processing tools in linux will not\n");
mprint (" like BOM.\n");
mprint (" This is the default in Windows builds.\n");
mprint (" -nobom: Do not append a BOM (Byte Order Mark) to output\n");
mprint (" files. Note that this may break files when using\n");
mprint (" Windows. This is the default in non-Windows builds.\n");
mprint (" -unicode: Encode subtitles in Unicode instead of Latin-1.\n");
mprint (" -utf8: Encode subtitles in UTF-8 (no longer needed.\n");
mprint (" because UTF-8 is now the default).\n");
@@ -507,10 +517,12 @@ void usage (void)
mprint (" -autodash: Based on position on screen, attempt to determine\n");
mprint (" the different speakers and a dash (-) when each\n");
mprint (" of them talks (.srt/.vtt only, -trim required).\n");
mprint (" -xmltv mode: produce an XMLTV file containing the EPG data from\n");
mprint (" -xmltv mode: produce an XMLTV file containing the EPG data from\n");
mprint (" the source TS file. Mode: 1 = full output\n");
mprint (" 2 = live output. 3 = both\n\n");
mprint (" 2 = live output. 3 = both\n");
mprint (" -sem: Create a .sem file for each output file that is open\n");
mprint (" and delete it on file close.\n");
mprint ("\n");
mprint ("Options that affect how ccextractor reads and writes (buffering):\n");
mprint (" -bi --bufferinput: Forces input buffering.\n");
@@ -656,27 +668,29 @@ void usage (void)
mprint (" then CEA-608/708 processing is disabled).\n");
mprint ("\n");
mprint("Transcript customizing options:\n");
mprint ("Transcript customizing options:\n");
mprint(" -customtxt format: Use the passed format to customize the (Timed) Transcript\n");
mprint(" output. The format must be like this: 1100100 (7 digits).\n");
mprint(" These indicate whether the next things should be displayed\n");
mprint(" or not in the (timed) transcript. They represent (in order):\n");
mprint(" - Display start time\n");
mprint(" - Display end time\n");
mprint(" - Display caption mode\n");
mprint(" - Display caption channel\n");
mprint(" - Use a relative timestamp ( relative to the sample)\n");
mprint(" - Display XDS info\n");
mprint(" - Use colors\n");
mprint(" Examples:\n");
mprint(" 0000101 is the default setting for transcripts\n");
mprint(" 1110101 is the default for timed transcripts\n");
mprint(" 1111001 is the default setting for -ucla\n");
mprint(" Make sure you use this parameter after others that might\n");
mprint(" affect these settings (-out, -ucla, -xds, -txt, -ttxt, ...)\n");
mprint (" -customtxt format: Use the passed format to customize the (Timed) Transcript\n");
mprint (" output. The format must be like this: 1100100 (7 digits).\n");
mprint (" These indicate whether the next things should be\n");
mprint (" displayed or not in the (timed) transcript. They\n");
mprint (" represent (in order): \n");
mprint (" - Display start time\n");
mprint (" - Display end time\n");
mprint (" - Display caption mode\n");
mprint (" - Display caption channel\n");
mprint (" - Use a relative timestamp ( relative to the sample)\n");
mprint (" - Display XDS info\n");
mprint (" - Use colors\n");
mprint (" Examples:\n");
mprint (" 0000101 is the default setting for transcripts\n");
mprint (" 1110101 is the default for timed transcripts\n");
mprint (" 1111001 is the default setting for -ucla\n");
mprint (" Make sure you use this parameter after others that might\n");
mprint (" affect these settings (-out, -ucla, -xds, -txt, \n");
mprint (" -ttxt ...)\n");
mprint("\n");
mprint ("\n");
mprint ("Communication with other programs and console output:\n");
@@ -716,6 +730,92 @@ void usage (void)
mprint(" /tmp/output_2.d/sub0000.png\n");
mprint(" /tmp/output_2.d/sub0001.png\n");
mprint(" ...\n");
mprint("\n");
mprint("Burned-in subtitle extraction:\n");
mprint(" -hardsubx : Enable the burned-in subtitle extraction subsystem.\n");
mprint("\n");
mprint(" NOTE: The following options will work only if -hardsubx is \n");
mprint(" specified before them:-\n");
mprint("\n");
mprint(" -ocr_mode : Set the OCR mode to either frame-wise, word-wise\n");
mprint(" or letter wise.\n");
mprint(" e.g. -ocr_mode frame (default), -ocr_mode word, \n");
mprint(" -ocr_mode letter\n");
mprint("\n");
mprint(" -subcolor : Specify the color of the subtitles\n");
mprint(" Possible values are in the set \n");
mprint(" {white,yellow,green,cyan,blue,magenta,red}.\n");
mprint(" Alternatively, a custom hue value between 1 and 360 \n");
mprint(" may also be specified.\n");
mprint(" e.g. -subcolor white or -subcolor 270 (for violet).\n");
mprint(" Refer to an HSV color chart for values.\n");
mprint("\n");
mprint(" -min_sub_duration : Specify the minimum duration that a subtitle line \n");
mprint(" must exist on the screen.\n");
mprint(" The value is specified in seconds.\n");
mprint(" A lower value gives better results, but takes more \n");
mprint(" processing time.\n");
mprint(" The recommended value is 0.5 (default).\n");
mprint(" e.g. -min_sub_duration 1.0 (for a duration of 1 second)\n");
mprint("\n");
mprint(" -detect_italics : Specify whether italics are to be detected from the \n");
mprint(" OCR text.\n");
mprint(" Italic detection automatically enforces the OCR mode \n");
mprint(" to be word-wise");
mprint("\n");
mprint(" -conf_thresh : Specify the classifier confidence threshold between\n");
mprint(" 1 and 100.\n");
mprint(" Try and use a threshold which works for you if you get \n");
mprint(" a lot of garbage text.\n");
mprint(" e.g. -conf_thresh 50\n");
mprint("\n");
mprint(" -whiteness_thresh : For white subtitles only, specify the luminance \n");
mprint(" threshold between 1 and 100\n");
mprint(" This threshold is content dependent, and adjusting\n");
mprint(" values may give you better results\n");
mprint(" Recommended values are in the range 80 to 100.\n");
mprint(" The default value is 95\n");
mprint("\n");
mprint("An example command is as follows:-\n");
mprint("ccextractor video.mp4 -hardsubx -subcolor white -detect_italics \n");
mprint("-whiteness_thresh 90 -conf_thresh 60\n");
mprint("\n");
}
unsigned char sha256_buf[16384];
char *calculateSHA256(char *location) {
int size_read, bytes_read, fh = 0;
SHA256_CTX ctx256;
SHA256_Init(&ctx256);
#ifdef _WIN32
fh = OPEN(location, O_RDONLY | O_BINARY);
#else
fh = OPEN(location, O_RDONLY);
#endif
if (fh < 0) {
return "Could not open file";
}
size_read = 0;
while ((bytes_read = read(fh, sha256_buf, 16384)) > 0) {
size_read += bytes_read;
SHA256_Update(&ctx256, (unsigned char*)sha256_buf, bytes_read);
}
close(fh);
SHA256_End(&ctx256, sha256_buf);
return sha256_buf;
}
void version(char *location) {
char *hash = calculateSHA256(location);
mprint("CCExtractor detailed version info\n");
mprint(" Version: %s\n", VERSION);
mprint(" Git commit: %s\n", GIT_COMMIT);
mprint(" Compilation date: %s\n", COMPILE_DATE);
mprint(" File SHA256: %s\n", hash);
}
void parse_708_services (struct ccx_s_options *opts, char *s)
@@ -842,6 +942,11 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
usage();
return EXIT_WITH_HELP;
}
if (!strcmp(argv[i], "--version"))
{
version(argv[0]);
return EXIT_WITH_HELP;
}
if (strcmp (argv[i], "-")==0 || strcmp(argv[i], "-stdin") == 0)
{
@@ -867,6 +972,168 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
}
continue;
}
#ifdef ENABLE_HARDSUBX
// Parse -hardsubx and related parameters
if (strcmp(argv[i], "-hardsubx")==0)
{
opt->hardsubx = 1;
continue;
}
if (opt->hardsubx == 1)
{
if (strcmp(argv[i], "-ocr_mode")==0)
{
if(i < argc - 1)
{
if(strcmp(argv[i+1], "simple")==0 || strcmp(argv[i+1], "frame")==0)
{
opt->hardsubx_ocr_mode = HARDSUBX_OCRMODE_FRAME;
}
else if(strcmp(argv[i+1], "word")==0)
{
opt->hardsubx_ocr_mode = HARDSUBX_OCRMODE_WORD;
}
else if(strcmp(argv[i+1], "letter")==0 || strcmp(argv[i+1], "symbol")==0)
{
opt->hardsubx_ocr_mode = HARDSUBX_OCRMODE_LETTER;
}
else
{
fatal (EXIT_MALFORMED_PARAMETER, "-ocr_mode has an invalid value.\nValid values are {frame,word,letter}");
}
}
else
{
fatal (EXIT_MALFORMED_PARAMETER, "-ocr_mode has no argument.\nValid values are {frame,word,letter}");
}
i++;
continue;
}
if (strcmp(argv[i], "-subcolor")==0 || strcmp(argv[i], "-sub_color")==0)
{
if(i < argc - 1)
{
if(strcmp(argv[i+1], "white")==0)
{
opt->hardsubx_subcolor = HARDSUBX_COLOR_WHITE;
opt->hardsubx_hue = 0.0;
}
else if(strcmp(argv[i+1], "yellow")==0)
{
opt->hardsubx_subcolor = HARDSUBX_COLOR_YELLOW;
opt->hardsubx_hue = 60.0;
}
else if(strcmp(argv[i+1], "green")==0)
{
opt->hardsubx_subcolor = HARDSUBX_COLOR_GREEN;
opt->hardsubx_hue = 120.0;
}
else if(strcmp(argv[i+1], "cyan")==0)
{
opt->hardsubx_subcolor = HARDSUBX_COLOR_CYAN;
opt->hardsubx_hue = 180.0;
}
else if(strcmp(argv[i+1], "blue")==0)
{
opt->hardsubx_subcolor = HARDSUBX_COLOR_BLUE;
opt->hardsubx_hue = 240.0;
}
else if(strcmp(argv[i+1], "magenta")==0)
{
opt->hardsubx_subcolor = HARDSUBX_COLOR_MAGENTA;
opt->hardsubx_hue = 300.0;
}
else if(strcmp(argv[i+1], "red")==0)
{
opt->hardsubx_subcolor = HARDSUBX_COLOR_RED;
opt->hardsubx_hue = 0.0;
}
else
{
// Take a custom hue from the user
opt->hardsubx_subcolor = HARDSUBX_COLOR_CUSTOM;
char *str=(char*)malloc(sizeof(argv[i+1]));
sprintf(str,"%s", argv[i+1]); // Done this way to avoid error with getting (i+1)th env variable
opt->hardsubx_hue = atof(str);
if(opt->hardsubx_hue <= 0.0 || opt->hardsubx_hue > 360.0)
{
fatal (EXIT_MALFORMED_PARAMETER, "-subcolor has either 0 or an invalid hue value supplied.\nIf you want to detect red subtitles, pass '-subcolor red' or a slightly higher hue value (e.g. 0.1)\n");
}
}
}
else
{
fatal (EXIT_MALFORMED_PARAMETER, "-subcolor has no argument.\nValid values are {white,yellow,green,cyan,blue,magenta,red} or a custom hue value between 0 and 360\n");
}
i++;
continue;
}
if (strcmp(argv[i], "-min_sub_duration")==0)
{
if(i < argc - 1)
{
char *str=(char*)malloc(sizeof(argv[i+1]));
sprintf(str,"%s", argv[i+1]); // Done this way to avoid error with getting (i+1)th env variable
opt->hardsubx_min_sub_duration = atof(str);
if(opt->hardsubx_min_sub_duration == 0.0)
{
fatal (EXIT_MALFORMED_PARAMETER, "-min_sub_duration has either 0 or an invalid value supplied\n");
}
}
else
{
fatal (EXIT_MALFORMED_PARAMETER, "-min_sub_duration has no argument.");
}
i++;
continue;
}
if (strcmp(argv[i], "-detect_italics")==0)
{
opt->hardsubx_detect_italics = 1;
continue;
}
if (strcmp(argv[i], "-conf_thresh")==0)
{
if(i < argc - 1)
{
char *str=(char*)malloc(sizeof(argv[i+1]));
sprintf(str,"%s", argv[i+1]); // Done this way to avoid error with getting (i+1)th env variable
opt->hardsubx_conf_thresh = atof(str);
if(opt->hardsubx_conf_thresh <= 0.0 || opt->hardsubx_conf_thresh > 100.0)
{
fatal (EXIT_MALFORMED_PARAMETER, "-conf_thresh has either 0 or an invalid value supplied\nValid values are in (0.0,100.0)");
}
}
else
{
fatal (EXIT_MALFORMED_PARAMETER, "-conf_thresh has no argument.");
}
i++;
continue;
}
if (strcmp(argv[i], "-whiteness_thresh")==0 || strcmp(argv[i], "-lum_thresh")==0)
{
if(i < argc - 1)
{
char *str=(char*)malloc(sizeof(argv[i+1]));
sprintf(str,"%s", argv[i+1]); // Done this way to avoid error with getting (i+1)th env variable
opt->hardsubx_lum_thresh = atof(str);
if(opt->hardsubx_lum_thresh <= 0.0 || opt->hardsubx_conf_thresh > 100.0)
{
fatal (EXIT_MALFORMED_PARAMETER, "-whiteness_thresh has either 0 or an invalid value supplied\nValid values are in (0.0,100.0)");
}
}
else
{
fatal (EXIT_MALFORMED_PARAMETER, "-whiteness_thresh has no argument.");
}
i++;
continue;
}
}
#endif
if (strcmp (argv[i],"-bi")==0 ||
strcmp (argv[i],"--bufferinput")==0)
{
@@ -889,7 +1156,11 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
opt->force_flush = 1;
continue;
}
if (strcmp(argv[i], "--append") == 0)
{
opt->append_mode = 1;
continue;
}
if ((strcmp (argv[i],"-bs")==0 || strcmp (argv[i],"--buffersize")==0) && i<argc-1)
{
FILEBUFFERSIZE = atol_size(argv[i+1]);
@@ -922,6 +1193,10 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
opt->enc_cfg.no_bom = 1;
continue;
}
if (strcmp(argv[i], "-sem") == 0){
opt->enc_cfg.with_semaphore = 1;
continue;
}
if (strcmp (argv[i],"-nots")==0 ||
strcmp (argv[i],"--notypesetting")==0)
{
@@ -986,6 +1261,33 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
}
continue;
}
if(strcmp(argv[i],"-dvbcolor")==0)
{
opt->dvbcolor = 1;
continue;
}
if(strcmp(argv[i],"-dvblang")==0 && i < argc-1)
{
i++;
opt->dvblang = (char *)malloc(sizeof(argv[i]));
sprintf(opt->dvblang,"%s",argv[i]);
for(int char_index=0; char_index < strlen(opt->dvblang);char_index++)
opt->dvblang[char_index] = cctolower(opt->dvblang[char_index]);
continue;
}
if(strcmp(argv[i],"-ocrlang")==0 && i < argc-1)
{
i++;
opt->ocrlang = (char *)malloc(sizeof(argv[i]));
sprintf(opt->ocrlang,"%s",argv[i]);
for(int char_index=0; char_index < strlen(opt->ocrlang);char_index++)
opt->ocrlang[char_index] = cctolower(opt->ocrlang[char_index]);
continue;
}
/* Output file formats */
if (strcmp (argv[i],"-srt")==0 ||
strcmp (argv[i],"-dvdraw")==0 ||
@@ -1521,6 +1823,11 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
opt->enc_cfg.autodash = 1;
continue;
}
if (strcmp(argv[i], "-sem") == 0)
{
opt->enc_cfg.autodash = 1;
continue;
}
if (strcmp (argv[i],"-xmltv")==0)
{
if (i==argc-1 // Means no following argument
@@ -1825,6 +2132,7 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
opt->enc_cfg.millis_separator = opt->millis_separator;
opt->enc_cfg.no_font_color = opt->nofontcolor;
opt->enc_cfg.force_flush = opt->force_flush;
opt->enc_cfg.append_mode = opt->append_mode;
opt->enc_cfg.ucla = opt->ucla;
opt->enc_cfg.no_type_setting = opt->notypesetting;
opt->enc_cfg.subs_delay = opt->subs_delay;

View File

@@ -225,8 +225,7 @@ void print_cc_report(struct lib_ccx_ctx *ctx, struct cap_info* info)
}
void print_file_report(struct lib_ccx_ctx *ctx)
{
struct lib_cc_decode *dec_ctx = NULL;
enum ccx_stream_mode_enum stream_mode;
struct lib_cc_decode *dec_ctx = NULL;
struct ccx_demuxer *demux_ctx = ctx->demux_ctx;
printf("File: ");

View File

@@ -22,8 +22,6 @@ void init_hdcc (struct lib_cc_decode *ctx)
// Buffer caption blocks for later sorting/flushing.
void store_hdcc(struct lib_cc_decode *ctx, unsigned char *cc_data, int cc_count, int sequence_number, LLONG current_fts_now, struct cc_subtitle *sub)
{
enum ccx_stream_mode_enum stream_mode;
//stream_mode = ctx->demux_ctx->get_stream_mode(ctx->demux_ctx);
// Uninitialized?
if (ctx->anchor_seq_number < 0)

View File

@@ -298,7 +298,7 @@ void draw_char_indexed(uint8_t * canvas, int rowstride, uint8_t * pen,
underline * (3 << 24) /* cell row 24, 25 */);
}
void write_sputag(struct spupng_t *sp,LLONG ms_start,LLONG ms_end)
void write_sputag_open (struct spupng_t *sp,LLONG ms_start,LLONG ms_end)
{
fprintf(sp->fpxml, "<spu start=\"%.3f\"", ((double)ms_start) / 1000);
fprintf(sp->fpxml, " end=\"%.3f\"", ((double)ms_end) / 1000);
@@ -306,9 +306,13 @@ void write_sputag(struct spupng_t *sp,LLONG ms_start,LLONG ms_end)
fprintf(sp->fpxml, " xoffset=\"%d\"", sp->xOffset);
fprintf(sp->fpxml, " yoffset=\"%d\"", sp->yOffset);
fprintf(sp->fpxml, ">\n");
fprintf(sp->fpxml, "</spu>\n");
}
void write_sputag_close(struct spupng_t *sp)
{
fprintf(sp->fpxml, "</spu>\n");
}
void write_spucomment(struct spupng_t *sp,const char *str)
{
fprintf(sp->fpxml, "<!--\n");
@@ -467,20 +471,27 @@ int write_cc_bitmap_as_spupng(struct cc_subtitle *sub, struct encoder_ctx *conte
struct cc_bitmap* rect;
png_color *palette = NULL;
png_byte *alpha = NULL;
int wrote_opentag = 1;
x_pos = -1;
y_pos = -1;
width = 0;
height = 0;
if (context->prev_start != -1 && (sub->flags & SUB_EOD_MARKER))
write_sputag(sp, context->prev_start, sub->start_time);
else if ( !(sub->flags & SUB_EOD_MARKER))
write_sputag(sp, sub->start_time, sub->end_time);
write_sputag_open(sp, context->prev_start, sub->start_time);
else if (!(sub->flags & SUB_EOD_MARKER))
write_sputag_open(sp, sub->start_time, sub->end_time);
else
wrote_opentag = 0;
if(sub->nb_data == 0 && (sub->flags & SUB_EOD_MARKER))
{
context->prev_start = -1;
if (wrote_opentag)
write_sputag_close(sp);
return 0;
}
rect = sub->data;
@@ -521,7 +532,7 @@ int write_cc_bitmap_as_spupng(struct cc_subtitle *sub, struct encoder_ctx *conte
}
inc_spupng_fileindex(sp);
filename = get_spupng_filename(sp);
set_spupng_offset(sp,y_pos,x_pos);
set_spupng_offset(sp, x_pos, y_pos);
if ( sub->flags & SUB_EOD_MARKER )
context->prev_start = sub->start_time;
pbuf = (uint8_t*) malloc(width * height);
@@ -554,15 +565,29 @@ int write_cc_bitmap_as_spupng(struct cc_subtitle *sub, struct encoder_ctx *conte
/* TODO do rectangle wise, one color table should not be used for all rectangles */
mapclut_paletee(palette, alpha, (uint32_t *)rect[0].data[1],rect[0].nb_colors);
#ifdef ENABLE_OCR
if (rect[0].ocr_text && *(rect[0].ocr_text))
{
write_spucomment(sp, rect[0].ocr_text);
char *str;
str = paraof_ocrtext(sub, context->encoded_crlf, context->encoded_crlf_length);
if (str)
{
write_spucomment(sp, str);
freep(&str);
}
}
#endif
save_spupng(filename,pbuf,width, height, palette, alpha,rect[0].nb_colors);
freep(&pbuf);
end:
if (wrote_opentag)
write_sputag_close(sp);
for(i = 0, rect = sub->data; i < sub->nb_data; i++, rect++)
{
freep(rect->data);
freep(rect->data+1);
}
sub->nb_data = 0;
freep(&sub->data);
freep(&palette);

View File

@@ -28,7 +28,8 @@ void write_spumux_header(struct encoder_ctx *ctx, struct ccx_s_write *out);
void write_spumux_footer(struct ccx_s_write *out);
void draw_char_indexed(uint8_t * canvas, int rowstride, uint8_t * pen,
int unicode, int italic, int underline);
void write_sputag(struct spupng_t *sp,LLONG ms_start,LLONG ms_end);
void write_sputag_open(struct spupng_t *sp,LLONG ms_start,LLONG ms_end);
void write_sputag_close(struct spupng_t *sp);
void write_spucomment(struct spupng_t *sp,const char *str);
char* get_spupng_filename(void *ctx);
void inc_spupng_fileindex(void *ctx);

View File

@@ -34,6 +34,7 @@ Werner Brückner -- Teletext in digital television
#include "teletext.h"
#include <signal.h>
#include "activity.h"
#include "ccx_encoders_helpers.h"
#ifdef __MINGW32__
// switch stdin and all normal files into binary mode -- needed for Windows
@@ -125,6 +126,9 @@ struct TeletextCtx
uint8_t using_pts;
int64_t delta;
uint32_t t0;
int sentence_cap;//Set to 1 if -sc is passed
int new_sentence;
};
typedef enum
{
@@ -589,6 +593,36 @@ uint16_t bcd_page_to_int (uint16_t bcd)
return ((bcd&0xf00)>>8)*100 + ((bcd&0xf0)>>4)*10 + (bcd&0xf);
}
void telx_case_fix (struct TeletextCtx *context)
{
//Capitalizing first letter of every sentence
int line_len = strlen(context->page_buffer_cur);
for(int i = 0; i < line_len; i++)
{
switch(context->page_buffer_cur[i])
{
case ' ':
//case 0x89: // This is a transparent space
case '-':
break;
case '.': // Fallthrough
case '?': // Fallthrough
case '!':
case ':':
context->new_sentence = 1;
break;
default:
if (context->new_sentence)
context->page_buffer_cur[i] = cctoupper(context->page_buffer_cur[i]);
else
context->page_buffer_cur[i] = cctolower(context->page_buffer_cur[i]);
context->new_sentence = 0;
break;
}
}
telx_correct_case(context->page_buffer_cur);
}
void telxcc_dump_prev_page (struct TeletextCtx *ctx, struct cc_subtitle *sub)
{
char info[4];
@@ -892,6 +926,8 @@ void process_page(struct TeletextCtx *ctx, teletext_page_t *page, struct cc_subt
}
break;
default:
if (ctx->sentence_cap)
telx_case_fix(ctx);
add_cc_sub_text(sub, ctx->page_buffer_cur, page->show_timestamp,
page->hide_timestamp + 1, NULL, "TLT", CCX_ENC_UTF_8);
}
@@ -1282,7 +1318,7 @@ int tlt_print_seen_pages(struct lib_cc_decode *dec_ctx)
}
return CCX_OK;
}
int tlt_process_pes_packet(struct lib_cc_decode *dec_ctx, uint8_t *buffer, uint16_t size, struct cc_subtitle *sub)
int tlt_process_pes_packet(struct lib_cc_decode *dec_ctx, uint8_t *buffer, uint16_t size, struct cc_subtitle *sub, int sentence_cap)
{
uint64_t pes_prefix;
uint8_t pes_stream_id;
@@ -1292,6 +1328,7 @@ int tlt_process_pes_packet(struct lib_cc_decode *dec_ctx, uint8_t *buffer, uint1
uint32_t t = 0;
uint16_t i;
struct TeletextCtx *ctx = dec_ctx->private_data;
ctx->sentence_cap = sentence_cap;
if(!ctx)
{
@@ -1466,6 +1503,9 @@ void* telxcc_init(void)
ctx->delta = 0;
ctx->t0 = 0;
ctx->sentence_cap = 0;
ctx->new_sentence = 0;
return ctx;
}

View File

@@ -140,7 +140,7 @@ int ts_readpacket(struct ccx_demuxer* ctx, struct ts_payload *payload)
if (result != 4)
{
if (result>0)
mprint("Premature end of file!\n");
mprint("Premature end of file (incomplete TS packer header, expected 4 bytes, got %lld).\n",result);
return CCX_EOF;
}
}
@@ -150,7 +150,7 @@ int ts_readpacket(struct ccx_demuxer* ctx, struct ts_payload *payload)
if (result != 188)
{
if (result > 0)
mprint("Premature end of file!\n");
mprint("Premature end of file - Transport Stream packet is incomplete (expected 188 bytes, got %lld).\n", result);
return CCX_EOF;
}
@@ -221,8 +221,8 @@ int ts_readpacket(struct ccx_demuxer* ctx, struct ts_payload *payload)
// Take the PCR (Program Clock Reference) from here, in case PTS is not available (copied from telxcc).
adaptation_field_length = tspacket[4];
uint8_t af_pcr_exists = (tspacket[5] & 0x10) >> 4;
if (af_pcr_exists > 0 )
payload->have_pcr = (tspacket[5] & 0x10) >> 4;
if (payload->have_pcr)
{
payload->pcr = 0;
payload->pcr |= (tspacket[6] << 25);
@@ -518,8 +518,8 @@ int copy_payload_to_capbuf(struct cap_info *cinfo, struct ts_payload *payload)
if(payload->start[0] != 0x00 || payload->start[1] != 0x00 ||
payload->start[2] != 0x01)
{
mprint("Missing PES header!\n");
dump(CCX_DMT_GENERIC_NOTICES, payload->start, payload->length, 0, 0);
mprint("Notice: Missing PES header\n");
dump(CCX_DMT_DUMPDEF, payload->start, payload->length, 0, 0);
cinfo->saw_pesstart = 0;
errno = EINVAL;
return -1;
@@ -596,7 +596,9 @@ long ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data)
for (j = 0; j < ctx->nb_program; j++)
{
if (ctx->pinfo[j].analysed_PMT_once == CCX_TRUE && ctx->pinfo[j].pcr_pid == payload.pid)
if (ctx->pinfo[j].analysed_PMT_once == CCX_TRUE &&
ctx->pinfo[j].pcr_pid == payload.pid &&
payload.have_pcr)
{
ctx->last_global_timestamp = ctx->global_timestamp;
ctx->global_timestamp = (uint32_t) payload.pcr / 90;
@@ -686,15 +688,15 @@ long ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data)
}
// Skip packets with no payload. This also fixes the problems
// with the continuity counter not being incremented in empty
// packets.
if ( !payload.length )
{
dbg_print(CCX_DMT_VERBOSE, "Packet (pid %u) skipped - no payload.\n",
payload.pid);
continue;
}
// Skip packets with no payload. This also fixes the problems
// with the continuity counter not being incremented in empty
// packets.
if ( !payload.length )
{
dbg_print(CCX_DMT_VERBOSE, "Packet (pid %u) skipped - no payload.\n",
payload.pid);
continue;
}
cinfo = get_cinfo(ctx, payload.pid);

View File

@@ -9,6 +9,7 @@ struct ts_payload
unsigned pid; // Stream PID
int counter; // continuity counter
int transport_error; // 0 = packet OK, non-zero damaged
int have_pcr;
int64_t pcr;
unsigned char section_buf[4098];
int section_index;

View File

@@ -108,6 +108,12 @@ int parse_PMT (struct ccx_demuxer *ctx, unsigned char *buf, int len, struct pro
crc = (*(int32_t*)(sbuf+olen-4));
table_id = buf[0];
/* TO-DO: We're currently parsing the PMT making assumptions that there's only one section with table_id=2,
but that doesn't have to be the case. There's a sample (friends_tbs.ts) that shows a previous section with
table_id = 0xc0. I can't find any place that says that 0xc0 (Program Information Table) must come before
table_id = 2, so we should process sections in any order.
Check https://github.com/CCExtractor/ccextractor/issues/385 for more info
*/
if (table_id == 0xC0)
{
/*
@@ -116,13 +122,22 @@ int parse_PMT (struct ccx_demuxer *ctx, unsigned char *buf, int len, struct pro
* PROGRAM INFORMATION Table found in PMT
*/
dbg_print(CCX_DMT_PARSE, "PMT: PROGRAM INFORMATION Table need implementation");
return 0;
// For now, just parse its length and remove it from the buffer
unsigned c0length = (buf[1] << 8 | buf[2]) & 0xFFF; // 12 bytes
dbg_print(CCX_DMT_PARSE, "Program information table length: %u", c0length);
memmove(buf, buf + c0length + 3, len - c0length -3); // First 3 bytes are for the table_id and the length, don't count
table_id = buf[0];
// return 0;
}
else if (table_id == 0xC1)
{
//SCTE 57 2003
dbg_print(CCX_DMT_PARSE, "PMT: PROGRAM Name Table need implementation");
return 0;
dbg_print(CCX_DMT_PARSE, "PMT: PROGRAM NAME Table need implementation");
unsigned c0length = (buf[1] << 8 | buf[2]) & 0xFFF; // 12 bytes
dbg_print(CCX_DMT_PARSE, "Program name message length: %u", c0length);
memmove(buf, buf + c0length + 3, len - c0length - 3); // First 3 bytes are for the table_id and the length, don't count
table_id = buf[0];
//return 0;
}
else if(table_id != 0x2)
{

View File

@@ -1096,37 +1096,19 @@ void parse_EPG_packet(struct lib_ccx_ctx *ctx)
// Free all memory used for EPG parsing
void EPG_free(struct lib_ccx_ctx *ctx)
{
int i = 0, j;
if(ccx_options.xmltv==2 || ccx_options.xmltv==3 || ccx_options.send_to_srv)
{
if(ctx->epg_inited)
{
if (ccx_options.send_to_srv)
EPG_output_net(ctx);
else
EPG_output_live(ctx);
}
for (i = 0; i < TS_PMT_MAP_SIZE; i++)
{
for(j = 0; j < ctx->eit_programs[i].array_len; j++)
if(ccx_options.xmltv==2 || ccx_options.xmltv==3 || ccx_options.send_to_srv)
{
if(ctx->eit_programs[i].epg_events[j].has_simple)
{
free(ctx->eit_programs[i].epg_events[j].event_name);
free(ctx->eit_programs[i].epg_events[j].text);
}
if(ctx->eit_programs[i].epg_events[j].extended_text!=NULL)
free(ctx->eit_programs[i].epg_events[j].extended_text);
if(ctx->eit_programs[i].epg_events[j].num_ratings>0)
free(ctx->eit_programs[i].epg_events[j].ratings);
if(ctx->eit_programs[i].epg_events[j].num_categories>0)
free(ctx->eit_programs[i].epg_events[j].categories);
if (ccx_options.send_to_srv)
EPG_output_net(ctx);
else
EPG_output_live(ctx);
}
ctx->eit_programs[i].array_len=0;
}
for (i = 0; i < 0xfff; i++)
{
if(ctx->epg_buffers[i].buffer!=NULL)
free(ctx->epg_buffers[i].buffer);
}
free(ctx->epg_buffers);
free(ctx->eit_programs);
free(ctx->eit_current_events);
free(ctx->ATSC_source_pg_map);
}

View File

@@ -1,10 +1,13 @@
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include "lib_ccx.h"
#include "ccx_common_option.h"
#include "activity.h"
#include "utility.h"
int temp_debug = 0; // This is a convenience variable used to enable/disable debug on variable conditions. Find references to understand.
volatile sig_atomic_t change_filename_requested = 0;
static uint32_t crc32_table [] = {
@@ -371,7 +374,91 @@ void m_signal(int sig, void (*func)(int))
return;
}
void create_signal(void)
{
if (signal(SIGUSR1, signal_handler) == SIG_ERR)
mprint("Can't catch SIGUSR1.\n");
}
void signal_handler(int sig_type)
{
int ret;
if (sig_type == SIGUSR1)
{
mprint("Caught SIGUSR1. Filename Change Requested\n");
change_filename_requested = 1;
}
}
#endif
struct encoder_ctx *change_filename(struct encoder_ctx *enc_ctx)
{
if(change_filename_requested == 0)
{
return enc_ctx;
}
struct encoder_ctx *temp_encoder = malloc(sizeof(struct encoder_ctx));
*temp_encoder = *enc_ctx;
if (enc_ctx->out->fh != -1)
{
if (enc_ctx->out->fh > 0)
close(enc_ctx->out->fh);
enc_ctx->out->fh=-1;
int iter;
char str_number[15];
char *current_name = malloc(sizeof(char)*(strlen(enc_ctx->out->filename)+10));
strcpy(current_name,enc_ctx->out->filename);
mprint ("Creating %s\n", enc_ctx->out->filename);
if(enc_ctx->out->renaming_extension)
{
strcat(current_name,".");
sprintf(str_number, "%d", enc_ctx->out->renaming_extension);
strcat(current_name,str_number);
}
enc_ctx->out->renaming_extension++;
for (iter = enc_ctx->out->renaming_extension; iter >= 1; iter--)
{
int ret;
char new_extension[6];
sprintf(new_extension, ".%d", iter);
char *newname = malloc(sizeof(char)*(strlen(enc_ctx->out->filename)+10));
strcpy(newname,enc_ctx->out->filename);
strcat(newname,new_extension);
ret = rename(current_name, newname);
if(ret)
{
mprint("Failed to rename the file\n");
}
mprint ("Creating %s\n", newname);
strcpy(current_name,enc_ctx->out->filename);
if(iter-2>0)
{
strcat(current_name,".");
sprintf(str_number, "%d", iter-2);
strcat(current_name,str_number);
}
free(newname);
}
enc_ctx->out->fh = open(enc_ctx->out->filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
free(current_name);
if (enc_ctx->out->fh == -1)
{
mprint("Failed to create a new rotation file\n");
return temp_encoder;
}
free(temp_encoder);
change_filename_requested = 0;
return enc_ctx;
}
return temp_encoder;
}
char *get_basename(char *filename)
{
char *c;
@@ -518,6 +605,6 @@ char *strndup(const char *s, size_t n)
}
char *strtok_r(char *str, const char *delim, char **saveptr)
{
strtok_s(str, delim, saveptr);
return strtok_s(str, delim, saveptr);
}
#endif //_WIN32

View File

@@ -1,6 +1,6 @@
#ifndef CC_UTILITY_H
#define CC_UTILITY_H
#include <signal.h>
#ifndef _WIN32
#include <arpa/inet.h>
#endif
@@ -20,6 +20,7 @@ struct ccx_rational
int den;
};
extern int temp_debug;
volatile extern sig_atomic_t change_filename_requested;
void init_boundary_time (struct ccx_boundary_time *bt);
void print_error (int mode, const char *fmt, ...);
int stringztoms (const char *s, struct ccx_boundary_time *bt);

277
src/lib_hash/README Normal file
View File

@@ -0,0 +1,277 @@
VERSION:
This is version 1.0.1 RELEASE
While this is my "release" version, due to lack of additional
official test vectors against which to verify this implementation's
correctness, beware that there may be implementation bugs. Also,
it has not yet been tested on very many other architectures,
big-endian machines in particular.
LICENSE:
This implementation is released freely under an open-source BSD
license which appears at the top of each source code file.
WHAT IT IS:
The files sha2.h and sha2.c implement the SHA-256, SHA-384, and SHA-512
hash algorithms as described in the PDF document found at the following
web address:
http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
The interface is similar to the interface to SHA-1 found in the OpenSSL
library.
The file sha2prog.c is a simple program that accepts input from either
STDIN or reads one or more files specified on the command line, and then
generates the specified hash (either SHA-256, SHA-384, SHA-512, or any
combination thereof, including all three at once).
LIMITATIONS:
This implementation has several limitations:
* Input data is only accepted in octet-length increments. No sub-byte
data is handled. The NIST document describes how to handle sub-byte
input data, but for ease of implementation this version will only
accept message data in multiples of bytes.
* This implementation utilizes 64-bit integer data types. If your
system and compiler does not have a 64-bit integer data type, this
implementation will not work.
* Because of the use of 64-bit operations, many 32-bit architectures
that do have 64-bit data types but do operations most efficiently
on 32-bit words, this implementation may be slower than an
implementation designed to use only 32-bit words (emulating the
64-bit operations).
* On platforms with 128-bit integer data types, the SHA-384 and SHA-512
bit counters used by this implementation might be better off using
the 128-bit type instead of simulating it with two 64-bit integers.
* This implementation was written in C in hopes of portability and for
the fun of it during my spare time. It is probably not the most
efficient or fastest C implementation. I welcome suggestions,
however, that suggest ways to speed things up without breaking
portability. I also welcome suggestions to improve portability.
* As mentioned above, this code has NOT been thoroughly tested.
This is perhaps the most severe limitation.
BEFORE YOU COMPILE (OPTIONS):
Each of the options described below may either be defined in the sha2.h
header file (or in the sha2.c file in some cases), or on the command
line at compile time if your compiler supports such things. For
example:
#define SHA2_USE_INTTYPES_H
#define SHA2_UNROLL_TRANSFORM
Or:
cc -c -DSHA2_UNROLL_TRANSFORM sha2.c
cc -c -DBYTE_ORDER=4321 -DBIG_ENDIAN=4321 sha2.c
Here are the available options. Read on below for a description of
each one:
SHA2_USE_INTTYPES_H
SHA2_USE_MEMSET_MEMCPY/SHA2_USE_BZERO_BCOPY
SHA2_UNROLL_TRANSFORM
BYTE_ORDER (LITTLE_ENDIAN/BIG_ENDIAN)
* SHA2_USE_INTTYPES_H option:
By default, this code uses u_intXX_t data types for 8 bit, 32 bit, and
64 bit unsigned integer type definitions. Most BSD systems define these,
as does Linux. However, some (like Compaq's Tru64 Unix) may instead
use uintXX_t data types as defined by recent ANSI C standards and as
included in the inttypes.h header file. Those wanting to use inttypes.h
need to define this either in sha.h or at compile time.
On those systems where NEITHER definitions are available, you will need
to edit both sha2.h and sha2.c and define things by hand in the appropriate
sections.
* BYTE_ORDER definitions:
This code assumes that BYTE_ORDER will be defined by the system during
compile to either equal LITTLE_ENDIAN or BIG_ENDIAN. If your system
does not define these, you may need to define them by hand in the sha.c
file according to the byte ordering conventions of your system.
* SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY
The code in sha2.c can use either memset()/memcpy() for memory block
operations, or bzero()/mcopy(). If you define neither of these, the
code will default to memset()/memcpy(). You can define either at the
command line or in sha2.h or in sha2.c.
* SHA2_UNROLL_TRANSFORM
By defining this either on the command line or in sha2.h or sha2.c,
the code will use macros to partially "unroll" the SHA transform
function. This usually generates bigger executables. It CAN (but
not necessarily WILL) generate faster code when you tell your compiler
to optimize things. For example, on the FreeBSD and Linux x86 systems
I tested things on (using gcc), when I optimized with just -O2 and
unrolled the transform, the hash transform was faster by 15-30%. On
these same systems, if I did NO optimization, the unrolled transform
was SLOWER, much slower (I'm guessing because the code was breaking
the cache, but I'm not sure). Your mileage may vary.
PORTABILITY:
The code in sha2.c and sha2.h is intended to be portable. It may
require that you do a few #definitions in the .h file. I've successfully
compiled and tested the sha2.c and sha2.h code on Apple's OS X (on
a PPC), FreeBSD 4.1.1 on Intel, Linux on Intel, FreeBSD on the Alpha,
and even under Windows98SE using Metrowerks C. The utility/example
programs (sha2prog.c, sha2test.c, and sha2speed.c) will very likely
have more trouble in portability since they do I/O.
To get sha2.c/sha2.h working under Windows, I had to define
SHA2_USE_INTTYPES_H, BYTE_ORDER, LITTLE_ENDIAN, and had to comment
out the include of <sys/types.h> in sha2.h. With a bit more work
I got the test program to run and verified that all the test
cases passed.
SUGGESTIONS/BUG FIXES:
If you make changes to get it working on other architectures, if you fix
any bugs, or if you make changes that improve this implementation's
efficiency that would be relatively portable and you're willing to release
your changes under the same license, please send them to me for possible
inclusion in future versions.
If you know where I can find some additional test vectors, please let me
know.
CHANGE HISTORY:
0.8 to 0.9 - Fixed spelling errors, changed to u_intXX_t type usage,
removed names from prototypes, added prototypes to sha2.c,
and a few things I can't recall.
0.9 to 0.9.5 - Add a new define in sha2.c that permits one to compile
it to either use memcpy()/memset() or bcopy()/bzero()
for memory block copying and zeroing. Added support
for unrolled SHA-256/384/512 transform loops. Just
compile with SHA2_UNROLL_TRANSFORM to enable. It takes
longer to compile, but I hope it is a bit faster. I
need to do some test to see whether or not it is. Oh,
in sha2.c, you either need to define SHA2_USE_BZERO_BCOPY
or SHA2_USE_MEMSET_MEMCPY to choose which way you want
to compile. *Whew* It's amazing how quickly something
simple starts to grow more complex even in the span of
just a few hours. I didn't really intend to do this much.
0.9.5 to 0.9.6 - Added a test program (sha2test) which tests against several
known test vectors. WARNING: Some of the test output
hashes are NOT from NIST's documentation and are the
output of this implementation and so may be incorrect.
0.9.6 to 0.9.7 - Fixed a bug that could cause invalid output in certain
cases and added an assumed scenario where zero-length
data is hashed. Also changed the rotation macros to use
a temporary variable as this reduces the number of operations.
When data is fed in blocks of the right length, copying of
data is reduced in this version. Added SHAYXZ_Data()
functions for ease of hashing a set of data. Added another
file sha2speed.c for doing speed testing. Added another test
vector with a larger data size (16KB). Fixed u_intXX_t and
uintXX_t handling by adding a define for SHA2_USE_INTTYPES_H
as well as made a few other minor changes to get rid of
warnings when compiling on Compaq's Tru64 Unix.
0.9.7 to 0.9.8 - The bug fix in 0.9.7 was incomplete and in some cases made
things worse. I believe that 0.9.8 fixes the bug completely
so that output is correct. I cannot verify this, however,
because of the lack of test vectors against which to do such
verification. All versions correctly matched the very few
NIST-provided vectors, but unfortunately the bug only
appeared in longer message data sets.
0.9.8 to 0.9.9 - Fixed some really bad typos and mistakes on my part that
only affected big-endian systems. I didn't have direct
access for testing before this version. Thanks to
Lucas Marshall for giving me access to his OS X system.
0.9.9 to 1.0.0b1 Added a few more test samples and made a few changes to
make things easier compiling on several other platforms.
Also I experimented with alternate macro definitions
in the SHA2_UNROLL_TRANSFORM version (see sha2.slower.c)
and eliminated the T1 temporary variable (the compiler
would of course still use internal temporary storage
during expression evaluation, but I'd hoped the compiler
would be more efficient), but unfortunately under FreeBSD
4.1.1-STABLE on an x86 platform, the change slowed things
down.
1.0.0b1 to 1.0 RELEASE Fixed an off-by-one implementation bug that affected
SHA-256 when hashed data length L = 55 + 64 * X where X is
either zero or a positive integer, and another (basically
the same bug) bug in SHA-384 and SHA-512 that showed up when
hashed data lengths L = 111 + 128 * X. Thanks to Rogier
van de Pol for sending me test data that revealed the bug.
The fix was very simple (just two tiny changes). Also,
I finally put the files into RCS so future changes will be
easier to manage. The sha2prog.c file was rewritten to
be more useful to me, and I got rid of the old C testing
program and now use a perl script with a subdirectory full
of test data. It's a more flexible test system.
1.0 to 1.0.1 - Specified the specific *_CTX structure in the MEMSET_BZERO
macro doing clean-up after hashing. This should eliminate
some warnings using Clang in version 3.0 (trunk 135348).
Thanks, Stephane Leon for reporting this.
LATEST VERSION:
The latest version and documentation (if any ;) should always be available
on the web at:
http://www.aarongifford.com/computers/sha.html
CONTACT ME:
I can be reached via email at:
Aaron Gifford <m e @ a a r o n g i f f o r d . c o m>
Please don't send support questions. I don't have the time to answer and
they'll probably be ignored. Bug fixes, or patches that add something useful
will be gratefully accepted, however.
If you use this implementation, I would enjoy getting a brief email message
letting me know who you are and what use to which it is being put. There
is no requirement to do so. I just think it would be fun.
EXAMPLES:
Here's an example of compiling and using the sha2 program (in this example
I build it using the unrolled transform version with -O2 optimizations),
and then running the perl testing script:
cc -O2 -DSHA2_UNROLL_TRANSFORM -Wall -o sha2 sha2prog.c sha2.c
% ./sha2test.pl
[most of the perl script output deleted for brevity]
===== RESULTS (18 VECTOR DATA FILES HASHED) =====
HASH TYPE NO. OF TESTS PASSED FAILED
--------- ------------ ------ ------
SHA-256 18 18 0
SHA-384 18 18 0
SHA-512 18 18 0
----------------------------------------------
TOTAL: 54 54 0
NO ERRORS! ALL TESTS WERE SUCCESSFUL!
ALL TEST VECTORS PASSED!
That's all folks! Have fun!
Aaron out.

1064
src/lib_hash/sha2.c Normal file

File diff suppressed because it is too large Load Diff

193
src/lib_hash/sha2.h Normal file
View File

@@ -0,0 +1,193 @@
/*
* FILE: sha2.h
* AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
*
* Copyright (c) 2000-2001, Aaron D. Gifford
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``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 AUTHOR OR CONTRIBUTOR(S) 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.
*
* $Id: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $
*/
#ifndef __SHA2_H__
#define __SHA2_H__
/*
* Import u_intXX_t size_t type definitions from system headers. You
* may need to change this, or define these things yourself in this
* file.
*/
#include <sys/types.h>
#ifdef _WIN32
#include <inttypes.h>
#define u_int8_t uint8_t
#define u_int32_t uint32_t
#define u_int64_t uint64_t
#define BYTE_ORDER LITTLE_ENDIAN
#endif
/*** SHA-256/384/512 Various Length Definitions ***********************/
#define SHA256_BLOCK_LENGTH 64
#define SHA256_DIGEST_LENGTH 32
#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
#define SHA384_BLOCK_LENGTH 128
#define SHA384_DIGEST_LENGTH 48
#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
#define SHA512_BLOCK_LENGTH 128
#define SHA512_DIGEST_LENGTH 64
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
/*** SHA-256/384/512 Context Structures *******************************/
/* NOTE: If your architecture does not define either u_intXX_t types or
* uintXX_t (from inttypes.h), you may need to define things by hand
* for your system:
*/
#if 0
typedef unsigned char u_int8_t; /* 1-byte (8-bits) */
typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */
typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */
#endif
/*
* Most BSD systems already define u_intXX_t types, as does Linux.
* Some systems, however, like Compaq's Tru64 Unix instead can use
* uintXX_t types defined by very recent ANSI C standards and included
* in the file:
*
* #include <inttypes.h>
*
* If you choose to use <inttypes.h> then please define:
*
* #define SHA2_USE_INTTYPES_H
*
* Or on the command line during compile:
*
* cc -DSHA2_USE_INTTYPES_H ...
*/
#ifdef SHA2_USE_INTTYPES_H
typedef struct _SHA256_CTX {
uint32_t state[8];
uint64_t bitcount;
uint8_t buffer[SHA256_BLOCK_LENGTH];
} SHA256_CTX;
typedef struct _SHA512_CTX {
uint64_t state[8];
uint64_t bitcount[2];
uint8_t buffer[SHA512_BLOCK_LENGTH];
} SHA512_CTX;
#else /* SHA2_USE_INTTYPES_H */
typedef struct _SHA256_CTX {
u_int32_t state[8];
u_int64_t bitcount;
u_int8_t buffer[SHA256_BLOCK_LENGTH];
} SHA256_CTX;
typedef struct _SHA512_CTX {
u_int64_t state[8];
u_int64_t bitcount[2];
u_int8_t buffer[SHA512_BLOCK_LENGTH];
} SHA512_CTX;
#endif /* SHA2_USE_INTTYPES_H */
typedef SHA512_CTX SHA384_CTX;
/*** SHA-256/384/512 Function Prototypes ******************************/
#ifndef NOPROTO
#ifdef SHA2_USE_INTTYPES_H
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX*, const uint8_t*, size_t);
void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
void SHA384_Init(SHA384_CTX*);
void SHA384_Update(SHA384_CTX*, const uint8_t*, size_t);
void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
void SHA512_Init(SHA512_CTX*);
void SHA512_Update(SHA512_CTX*, const uint8_t*, size_t);
void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
#else /* SHA2_USE_INTTYPES_H */
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX*, const u_int8_t*, size_t);
void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
char* SHA256_Data(const u_int8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
void SHA384_Init(SHA384_CTX*);
void SHA384_Update(SHA384_CTX*, const u_int8_t*, size_t);
void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
void SHA512_Init(SHA512_CTX*);
void SHA512_Update(SHA512_CTX*, const u_int8_t*, size_t);
void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
#endif /* SHA2_USE_INTTYPES_H */
#else /* NOPROTO */
void SHA256_Init();
void SHA256_Update();
void SHA256_Final();
char* SHA256_End();
char* SHA256_Data();
void SHA384_Init();
void SHA384_Update();
void SHA384_Final();
char* SHA384_End();
char* SHA384_Data();
void SHA512_Init();
void SHA512_Update();
void SHA512_Final();
char* SHA512_End();
char* SHA512_Data();
#endif /* NOPROTO */
#endif /* __SHA2_H__ */

View File

@@ -1211,8 +1211,6 @@ vbi3_raw_decoder_set_log_fn (vbi3_raw_decoder * rd,
void * user_data,
vbi_log_mask mask)
{
unsigned int i;
assert (NULL != rd);
if (NULL == log_fn)

View File

@@ -8,13 +8,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug-OCR|Win32 = Debug-OCR|Win32
Release|Win32 = Release|Win32
Release-OCR|Win32 = Release-OCR|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Debug|Win32.ActiveCfg = Debug|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Debug|Win32.Build.0 = Debug|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Debug-OCR|Win32.ActiveCfg = Debug-OCR|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Debug-OCR|Win32.Build.0 = Debug-OCR|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Release|Win32.ActiveCfg = Release|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Release|Win32.Build.0 = Release|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Release-OCR|Win32.ActiveCfg = Release-OCR|Win32
{0F0063C4-BCBC-4379-A6D5-84A5669C940A}.Release-OCR|Win32.Build.0 = Release-OCR|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -1,744 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ccextractor"
ProjectGUID="{0F0063C4-BCBC-4379-A6D5-84A5669C940A}"
RootNamespace="ccextractor"
Keyword="Win32Proj"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../src/gpacmp4;../src/libpng;../src/zlib"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_FILE_OFFSET_BITS=64"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="WS2_32.Lib"
ShowProgress="0"
LinkIncremental="2"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../src/gpacmp4;../src/libpng;../src/zlib"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_FILE_OFFSET_BITS=64"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="WS2_32.Lib"
LinkIncremental="1"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\src\608.h"
>
</File>
<File
RelativePath="..\src\608_spupng.h"
>
</File>
<File
RelativePath="..\src\708.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\internal\avilib.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\avparse.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\base_coding.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\bitstream.h"
>
</File>
<File
RelativePath="..\src\bitstream.h"
>
</File>
<File
RelativePath="..\src\ccextractor.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\configuration.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\constants.h"
>
</File>
<File
RelativePath="..\src\zlib\crc32.h"
>
</File>
<File
RelativePath="..\src\zlib\deflate.h"
>
</File>
<File
RelativePath="..\src\disable_warnings.h"
>
</File>
<File
RelativePath="..\src\zlib\gzguts.h"
>
</File>
<File
RelativePath="..\src\hamming.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\ietf.h"
>
</File>
<File
RelativePath="..\src\zlib\inffast.h"
>
</File>
<File
RelativePath="..\src\zlib\inffixed.h"
>
</File>
<File
RelativePath="..\src\zlib\inflate.h"
>
</File>
<File
RelativePath="..\src\zlib\inftrees.h"
>
</File>
<File
RelativePath="..\src\inttypes.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\isomedia.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\internal\isomedia_dev.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\list.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\math.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\internal\media_dev.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\media_tools.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\mpeg4_odf.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\network.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\internal\odf_dev.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\internal\odf_parse_common.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\internal\ogg.h"
>
</File>
<File
RelativePath="..\src\libpng\png.h"
>
</File>
<File
RelativePath="..\src\libpng\pngconf.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\setup.h"
>
</File>
<File
RelativePath="..\src\stdint.h"
>
</File>
<File
RelativePath="..\src\stdintmsc.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\sync_layer.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\targetver.h"
>
</File>
<File
RelativePath="..\src\teletext.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\tools.h"
>
</File>
<File
RelativePath="..\src\zlib\trees.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\utf.h"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac\version.h"
>
</File>
<File
RelativePath="..\src\zlib\zconf.h"
>
</File>
<File
RelativePath="..\src\zlib\zlib.h"
>
</File>
<File
RelativePath="..\src\zlib\zutil.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\src\608.cpp"
>
</File>
<File
RelativePath="..\src\608_helpers.cpp"
>
</File>
<File
RelativePath="..\src\608_sami.cpp"
>
</File>
<File
RelativePath="..\src\608_smptett.cpp"
>
</File>
<File
RelativePath="..\src\608_spupng.cpp"
>
</File>
<File
RelativePath="..\src\608_srt.cpp"
>
</File>
<File
RelativePath="..\src\708.cpp"
>
</File>
<File
RelativePath="..\src\708_encoding.cpp"
>
</File>
<File
RelativePath="..\src\activity.cpp"
>
</File>
<File
RelativePath="..\src\zlib\adler32.c"
>
</File>
<File
RelativePath="..\src\asf_functions.cpp"
>
</File>
<File
RelativePath="..\src\gpacmp4\av_parsers.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\avc_ext.c"
>
</File>
<File
RelativePath="..\src\avc_functions.cpp"
>
</File>
<File
RelativePath="..\src\gpacmp4\avilib.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\base_encoding.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\bitstream.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\box_code_3gpp.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\box_code_apple.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\box_code_base.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\box_code_isma.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\box_code_meta.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\box_funcs.c"
>
</File>
<File
RelativePath="..\src\cc_bitstream.cpp"
>
</File>
<File
RelativePath="..\src\cc_decoders_common.cpp"
>
</File>
<File
RelativePath="..\src\ccextractor.cpp"
>
</File>
<File
RelativePath="..\src\constants.cpp"
>
</File>
<File
RelativePath="..\src\zlib\crc32.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\data_map.c"
>
</File>
<File
RelativePath="..\src\zlib\deflate.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\desc_private.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\descriptors.c"
>
</File>
<File
RelativePath="..\src\encoding.cpp"
>
</File>
<File
RelativePath="..\src\gpacmp4\error.c"
>
</File>
<File
RelativePath="..\src\es_functions.cpp"
>
</File>
<File
RelativePath="..\src\es_userdata.cpp"
>
</File>
<File
RelativePath="..\src\file_functions.cpp"
>
</File>
<File
RelativePath="..\src\general_loop.cpp"
>
</File>
<File
RelativePath="..\src\gpacmp4\gpac_ogg.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\hinting.c"
>
</File>
<File
RelativePath="..\src\zlib\inffast.c"
>
</File>
<File
RelativePath="..\src\zlib\inflate.c"
>
</File>
<File
RelativePath="..\src\zlib\inftrees.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\ipmpx_code.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\ipmpx_parse.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\isom_intern.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\isom_read.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\isom_store.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\isom_write.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\list.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\media.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\media_odf.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\meta.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\movie_fragments.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\mp4.cpp"
>
</File>
<File
RelativePath="..\src\myth.cpp"
>
</File>
<File
RelativePath="..\src\gpacmp4\odf_code.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\odf_codec.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\odf_command.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\os_divers.c"
>
</File>
<File
RelativePath="..\src\output.cpp"
>
</File>
<File
RelativePath="..\src\params.cpp"
>
</File>
<File
RelativePath="..\src\params_dump.cpp"
>
</File>
<File
RelativePath="..\src\libpng\png.c"
>
</File>
<File
RelativePath="..\src\libpng\pngerror.c"
>
</File>
<File
RelativePath="..\src\libpng\pngmem.c"
>
</File>
<File
RelativePath="..\src\libpng\pngset.c"
>
</File>
<File
RelativePath="..\src\libpng\pngtrans.c"
>
</File>
<File
RelativePath="..\src\libpng\pngwio.c"
>
</File>
<File
RelativePath="..\src\libpng\pngwrite.c"
>
</File>
<File
RelativePath="..\src\libpng\pngwtran.c"
>
</File>
<File
RelativePath="..\src\libpng\pngwutil.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\qos.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\sample_descs.c"
>
</File>
<File
RelativePath="..\src\sequencing.cpp"
>
</File>
<File
RelativePath="..\src\gpacmp4\slc.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\stbl_read.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\stbl_write.c"
>
</File>
<File
RelativePath="..\src\stream_functions.cpp"
>
</File>
<File
RelativePath="..\src\telxcc.cpp"
>
</File>
<File
RelativePath="..\src\timing.cpp"
>
</File>
<File
RelativePath="..\src\gpacmp4\track.c"
>
</File>
<File
RelativePath="..\src\zlib\trees.c"
>
</File>
<File
RelativePath="..\src\ts_functions.cpp"
>
</File>
<File
RelativePath="..\src\gpacmp4\tx3g.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\url.c"
>
</File>
<File
RelativePath="..\src\gpacmp4\utf.c"
>
</File>
<File
RelativePath="..\src\utility.cpp"
>
</File>
<File
RelativePath="..\src\xds.cpp"
>
</File>
<File
RelativePath="..\src\zlib\zutil.c"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -1,16 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug-OCR|Win32">
<Configuration>Debug-OCR</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release-OCR|Win32">
<Configuration>Release-OCR</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\lib_ccx\compile_info.h" />
<ClInclude Include="..\src\gpacmp4\gpac\avparse.h" />
<ClInclude Include="..\src\gpacmp4\gpac\base_coding.h" />
<ClInclude Include="..\src\gpacmp4\gpac\bitstream.h" />
@@ -66,6 +75,9 @@
<ClInclude Include="..\src\lib_ccx\spupng_encoder.h" />
<ClInclude Include="..\src\lib_ccx\teletext.h" />
<ClInclude Include="..\src\lib_ccx\utility.h" />
<ClInclude Include="..\src\lib_hash\sha2.h" />
<ClInclude Include="..\src\win_iconv\iconv.h" />
<ClInclude Include="..\src\win_spec_incld\dirent.h" />
<ClInclude Include="..\src\zlib\crc32.h" />
<ClInclude Include="..\src\zlib\deflate.h" />
<ClInclude Include="..\src\zlib\gzguts.h" />
@@ -85,8 +97,8 @@
<ClInclude Include="..\src\zvbi\sampling_par.h" />
<ClInclude Include="..\src\zvbi\sliced.h" />
<ClInclude Include="..\src\zvbi\zvbi_decoder.h" />
<ClInclude Include="include\inttypes.h" />
<ClInclude Include="include\stdint.h" />
<ClInclude Include="..\src\win_spec_incld\inttypes.h" />
<ClInclude Include="..\src\win_spec_incld\stdint.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\ccextractor.c" />
@@ -199,6 +211,7 @@
<ClCompile Include="..\src\lib_ccx\ts_tables_epg.c" />
<ClCompile Include="..\src\lib_ccx\utility.c" />
<ClCompile Include="..\src\lib_ccx\wtv_functions.c" />
<ClCompile Include="..\src\lib_hash\sha2.c" />
<ClCompile Include="..\src\win_iconv\win_iconv.c" />
<ClCompile Include="..\src\zlib\adler32.c" />
<ClCompile Include="..\src\zlib\crc32.c" />
@@ -221,11 +234,19 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-OCR|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-OCR|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -236,6 +257,12 @@
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug-OCR|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release-OCR|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.21005.1</_ProjectFileVersion>
@@ -244,11 +271,29 @@
<OutDir>Debug\</OutDir>
<IntDir>Debug\</IntDir>
<LinkIncremental>true</LinkIncremental>
<TargetName>ccextractorwin</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-OCR|Win32'">
<OutDir>Debug-OCR\</OutDir>
<IntDir>Debug-OCR\</IntDir>
<LinkIncremental>true</LinkIncremental>
<TargetName>ccextractorwin</TargetName>
<IncludePath>$(ProjectDir)\libs\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-OCR|Win32'">
<OutDir>Release-OCR\</OutDir>
<IntDir>Release-OCR\</IntDir>
<LinkIncremental>false</LinkIncremental>
<TargetName>ccextractorwin</TargetName>
<IncludePath>$(ProjectDir)\libs\include;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)\libs\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>Release\</OutDir>
<IntDir>Release\</IntDir>
<LinkIncremental>false</LinkIncremental>
<TargetName>ccextractorwin</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -270,10 +315,58 @@
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-OCR|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../src/win_spec_incld;../src/gpacmp4;../src/libpng;../src/zlib;../src;../src/lib_ccx;../src/zvbi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ENABLE_OCR;WIN32;_DEBUG;_CONSOLE;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>WS2_32.Lib;liblept172.lib;libtesseract304d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ShowProgress>NotSet</ShowProgress>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>xcopy /y $(ProjectDir)libs\lib\liblept172.dll $(ProjectDir)$(OutDir)
xcopy /y $(ProjectDir)libs\lib\libtesseract304d.dll $(ProjectDir)$(OutDir)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-OCR|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../src/win_spec_incld;../src/gpacmp4;../src/libpng;../src/zlib;../src;../src/lib_ccx;../src/zvbi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>VERSION_FILE_PRESENT;ENABLE_OCR;WIN32;NDEBUG;_CONSOLE;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>WS2_32.Lib;libtesseract302.lib;liblept168.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>xcopy /y $(ProjectDir)libs\leptonica\lib\liblept168.dll $(ProjectDir)$(OutDir)
xcopy /y $(ProjectDir)libs\tesseract\lib\libtesseract302.dll $(ProjectDir)$(OutDir)</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>../src/win_spec_incld;../src/lib_ccx;../src/gpacmp4;../src/libpng;../src/zlib;../src/zvbi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../src/win_spec_incld;../src/lib_ccx;../src/lib_hash;../src/gpacmp4;../src/libpng;../src/zlib;../src/zvbi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>VERSION_FILE_PRESENT;WIN32;NDEBUG;_CONSOLE;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
@@ -287,6 +380,9 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PreBuildEvent>
<Command>pre-build.bat</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@@ -55,6 +55,21 @@
<Filter Include="Header Files\zvbi">
<UniqueIdentifier>{288f48c3-470a-45ad-a70a-8f062c51aeb1}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\lib_hash">
<UniqueIdentifier>{140e6ccb-2042-4ecc-9cba-42a04a5b0803}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\lib_hash">
<UniqueIdentifier>{dcb7e1ec-51eb-4f69-93db-b10133e98402}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\win_spec_incld">
<UniqueIdentifier>{de4fb954-0fd9-407a-8803-4dec4640296b}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\win_iconv">
<UniqueIdentifier>{1870287a-d318-4ef0-9bd1-11c965a1474c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\win_iconv">
<UniqueIdentifier>{964b0a18-918d-4b08-ba92-5a84e3c48b43}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\gpacmp4\gpac\avparse.h">
@@ -183,12 +198,6 @@
<ClInclude Include="..\src\lib_ccx\disable_warnings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\inttypes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\stdint.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\lib_ccx\ccx_common_char_encoding.h">
<Filter>Header Files\ccx_common</Filter>
</ClInclude>
@@ -285,6 +294,24 @@
<ClInclude Include="..\src\zvbi\zvbi_decoder.h">
<Filter>Header Files\zvbi</Filter>
</ClInclude>
<ClInclude Include="..\src\lib_ccx\compile_info.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\lib_hash\sha2.h">
<Filter>Header Files\lib_hash</Filter>
</ClInclude>
<ClInclude Include="..\src\win_spec_incld\stdint.h">
<Filter>Header Files\win_spec_incld</Filter>
</ClInclude>
<ClInclude Include="..\src\win_spec_incld\inttypes.h">
<Filter>Header Files\win_spec_incld</Filter>
</ClInclude>
<ClInclude Include="..\src\win_spec_incld\dirent.h">
<Filter>Header Files\win_spec_incld</Filter>
</ClInclude>
<ClInclude Include="..\src\win_iconv\iconv.h">
<Filter>Header Files\win_iconv</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\ccextractor.c">
@@ -611,9 +638,6 @@
<ClCompile Include="..\src\lib_ccx\ccx_decoders_708_output.c">
<Filter>Source Files\ccx_decoders</Filter>
</ClCompile>
<ClCompile Include="..\src\win_iconv\win_iconv.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\lib_ccx\ccx_decoders_708_encoding.c">
<Filter>Source Files</Filter>
</ClCompile>
@@ -668,5 +692,11 @@
<ClCompile Include="..\src\lib_ccx\ccx_encoders_g608.c">
<Filter>Source Files\ccx_decoders</Filter>
</ClCompile>
<ClCompile Include="..\src\lib_hash\sha2.c">
<Filter>Source Files\lib_hash</Filter>
</ClCompile>
<ClCompile Include="..\src\win_iconv\win_iconv.c">
<Filter>Source Files\win_iconv</Filter>
</ClCompile>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_ALLTYPES_H
#define LEPTONICA_ALLTYPES_H
/* Standard */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
/* General and configuration defs */
#include "environ.h"
/* Generic and non-image-specific containers */
#include "array.h"
#include "bbuffer.h"
#include "heap.h"
#include "list.h"
#include "ptra.h"
#include "queue.h"
#include "stack.h"
/* Imaging */
#include "arrayaccess.h"
#include "bmf.h"
#include "ccbord.h"
#include "dewarp.h"
#include "gplot.h"
#include "imageio.h"
#include "jbclass.h"
#include "morph.h"
#include "pix.h"
#include "recog.h"
#include "regutils.h"
#include "stringcode.h"
#include "sudoku.h"
#include "watershed.h"
#endif /* LEPTONICA_ALLTYPES_H */

View File

@@ -0,0 +1,170 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_ARRAY_H
#define LEPTONICA_ARRAY_H
/*
* Contains the following structs:
* struct Numa
* struct Numaa
* struct Numa2d
* struct NumaHash
* struct L_Dna
* struct L_Dnaa
* struct Sarray
* struct L_Bytea
*
* Contains definitions for:
* Numa interpolation flags
* Numa and FPix border flags
* Numa data type conversion to string
*/
/*------------------------------------------------------------------------*
* Array Structs *
*------------------------------------------------------------------------*/
#define NUMA_VERSION_NUMBER 1
/* Number array: an array of floats */
struct Numa
{
l_int32 nalloc; /* size of allocated number array */
l_int32 n; /* number of numbers saved */
l_int32 refcount; /* reference count (1 if no clones) */
l_float32 startx; /* x value assigned to array[0] */
l_float32 delx; /* change in x value as i --> i + 1 */
l_float32 *array; /* number array */
};
typedef struct Numa NUMA;
/* Array of number arrays */
struct Numaa
{
l_int32 nalloc; /* size of allocated ptr array */
l_int32 n; /* number of Numa saved */
struct Numa **numa; /* array of Numa */
};
typedef struct Numaa NUMAA;
/* Sparse 2-dimensional array of number arrays */
struct Numa2d
{
l_int32 nrows; /* number of rows allocated for ptr array */
l_int32 ncols; /* number of cols allocated for ptr array */
l_int32 initsize; /* initial size of each numa that is made */
struct Numa ***numa; /* 2D array of Numa */
};
typedef struct Numa2d NUMA2D;
/* A hash table of Numas */
struct NumaHash
{
l_int32 nbuckets;
l_int32 initsize; /* initial size of each numa that is made */
struct Numa **numa;
};
typedef struct NumaHash NUMAHASH;
#define DNA_VERSION_NUMBER 1
/* Double number array: an array of doubles */
struct L_Dna
{
l_int32 nalloc; /* size of allocated number array */
l_int32 n; /* number of numbers saved */
l_int32 refcount; /* reference count (1 if no clones) */
l_float64 startx; /* x value assigned to array[0] */
l_float64 delx; /* change in x value as i --> i + 1 */
l_float64 *array; /* number array */
};
typedef struct L_Dna L_DNA;
/* Array of double number arrays */
struct L_Dnaa
{
l_int32 nalloc; /* size of allocated ptr array */
l_int32 n; /* number of L_Dna saved */
struct L_Dna **dna; /* array of L_Dna */
};
typedef struct L_Dnaa L_DNAA;
#define SARRAY_VERSION_NUMBER 1
/* String array: an array of C strings */
struct Sarray
{
l_int32 nalloc; /* size of allocated ptr array */
l_int32 n; /* number of strings allocated */
l_int32 refcount; /* reference count (1 if no clones) */
char **array; /* string array */
};
typedef struct Sarray SARRAY;
/* Byte array (analogous to C++ "string") */
struct L_Bytea
{
size_t nalloc; /* number of bytes allocated in data array */
size_t size; /* number of bytes presently used */
l_int32 refcount; /* reference count (1 if no clones) */
l_uint8 *data; /* data array */
};
typedef struct L_Bytea L_BYTEA;
/*------------------------------------------------------------------------*
* Array flags *
*------------------------------------------------------------------------*/
/* Flags for interpolation in Numa */
enum {
L_LINEAR_INTERP = 1, /* linear */
L_QUADRATIC_INTERP = 2 /* quadratic */
};
/* Flags for added borders in Numa and Fpix */
enum {
L_CONTINUED_BORDER = 1, /* extended with same value */
L_SLOPE_BORDER = 2, /* extended with constant normal derivative */
L_MIRRORED_BORDER = 3 /* mirrored */
};
/* Flags for data type converted from Numa */
enum {
L_INTEGER_VALUE = 1, /* convert to integer */
L_FLOAT_VALUE = 2 /* convert to float */
};
#endif /* LEPTONICA_ARRAY_H */

View File

@@ -0,0 +1,205 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_ARRAY_ACCESS_H
#define LEPTONICA_ARRAY_ACCESS_H
/*
* arrayaccess.h
*
* 1, 2, 4, 8, 16 and 32 bit data access within an array of 32-bit words
*
* This is used primarily to access 1, 2, 4, 8, 16 and 32 bit pixels
* in a line of image data, represented as an array of 32-bit words.
*
* pdata: pointer to first 32-bit word in the array
* n: index of the pixel in the array
*
* Function calls for these accessors are defined in arrayaccess.c.
*
* However, for efficiency we use the inline macros for all accesses.
* Even though the 2 and 4 bit set* accessors are more complicated,
* they are about 10% faster than the function calls.
*
* The 32 bit access is just a cast and ptr arithmetic. We include
* it so that the input ptr can be void*.
*
* At the end of this file is code for invoking the function calls
* instead of inlining.
*
* The macro SET_DATA_BIT_VAL(pdata, n, val) is a bit slower than
* if (val == 0)
* CLEAR_DATA_BIT(pdata, n);
* else
* SET_DATA_BIT(pdata, n);
*/
/* Use the inline accessors (except with _MSC_VER), because they
* are faster. */
#define USE_INLINE_ACCESSORS 1
#if USE_INLINE_ACCESSORS
#ifndef _MSC_VER
/*--------------------------------------------------*
* 1 bit access *
*--------------------------------------------------*/
#define GET_DATA_BIT(pdata, n) \
((*((l_uint32 *)(pdata) + ((n) >> 5)) >> (31 - ((n) & 31))) & 1)
#define SET_DATA_BIT(pdata, n) \
(*((l_uint32 *)(pdata) + ((n) >> 5)) |= (0x80000000 >> ((n) & 31)))
#define CLEAR_DATA_BIT(pdata, n) \
(*((l_uint32 *)(pdata) + ((n) >> 5)) &= ~(0x80000000 >> ((n) & 31)))
#define SET_DATA_BIT_VAL(pdata, n, val) \
({l_uint32 *_TEMP_WORD_PTR_; \
_TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 5); \
*_TEMP_WORD_PTR_ &= ~(0x80000000 >> ((n) & 31)); \
*_TEMP_WORD_PTR_ |= ((val) << (31 - ((n) & 31))); \
})
/*--------------------------------------------------*
* 2 bit access *
*--------------------------------------------------*/
#define GET_DATA_DIBIT(pdata, n) \
((*((l_uint32 *)(pdata) + ((n) >> 4)) >> (2 * (15 - ((n) & 15)))) & 3)
#define SET_DATA_DIBIT(pdata, n, val) \
({l_uint32 *_TEMP_WORD_PTR_; \
_TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 4); \
*_TEMP_WORD_PTR_ &= ~(0xc0000000 >> (2 * ((n) & 15))); \
*_TEMP_WORD_PTR_ |= (((val) & 3) << (30 - 2 * ((n) & 15))); \
})
#define CLEAR_DATA_DIBIT(pdata, n) \
(*((l_uint32 *)(pdata) + ((n) >> 4)) &= ~(0xc0000000 >> (2 * ((n) & 15))))
/*--------------------------------------------------*
* 4 bit access *
*--------------------------------------------------*/
#define GET_DATA_QBIT(pdata, n) \
((*((l_uint32 *)(pdata) + ((n) >> 3)) >> (4 * (7 - ((n) & 7)))) & 0xf)
#define SET_DATA_QBIT(pdata, n, val) \
({l_uint32 *_TEMP_WORD_PTR_; \
_TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 3); \
*_TEMP_WORD_PTR_ &= ~(0xf0000000 >> (4 * ((n) & 7))); \
*_TEMP_WORD_PTR_ |= (((val) & 15) << (28 - 4 * ((n) & 7))); \
})
#define CLEAR_DATA_QBIT(pdata, n) \
(*((l_uint32 *)(pdata) + ((n) >> 3)) &= ~(0xf0000000 >> (4 * ((n) & 7))))
/*--------------------------------------------------*
* 8 bit access *
*--------------------------------------------------*/
#ifdef L_BIG_ENDIAN
#define GET_DATA_BYTE(pdata, n) \
(*((l_uint8 *)(pdata) + (n)))
#else /* L_LITTLE_ENDIAN */
#define GET_DATA_BYTE(pdata, n) \
(*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3))
#endif /* L_BIG_ENDIAN */
#ifdef L_BIG_ENDIAN
#define SET_DATA_BYTE(pdata, n, val) \
(*((l_uint8 *)(pdata) + (n)) = (val))
#else /* L_LITTLE_ENDIAN */
#define SET_DATA_BYTE(pdata, n, val) \
(*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3) = (val))
#endif /* L_BIG_ENDIAN */
/*--------------------------------------------------*
* 16 bit access *
*--------------------------------------------------*/
#ifdef L_BIG_ENDIAN
#define GET_DATA_TWO_BYTES(pdata, n) \
(*((l_uint16 *)(pdata) + (n)))
#else /* L_LITTLE_ENDIAN */
#define GET_DATA_TWO_BYTES(pdata, n) \
(*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2))
#endif /* L_BIG_ENDIAN */
#ifdef L_BIG_ENDIAN
#define SET_DATA_TWO_BYTES(pdata, n, val) \
(*((l_uint16 *)(pdata) + (n)) = (val))
#else /* L_LITTLE_ENDIAN */
#define SET_DATA_TWO_BYTES(pdata, n, val) \
(*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2) = (val))
#endif /* L_BIG_ENDIAN */
/*--------------------------------------------------*
* 32 bit access *
*--------------------------------------------------*/
#define GET_DATA_FOUR_BYTES(pdata, n) \
(*((l_uint32 *)(pdata) + (n)))
#define SET_DATA_FOUR_BYTES(pdata, n, val) \
(*((l_uint32 *)(pdata) + (n)) = (val))
#endif /* ! _MSC_VER */
#endif /* USE_INLINE_ACCESSORS */
/*--------------------------------------------------*
* Slower, using function calls for all accessors *
*--------------------------------------------------*/
#if !USE_INLINE_ACCESSORS || defined(_MSC_VER)
#define GET_DATA_BIT(pdata, n) l_getDataBit(pdata, n)
#define SET_DATA_BIT(pdata, n) l_setDataBit(pdata, n)
#define CLEAR_DATA_BIT(pdata, n) l_clearDataBit(pdata, n)
#define SET_DATA_BIT_VAL(pdata, n, val) l_setDataBitVal(pdata, n, val)
#define GET_DATA_DIBIT(pdata, n) l_getDataDibit(pdata, n)
#define SET_DATA_DIBIT(pdata, n, val) l_setDataDibit(pdata, n, val)
#define CLEAR_DATA_DIBIT(pdata, n) l_clearDataDibit(pdata, n)
#define GET_DATA_QBIT(pdata, n) l_getDataQbit(pdata, n)
#define SET_DATA_QBIT(pdata, n, val) l_setDataQbit(pdata, n, val)
#define CLEAR_DATA_QBIT(pdata, n) l_clearDataQbit(pdata, n)
#define GET_DATA_BYTE(pdata, n) l_getDataByte(pdata, n)
#define SET_DATA_BYTE(pdata, n, val) l_setDataByte(pdata, n, val)
#define GET_DATA_TWO_BYTES(pdata, n) l_getDataTwoBytes(pdata, n)
#define SET_DATA_TWO_BYTES(pdata, n, val) l_setDataTwoBytes(pdata, n, val)
#define GET_DATA_FOUR_BYTES(pdata, n) l_getDataFourBytes(pdata, n)
#define SET_DATA_FOUR_BYTES(pdata, n, val) l_setDataFourBytes(pdata, n, val)
#endif /* !USE_INLINE_ACCESSORS || _MSC_VER */
#endif /* LEPTONICA_ARRAY_ACCESS_H */

View File

@@ -0,0 +1,57 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_BBUFFER_H
#define LEPTONICA_BBUFFER_H
/*
* bbuffer.h
*
* Expandable byte buffer for reading data in from memory and
* writing data out to other memory.
*
* This implements a queue of bytes, so data read in is put
* on the "back" of the queue (i.e., the end of the byte array)
* and data written out is taken from the "front" of the queue
* (i.e., from an index marker "nwritten" that is initially set at
* the beginning of the array.) As usual with expandable
* arrays, we keep the size of the allocated array and the
* number of bytes that have been read into the array.
*
* For implementation details, see bbuffer.c.
*/
struct ByteBuffer
{
l_int32 nalloc; /* size of allocated byte array */
l_int32 n; /* number of bytes read into to the array */
l_int32 nwritten; /* number of bytes written from the array */
l_uint8 *array; /* byte array */
};
typedef struct ByteBuffer BBUFFER;
#endif /* LEPTONICA_BBUFFER_H */

View File

@@ -0,0 +1,130 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_BILATERAL_H
#define LEPTONICA_BILATERAL_H
/*
* Contains the following struct
* struct L_Bilateral
*
*
* For a tutorial introduction to bilateral filters, which apply a
* gaussian blur to smooth parts of the image while preserving edges, see
* http://people.csail.mit.edu/sparis/bf_course/slides/03_definition_bf.pdf
*
* We give an implementation of a bilateral filtering algorithm given in:
* "Real-Time O(1) Bilateral Filtering," by Yang, Tan and Ahuja, CVPR 2009
* which is at:
* http://vision.ai.uiuc.edu/~qyang6/publications/cvpr-09-qingxiong-yang.pdf
* This is based on an earlier algorithm by Sylvain Paris and Frédo Durand:
* http://people.csail.mit.edu/sparis/publi/2006/eccv/
* Paris_06_Fast_Approximation.pdf
*
* The kernel of the filter is a product of a spatial gaussian and a
* monotonically decreasing function of the difference in intensity
* between the source pixel and the neighboring pixel. The intensity
* part of the filter gives higher influence for pixels with intensities
* that are near to the source pixel, and the spatial part of the
* filter gives higher weight to pixels that are near the source pixel.
* This combination smooths in relatively uniform regions, while
* maintaining edges.
*
* The advantage of the appoach of Yang et al is that it is separable,
* so the computation time is linear in the gaussian filter size.
* Furthermore, it is possible to do much of the computation as a reduced
* scale, which gives a good approximation to the full resolution version
* but greatly speeds it up.
*
* The bilateral filtered value at x is:
*
* sum[y in N(x)]: spatial(|y - x|) * range(|I(x) - I(y)|) * I(y)
* I'(x) = --------------------------------------------------------------
* sum[y in N(x)]: spatial(|y - x|) * range(|I(x) - I(y)|)
*
* where I() is the input image, I'() is the filtered image, N(x) is the
* set of pixels around x in the filter support, and spatial() and range()
* are gaussian functions:
* spatial(x) = exp(-x^2 / (2 * s_s^2))
* range(x) = exp(-x^2 / (2 * s_r^2))
* and s_s and s_r and the standard deviations of the two gaussians.
*
* Yang et al use a separable approximation to this, by defining a set
* of related but separable functions J(k,x), that we call Principal
* Bilateral Components (PBC):
*
* sum[y in N(x)]: spatial(|y - x|) * range(|k - I(y)|) * I(y)
* J(k,x) = -----------------------------------------------------------
* sum[y in N(x)]: spatial(|y - x|) * range(|k - I(y)|)
*
* which are computed quickly for a set of n values k[p], p = 0 ... n-1.
* Then each output pixel is found using a linear interpolation:
*
* I'(x) = (1 - q) * J(k[p],x) + q * J(k[p+1],x)
*
* where J(k[p],x) and J(k[p+1],x) are PBC for which
* k[p] <= I(x) and k[p+1] >= I(x), and
* q = (I(x) - k[p]) / (k[p+1] - k[p]).
*
* We can also subsample I(x), create subsampled versions of J(k,x),
* which are then interpolated between for I'(x).
*
* We generate 'pixsc', by optionally downscaling the input image
* (using area mapping by the factor 'reduction'), and then adding
* a mirrored border to avoid boundary cases. This is then used
* to compute 'ncomps' PBCs.
*
* The 'spatial_stdev' is also downscaled by 'reduction'. The size
* of the 'spatial' array is 4 * (reduced 'spatial_stdev') + 1.
* The size of the 'range' array is 256.
*/
/*------------------------------------------------------------------------*
* Bilateral filter *
*------------------------------------------------------------------------*/
struct L_Bilateral
{
struct Pix *pixs; /* clone of source pix */
struct Pix *pixsc; /* downscaled pix with mirrored border */
l_int32 reduction; /* 1, 2 or 4x for intermediates */
l_float32 spatial_stdev; /* stdev of spatial gaussian */
l_float32 range_stdev; /* stdev of range gaussian */
l_float32 *spatial; /* 1D gaussian spatial kernel */
l_float32 *range; /* one-sided gaussian range kernel */
l_int32 minval; /* min value in 8 bpp pix */
l_int32 maxval; /* max value in 8 bpp pix */
l_int32 ncomps; /* number of intermediate results */
l_int32 *nc; /* set of k values (size ncomps) */
l_int32 *kindex; /* mapping from intensity to lower k */
l_float32 *kfract; /* mapping from intensity to fract k */
struct Pixa *pixac; /* intermediate result images (PBC) */
l_uint32 ***lineset; /* lineptrs for pixac */
};
typedef struct L_Bilateral L_BILATERAL;
#endif /* LEPTONICA_BILATERAL_H */

View File

@@ -0,0 +1,62 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_BMF_H
#define LEPTONICA_BMF_H
/*
* bmf.h
*
* Simple data structure to hold bitmap fonts and related data
*/
/* Constants for deciding when text block is divided into paragraphs */
enum {
SPLIT_ON_LEADING_WHITE = 1, /* tab or space at beginning of line */
SPLIT_ON_BLANK_LINE = 2, /* newline with optional white space */
SPLIT_ON_BOTH = 3 /* leading white space or newline */
};
struct L_Bmf
{
struct Pixa *pixa; /* pixa of bitmaps for 93 characters */
l_int32 size; /* font size (in points at 300 ppi) */
char *directory; /* directory containing font bitmaps */
l_int32 baseline1; /* baseline offset for ascii 33 - 57 */
l_int32 baseline2; /* baseline offset for ascii 58 - 91 */
l_int32 baseline3; /* baseline offset for ascii 93 - 126 */
l_int32 lineheight; /* max height of line of chars */
l_int32 kernwidth; /* pixel dist between char bitmaps */
l_int32 spacewidth; /* pixel dist between word bitmaps */
l_int32 vertlinesep; /* extra vertical space between text lines */
l_int32 *fonttab; /* table mapping ascii --> font index */
l_int32 *baselinetab; /* table mapping ascii --> baseline offset */
l_int32 *widthtab; /* table mapping ascii --> char width */
};
typedef struct L_Bmf L_BMF;
#endif /* LEPTONICA_BMF_H */

View File

@@ -0,0 +1,634 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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.
*====================================================================*/
/*
* bmfdata.h
*
* This file contains data for constructing the bitmap fonts.
*
* The fontdata string holds all 9 sets of bitmap fonts in a base64
* encoding of a pixacomp representation of the tiff compressed images.
* It was generated by prog/genfonts and pasted in. This allows
* the use of the bitmap fonts for iamge labelling without accessing
* stored versions of either the tiff images for each set, or the pixa
* of the 95 printable character images that was derived from the tiff image.
*
* In use, to get the bmf for a specific font size, from the encoded
* string in this file, call
* bmfCreate(NULL, fontsize);
*/
#ifndef LEPTONICA_BMFDATA_H
#define LEPTONICA_BMFDATA_H
#define NUM_FONTS 9
static const char *inputfonts[] = {"chars-4.tif", "chars-6.tif",
"chars-8.tif", "chars-10.tif",
"chars-12.tif", "chars-14.tif",
"chars-16.tif", "chars-18.tif",
"chars-20.tif"};
static const char *outputfonts[] = {"chars-4.pa", "chars-6.pa",
"chars-8.pa", "chars-10.pa",
"chars-12.pa", "chars-14.pa",
"chars-16.pa", "chars-18.pa",
"chars-20.pa"};
static const l_int32 baselines[NUM_FONTS][3] = {{11, 12, 12}, {18, 18, 18},
{24, 24, 24}, {30, 30, 30},
{36, 36, 36}, {42, 42, 42},
{48, 48, 48}, {54, 54, 54},
{60, 60, 60}};
static const char fontdata_4[] =
"SUkqACYFAAAmoHICP///////////////////////kFcchgc45Bgc45AgcgxBY5DY5DY5Agcg"
"jkM45A8GocgxBA8M45BfCGgchhzOQxZBiNe/CDQRT6RQ+k4QV6BHcgvBBjCC+KoSjQI7wjj/"
"16I+EUPTpV0rI4LilVtAjjyPuR58jg3CRd6dJkcDMCj+v//qlVsMgQPVY6vugih9Lr/8RCF+"
"OqUUK6C/fHFV9RStf8MulG10fKcN6X+lXOBg+GexX71wxSPCf4/+kE0uR5zE0rtfCFg3oIp0"
"R+GF5DSmQaMS/oG1xen0X2wyh8WXwoI46VPt/kNYcf9J4h/pUHB///2H+t+lkCByDj/r9ZBX"
"H1BAtUr7u/IEOQanrS0eByO16tpVaSWtaEVsNiG66WrBgg05wM4bCYNWDCWIiDCER6HGhERE"
"RER3ZHBfXjaSQ7iOP/////////////////////////////////////////////////////+Q"
"JgK95DIDRZAjCDccgRMhn4g5yC9CD0IL+QxhuIfCCYQTC4IJhBiyLBB7J4QX4gvQgxxBehBi"
"yGDkPhdkEw1kPZY5cEHck5BIJOQc9aI+wjE7DL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dP//qP/pMjhq8bSXwojsGkEwmliIiP/////////////"
"/////////////////////////wAQAQ4AAAEDAAEAAACSAwAAAQEDAAEAAAA2AgAAAgEDAAEA"
"AAABAAAAAwEDAAEAAAAEAAAABgEDAAEAAAABAAAAEQEEAAEAAAAIAAAAEgEDAAEAAAABAAAA"
"FQEDAAEAAAABAAAAFgEDAAEAAAA2AgAAFwEEAAEAAAAeBQAAGgEFAAEAAADUBQAAGwEFAAEA"
"AADcBQAAHAEDAAEAAAABAAAAKAEDAAEAAAACAAAAAAAAAAAAwBIAAAQAAADAEgAABAA=";
static const char fontdata_6[] =
"SUkqAMoGAAAmoHVf///////////////////////////////IZAUfsgeBdyGdyDjkMgI+QPKC"
"GIO5AhzOgyGiCMcgYtUrIKHohowhschs4hnwgXcgRQhsgguQQXwhov6/QYQI7qgRUUk2QIfV"
"F5hQmmugqCMTCBHj/9F8j9JuknWm7rSbCBFPLtou2sjhlBSOKkE3Qf3+kv9fpcMQaXY9PTwR"
"T6WvpX/0v19aVbeQ0D6X7+v/X//QIQfj6xSS4QLS3xx69IVtL/EQy8CvbSqhq4I7//pJeVnT"
"Dr/+Niloufj9fpJLxalYrDtdr2DGk/etf6CDrkduzQkw21/w2prRfYZcNbj1+kQMQuL03hF5"
"sQRT+CEMMj7pAjuk/5DVDINfr+k9b06Stj+GXgW6pN9/kNsdL/XQg/+nSx/0v20vxSv0v/S3"
"/yDA/19sV/6WkQ0D5DY/6+lkDyf/SX9h65BRBDTdJ/StLILuk2lWkl399U2kw0Thpa0r7S0U"
"A7S20rSVtJL/iGrFMSPJv+qYoEaA+KBA4pikmKCWIiDVCINaQ0KiIiIiIoFhoRfSodbS1xbp"
"Id0hx8f///////////////////////////////////////////////////IHMFnMgTA0hyGQ"
"G45DLcg0jkQfyGQDNxBv5DLcg3QQ2EEHDIEaEHDIaDkMTJzIeZBJkEmTwh5kNmEPhB7ITCGi"
"ZDOghsmQ0IIbJhHUEMzPAh8jYOeIuRsEZFHCZEHBDhdoww1D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JHmHD6BYbNhoDEjzSbDDLhJo"
"NnHSdQ4cMJoMJQ0DpBphVC//x9v/ScMEkwqf9Lpp6dJum18cQwX3V9XXWv/pN9OkKX/9f6X1"
"1/TpdX+6umrDdRSS2yBGFv4iQZu/9D//4r//f/58CP3XI/p7pL9F9peEYv/zAF8NL/hFP///"
"/t/utrrutN6SQYr0F//7Ff+3////g3/11dJ+l+I/+ld7ey4KP+3//fpX5DOOD/3sb8j+6X/9"
"en1+v/b//dLr//Vuo0rY0ib//aphKGYdtAinbLfROC//Yf/8NKGEmwvaUOwvtK3SX/7DPcUG"
"NjhsUEHhBwwg8JuEGEGEHDCDhhiopiCKcIOKeJHTd8JNuh/+IiIiIsubERxEREREZcNKIiIi"
"IiNDj+En/X/IbQdf/+Cj/9Npd6SXq3WLDSrwSEdigkEGCDrEREf/////////////////////"
"///////4AIAIAA4AAAEDAAEAAABBBAAAAQEDAAEAAAA6AgAAAgEDAAEAAAABAAAAAwEDAAEA"
"AAAEAAAABgEDAAEAAAABAAAAEQEEAAEAAAAIAAAAEgEDAAEAAAABAAAAFQEDAAEAAAABAAAA"
"FgEDAAEAAAA6AgAAFwEEAAEAAADBBgAAGgEFAAEAAAB4BwAAGwEFAAEAAACABwAAHAEDAAEA"
"AAABAAAAKAEDAAEAAAACAAAAAAAAAAAAwBIAAAQAAADAEgAABAA=";
static const char fontdata_8[] =
"SUkqALIIAAAmoHcGf/////////////////////////////////kMgMsfUgeDaOQLjkHHIZAN"
"T5A8K5AiDQQ0OW7kMqCEHIZthNJkcMwuGQG8g34gYcgo8go4hmwQIDIGIIL1EGOIKO1/wRmG"
"cvBqEX3S3dBGJhUwmlQSpGINF2/9cIxkfa9U+k2Q2OlpNgqaNzWwgWk2k33Veluk2q6STadJ"
"U2jHlzcJtZcGlS4RJOt9f9f9L62GMw+vC0np5HXS/0n/6Vf9dapwxpdj7rr6Wl/f//v9dJLa"
"kG76X/XXpf//v/j62kl4I2i4ZVd8caX8UrS/xEgvV7aVMUP19f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p7pXjSW5DRhFH+sLuor///6C//33X4P91bl1pjdJKt"
"hovBr4iQPKn/x/X/F////7NAz/v0tavW9aYaXhG3/+YDM2l/zCf///+3+9e3TvSTeglDFegv"
"//bS/9v//+vw3/q3Wt6pf0PpfV3+xX/t//3635DNv9utb0R9t1X4/+vreyOGZ/2//+uvyGx3"
"/16elvVIjH//Xp3/X/2//3X3//WKjjSeNb/+10rtWyMfX/2//7q0rX6u1d2kraSr/3RdYaTD"
"LdsIv2GvJAZ/+w//2GErCCbCLr2EoNiR161b0l/9g0HI6FBimKg2KCB2CBwwQPBA2wQMEDBA"
"4MEDhhiFFBisETgwITTCg2vCTDaQ//ERERERZg2IjiIiIiIzAa8REREREccfwgg/9f6X+v+Q"
"ZK///0x/+m0sF0q9W0sW6XyGSGkOkI7YSr4rYhAkEGCDrFhCI4//////////////////////"
"///////////8AEAEDgAAAQMAAQAAAP8EAAABAQMAAQAAAFUCAAACAQMAAQAAAAEAAAADAQMA"
"AQAAAAQAAAAGAQMAAQAAAAEAAAARAQQAAQAAAAgAAAASAQMAAQAAAAEAAAAVAQMAAQAAAAEA"
"AAAWAQMAAQAAAFUCAAAXAQQAAQAAAKoIAAAaAQUAAQAAAGAJAAAbAQUAAQAAAGgJAAAcAQMA"
"AQAAAAEAAAAoAQMAAQAAAAIAAAAAAAAAAADAEgAABAAAAMASAAAEAA==";
static const char fontdata_10[] =
"SUkqAGwKAAAmoFQGz///////////////////////////5DIBocgZg0PkDwy3JvkFdyB4Qchl"
"DkGB7yB5OnZBQ5J8hmckQ0rBNUyDSOkQWnIZXkMqZBrghs0INDkM/kdkDfsLqqhGYKDEHp0k"
"G0HkFEwoQaaqCcWQzzCMMPXfwg0m0gi89KyCgekkYmCpppYQKgjc0m//0Yy8/16VtP0EGwqN"
"to22ugtBBtJv2vpLdJtJJ1SbTpJKwjnoOgg2swGmFLgiStb3+lXf/69v1bYLpuuR1pLVX//X"
"r/S60mwYorKXH/dfS69J/2vX/9UvYyGU699PXXpa/3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63+++ONV/6X8uu3r+l/iOP2t6uk9Cl"
"4WHqR8e7r6SH/Uf/S+19v3/f/96dGF7q0kvCw0qCBAn6vpff//pe9e39/3pX/a9XTaTql5A9"
"wQ2QEmHWgmKer6X8iPkR1/9L7X30vSS///991bpL1TCCDBpKv76Vb/9f+l719+/W+lD/erXW"
"K0v7wggw0qS9K4YIL////QX3+3/pfpMoBq/a9XTTapfWCCIFy4MNL694g/44+P9fdL2/8Jfn"
"mzoGZ96dX+6S92ggsMNLS9bmyD///i/v9v/P/6BMP+/r22KS8RCBCGGl+teDf84POD82DH79"
"1//5HDL+Gw3+6/a/XhBBhpddK+/9PT//N7/r2/8b9yGpT/q1ek2l9BBuvS6vu9f+yDuRj/+3"
"9r7ff/2D/2r16MLpfT9+kh7/X/xf/t+9e39fW2/71q2qV6XsML+qV//jjkCM/9h/a+36+u2/"
"/9dU3peGDCCbdtalw/2/93/9v3r/f2/b/20r71frwwyGWXBBVbaL8JK/+l9//t/a+33X1//7"
"G+levhh4QIXYqKNFX7fWQR9v/9vIO+9e3uu2ltkND/rHUaTekQw/hhiEE2IpK+l6///7elx+"
"33X+313TXX6X5A9uQUQGGEEQa4tKr9vS/b//b/a9jbS20tvX16dJvS/TChgwgk2Gkr6TDILj"
"4S/Yf/7f/+2ltpfdbaX6Tfr90GwgtsJd4JNhcEtLb//b/r3YaWw0tu0uDBJp9fSX/B4WGeNB"
"NNCEGZkghCCGEGGZlCDCDCDwg2GhhN0GE3YYJBBsMEEEGw4YJBBsV00kw0Gh+1QeE0xCCDBB"
"hBMQkCChBsQggwQYQeEG2FBA8IGCBuGIQQYYoINuIQINr8JWCBr4qIiDCERBhCIgygDw1IiI"
"tCLhghBghEGEIMJrxER+hEaERDiIiPpaB/0g/SIGwCcdJFzOgGgr6jEGvGgamgH2EL4j////"
"//////////////////////////////////////////+QP6EDob+QPBoHIElkDw9kCyyBJBA8"
"F7INVkDYDEZDLjyGVCZBXmCqQZPIaUENEAoKlt5A8sTSfV00/S2/6BwdF3D+Dg//pr6Q/+QW"
"wbj//MKvrtNeC/9JN1/iP//+vr//+k3////9r///+k9ZeECzPy+IZY5BuP5AuOXhHhDKHL4g"
"tOXxBowscg3HLjIGByHHIG9CMci+Qzv/+3BEMyeEGQMUCGQLzyBimgwUgRmRewVNBgqDIZXg"
"qYQsFTIEUyGzAUgucuippgmRLIOcuhDFX/pYhPTChGHCNzROBBuKAXpgoLoLBU0wVMIwwwVN"
"Fzgqow2icEgoYIGCDBYMK0EGEDClxP/7YRtvl20YOgg6CDYVBNaMXfQXovNGK6MUIJt0XbCT"
"WqCDhX336B6apJL/0ug3bpB0nSsGbDZZsNghBsHB9BYNhiE2GIQbSbBsNoJwYkergzYN4P1p"
"9pXXX/q3vTaWrr6V1/pf9at02vTX/t7fTaT+l/9Y/rr0370/6XTT0/fr44/6WnuukKpdkFFk"
"K/pN+9DWv//6C//S/rq/7+XVJum9Kt0DXxEF9V///9f/991+ZgY+6Tf8VrQSww0YwaXkDwOE"
"f/H3X/H////sH/+k2k1dJN6SQYrwjj//Ng1dL/m0////9h/t1/tvpN6SQa9Av//ev/b////w"
"3/rpN6ekrelQ+v//sMJf+3///X4N/3t+lt6X4+l6V33hiF/7f/9+t+D/ulr6L70q////+XBp"
"/7f//XX5BQO/9/TdJNvpER//16d1fS/9v/919//1emONK71r//0rtb1/9h//3Wla/XrHWrxS"
"S//YRdbpsijtourZFfT/9v/9+0E2vrZ3hourW0k26X/7aWgwgmGFYaVsMJJzWBDtPTYaaYTt"
"O20oaTYRhUGnUUxV76V0kF/9ioOXQpigxUNiggbYQOGEDwg3CBggwg4MIHDYaCimIWEHDCCa"
"ah9OrDeP/2ENBoNMIQwhbERxkcMgYqbQTCxDEJpoX8RocfxEREUYE4jiOIiIj/2En/r/IG5d"
"J/1/////H69JtLIH9NJf3S6uq9ISh0CxdL8gt46iO2kl6FbYSCQIMIHWGISCTCbWIiI/////"
"/////////////////////////wAQAQ4AAAEDAAEAAACoBQAAAQEDAAEAAABCAgA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0vtL2/9L8IKdQ0/uk39U3SXvhBEMomGGgv+rg/44+P9ff+/8JfnOynBp/f1q+qXtMIIFhh"
"paXq84Qf//8X9pe3/nP/BBv961b7Yr8RCCww0vSXvITv58efH5wNH79/2/9hfuG/9ev3S8II"
"QwaX9Je3/CDwg//zif2l7/4/tkNQP9vbXpPS8IINpdfvvf///7fv+339/kNqf+l7a20l8IN1"
"fpJX36/9kGCP/Df6Xt//7Yf+/r0Y//v+lx7/X/3/7f3/fpeltv+9at0lel8MEt/ST9/33chs"
"//2/evb39/b/9f1pvS8MMIJvbRHWpgMfv8cbD/+39r79/f7/t02l6vpeGGQaSYQT3YXX/9L/"
"/9v3r2/r62//X29K9Lww8IIXYrCR4Sv2/9v/9h5Bgftfb3XbXbINx/1/rpX8gw/hg8IKwwmI"
"S76V6WQXf//29divvuvrbuu9uo46vS/DDEIJsWkkr9vS12//2//29tLbrtV+o3dJvS/IHnBA"
"vYMMEEQ04bFLfpvS62//2/39jettLfrdWqpX0v0woYYQSbaS3pNkM4+l+3/+3/Xu2l2lt69p"
"fpXr+tBhhArbCVPhJhhcJft//t67+7DS20tu62GvT030v+G0FsMJLagkygWmRaYLsNdf21BV"
"q12GEsMMJd2EtgwSafX0gv9B4WGfMIEUAgNCgxSEIhlkyC+oZoOQY0IXQhjXIZ9GDQyGEOCI"
"YYKAIsGCRAvoydogX0YcGEiGXoxX0CTBkC+iH7Sh4TQYhJqgQYSBLhiCu/t1vTtwxCsMQrbY"
"hWwunSbv8aERDCERBghEQZIA8GWIiNCLhghBghEGCEGF+IiP0IjQiJA8C+CIiK64QP6pB+kk"
"gf+i4zUBoDN0iBKb0INfCigak4HhI0QMw1IvYQjj////////////////////////////////"
"////////////kD9BA6hrjkM2CGYP5DIDUggeBiyB9hBYsgeGVBDVggbQ2ZiVHkGiCB4rkDfy"
"B4bJqQN5kNdyCiCBEyDVNBbeQPHyqqqqaf/e6aRBYsgeBfEXcgUYnZDRZDUtLb/90hf//9NL"
"1/8gtgsP/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BCIiIhh"
"TeEGsQwmgwhd6EccfsREREIwE4jiOIiIjX+Egf//1f9f8gVq6/6////S1H0vSb8gfo0v90vu"
"v0m4WLrXkFsGsdRHtJL7S2GCCr4rDFEDwUYQyQ0yCCqGlhgqXaxERH//////////////////"
"/////////////////////4AIAIAOAAABAwABAAAAYwYAAAEBAwABAAAAeAIAAAIBAwABAAAA"
"AQAAAAMBAwABAAAABAAAAAYBAwABAAAAAQAAABEBBAABAAAACAAAABIBAwABAAAAAQAAABUB"
"AwABAAAAAQAAABYBAwABAAAAeAIAABcBBAABAAAASAwAABoBBQABAAAA/gwAABsBBQABAAAA"
"Bg0AABwBAwABAAAAAQAAACgBAwABAAAAAgAAAAAAAAAAAMASAAAEAAAAwBIAAAQA";
static const char fontdata_14[] =
"SUkqAKINAAAmoCAz/////////////////////////yGQBw/kMgGYcgw5DJBpvIHg1wR3kCuC"
"B4NFhbrIHiwnZAxZFjIafUQ2+BJJshrRkGnyGtBBqmQ05kNqyBcQQ1YINyZBRMhpfhf1CMwz"
"S5hqg9W4aggwoIGCDCWC4QYIPXrwR1BQm6Wkm6pGzYKmn2EFQRsgwjhB/9UjeXg0m1RifVkM"
"t1VBNhUGE1pAtBBtBN//hBYdboJOkk2nVJNgj3R4s8b8JUk6TftfpYfdafV09VbQXCDcEHWX"
"BWCmAIraTf/9eldL0ld1VcLp6bRddKkqff91Vf9fXbDeqtwum0v9L11v/+v+uqSwxR+rx/3S"
"9LS+vfqtf9da7DHr+/pel/79f1/9dKr5Boha9Lr/9L1/a/8fXSqsI/ev/HS9Kkrrv/IZ0n9V"
"aSXYIEU467ePX6j2v+I/tqulSulfX+qX0ldf/e9U6Q9wr1X6pfJ+u2l/kFqyO/tJYr2vr/qv"
"BA9JhpX/XeG0qqtq9f1SS9NIl3DS1/pg8MQlyJWuP/9JfF4QaTFN//EMaVd36/SIZrhNLnCe"
"EGob1/2U4bUJ/cLX/iDXQQb06Ydr0uw6RvZCaePX6V106EwdK2GF38NqQnJOzgE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+lj7aTrr//+l//T02vVj/1ownTaV0KSW2QzMv6b/xr///0F//39ff9r1r060luEDXx"
"ELuq///+l/+vv/B/vTa3TFeqWw0DS8hkBoI/+Gv1/xf/+/r7JAZn7+n2m6Sr0bMMJeQyAXmb"
"P/j7X/v////Z1Av90v19UmHhBJBj8I8P/8iAMXr/nE////9h/3tpN03dJN/QYXoL/+cBs2l/"
"7f///+G/3S/W3XfSSBr0vr/2GEv/b///r8H//W6+kr9ofS//9iF/7f///+Q16f39Poum3pfj"
"6X93+GC/9v/+61vwf90m10lb1S//9L+9mA1v+3///X7/39N6T3SX//07r6X/t//v+/kMt3/d"
"LX0rdVId//11u9vS/9v/+0tK//19jikm+q//16bbX1/9v/9/rX69YqnVtvS//tdL0XWyDj6/"
"+3//aVpNr39our/XFJf/6L+GgmGQo7aW2vf/t//t1DSsIwvpWW8NL6pJt0l/9sJcMJMMKwwl"
"sMLyXAv/2H/+2lDCCYaX2lFMVbTurdKl/7EKDiExTFScNAogRrDIMazQMHUGJAjVsg+pDGpt"
"JOCHUQ0DQGEopiFkCKoYSdqThlfBKD0P/60Y07WGFt/+wuv9iFCDXxCaa3pqnf/8MIWgYQME"
"DCEMEIcRHFghEREQwU5BBhYhhNBhDT4jQ4/iIiIhGw7xHEcRERH/0g/9f4Sf//yB+Bf+l/6X"
"/9f/+ra+PVfXWCf/q2uC6r9NoLpuq9RHHS/IGeOltpV9rtpJehWwwSIHg08EDCDrDEKECDIM"
"tVYYIfaxER/////////////////////////////+ACACAA4AAAEDAAEAAAATBwAAAQEDAAEA"
"AABKAgAAAgEDAAEAAAABAAAAAwEDAAEAAAAEAAAABgEDAAEAAAABAAAAEQEEAAEAAAAIAAAA"
"EgEDAAEAAAABAAAAFQEDAAEAAAABAAAAFgEDAAEAAABKAgAAFwEEAAEAAACZDQAAGgEFAAEA"
"AABQDgAAGwEFAAEAAABYDgAAHAEDAAEAAAABAAAAKAEDAAEAAAACAAAAAAAAAAAAwBIAAAQA"
"AADAEgAABAA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X/0vuvb1fpX0r/br79XqvIHhYIZdhWHWEE6TaT//kF3yC7//pe6+/"
"XrX//rpatpWkvhNMIIMNUko/vS9v/r/0vuvv7670r/er3punVL7UEEGHXvpegq////S9/2//"
"/ph/3ut+k3SX9hAgw0tKvfCS//r/6X2l7er6SvpQ/9enVjtKvXCCDDSSS9bhggX///+l7/t/"
"6X4SZ1BW+3X/T6++EEQaBMMNL/p4h/668f6C+0vf/S/CTIgGz+ut01aSX00EFhg0tV+4P+OP"
"/0/f+/8JfmIYP96un23SS9poILDDS6rSeeCB///xf6Xt/5ZH8Ew/73XXvS8RCCwYaX6XeDf/"
"88GX+H7f7f+wX7hh/69XVsVXgghDDrX0vb/ngfPA//57f6+3/j+2Q2hH717+6+EEGGl0l77f"
"++//7ft17f/+2QV9f7W19PS8IEGHX6S3v9b7//t/r//9bkFNH709NqjabSXwg2v/T93///+3"
"7de33Xf2G/7/6S9L4Qer1SQvf1/7IN6v/b/X2//9sP+66V9N9fa79V+/X+9/+37de3v7+2//"
"Xvrevwwv6pX/+OOQzJ/+3+vt+l6W//e2ukk+l4YMIJ7fVGwz/vX7D/+37df9/f2/7pdXpN6X"
"hhhArfRdUqf36///b/X29//b/7/f768MMhqiYIJrbS0Et/f+//7ft17fpb1t/7paWqT6+GHh"
"BC22lpU/vpff/7f6+339r/6X33SV6RBRHhh4QVsUxCJ2t9XrkG77f/7eQUPt17e9b1tkC8V/"
"exv76VeDB4QThhMJa9W+v//9vX/77S7S2/73Sr0m9L8MMQgmxGlf70tdv/9v+K99v39vS3X9"
"ikr6/IHhYINEBhhBEFS7S70m9L9v/9v9/b3S20v/umKrV9fwmChhggSbaVP03hLrv/9v+vY7"
"S7S29L136b0v7UMMILYYSW9WGQLvpft//sPS3/bS20tu67S90r0l/oMMIJNtL8JMMJYS1ww/"
"/2//3YaW2lt2lthWqpX0v1w2gsMMElbwSYMElIOfW2Gt3fbarbXuGwgrYaCu7CVsGEv0r6C+"
"6QPC2DCSpoQgxoQkNWDCq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Ta9P//61aXWl/63/q6Wl/1/pdV19/XQ//dft039Vv9Nj03/7evv+l7vuk9Nr9j+6ujC"
"aTpaQqvZBp4gQ/q/6Qpa///hL///S6v/q/7SvSrcINP6t9////9Bf/97/3+2vTdN06SSWw0D"
"S8RIHgrU9f///0v/1//ZQDX/3XVj9IILDDQa+QyAatP15OJ+v+L//39fmoMz91dfTdbegpsg"
"0vIZAZlDd/8ff/3////sH+66tpPqkw8JJBivCPj//KgDF0v+eT////2/+nr3fSb0kga8IF//"
"PBt7S/9v//+vwb/bW1bq7SSfqg16X1/7df+3////hv/r9b9K/wwvS//9hhL/2////8g2Eft+"
"l0rdfq0P/93+GIX/t//39X5BUn/pN7ejG9Uvx9L0v/Bgv/b//61/D/39apNvSX//7v3y4bf/"
"b//f6/IZkP+6Wr0t2qX//1d74S/9v//X2//19+1Sf0iGH//XX1vS/9v/+60v//bWK6Stuv//"
"+m219f/b//f1tfrtetjpvVJf/sLpdq3r/7f/9pXTa/+sbWk2xSX/9owtoJttGFhkHfT/9v/9"
"urQTa9pWSHbRftbS+lX/thBcNJhkOOwwlsMJcqwyv+w//20rCUMI2v9pwwl9aTbS//xXDCCb"
"CsQrY1hra6sGtrrbaUNBMQtbSYpit/VvSBf/ak4ZzCFMbUkBsRDPU2QYrlAOawzyBFbkHrIP"
"WauUA5rCFAbGlEINZAhPDCCpqUBmp2gSg9D/9hdNNBrDC2//YXX+xCnkmF8U01vXTtf/hoaB"
"hAwQaEMEIOIjiyOGQCwCwwgYWIMEGgwh/EccfoREREI2CPEcRxEREa/wgg///hJ/6/0n/X/I"
"HiiX///pdfT+n/+tpePX9fhfX1bSyB49NKvptL7/1IHg1wEYA1CxdKvSEdtJLyBmDU/2l/YS"
"2wkl8eGGEEQPDXcJBBhBpYYhMQgQMgUVwsGaAeCsF7WIiI//////////////////////////"
"////////wAQAQA4AAAEDAAEAAADOBwAAAQEDAAEAAAB3AgAAAgEDAAEAAAABAAAAAwEDAAEA"
"AAAEAAAABgEDAAE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f+tq9JvSvpYYXpf/+wwgv/b////wb/bp6tbvSv2h9L+7/Yr/2//7/vyCuR/r/oxvSS/H/1/8"
"ML/2//+tL8H/erSel36/9L6/vBgv/b//f/8P/a/apN2kl//+22r6MArf9v//+n8g1O//TpPS"
"Tb6//+l/4S/9v/+0tb//Vtb7VK70iC8f/r1drel/7f//9f/69R/vpJf//q2+3pf+3/+3Wtr9"
"er7T0k231//YXS7X1/9v//StJtf+1j40rikq//RhbQTDbRhWyBA+n/7f/7faCte0rtG1qnSb"
"df/20uGk3YS4YXv/2//20oaTYRtf7Juwwgt3pXpJf/sILgwgmGQsMMILYYXlIGZ/2H/+2lDB"
"BMMJfDSjiuvSt0l/9irMPFMUxVsUnDTtPTYaaYTtO2GEopiFoM0WEmqTenVukP/6jmEnakgC"
"6IaE7DIMDJIDBThokNCdyC6cgunLGSGCEYHJANxChMLIaBEQqakMGn0CTB6/+wtIMINBrYLf"
"/2F/+wp5INegmmFtNPW//4NDQMIMEDQgwhBsRHEMjhkhAsGEDCxBhBoGEP4jQ4/iIiIhHATi"
"OI4iIiP/hBA3/X+Eg///pf9f6T/r/ZA8OLf//+l16T1///a6/S+k9aj//a5Arq0q9JtL//wY"
"YQLdtKvSEcdV8gaIddtKvTS20kvj2GEkvrYYIIgeCsOEggyB6sIOtiFFEFsGRPE6AZgsLDCY"
"XsFkDYDScREcf////////////////////////////////////4AIAIAADgAAAQMAAQAAAIEI"
"AAABAQMAAQAAAIsCAAACAQMAAQAAAAEAAAADAQMAAQAAAAQAAAAGAQMAAQAAAAEAAAARAQQA"
"AQAAAAgAAAASAQMAAQAAAAEAAAAVAQMAAQAAAAEAAAAWAQMAAQAAAIsCAAAXAQQAAQAAADcR"
"AAAaAQUAAQAAAO4RAAAbAQUAAQAAAPYRAAAcAQMAAQAAAAEAAAAoAQMAAQAAAAIAAAAAAAAA"
"AADAEgAABAAAAMASAAAEAA==";
static const char fontdata_20[] =
"SUkqABATAAAmoDgf////////////////////////////+QyQy7IGwGXP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f77c2q33SX4Qafpf9Cl///4QX/+//V/2vXulqqW6DX6b/X///9L///S+"
"H/1q2k2k9JJbaBpeIgu///X/pf/97/sH+2rdfFWtILDDQa+QyQ31/XX//9P/9f/5qDU/1rdN"
"PpJbaPEQzXkMgCsR6/H3/8f/+/r7IgGn7/Tq1dJBh4QVBivBFB///S/7////2H/aVr16qw8J"
"JBrwjQT/8gYZt6/59P////Yf7703tvST6SQNegX/8zBT2l/7f//9fhv+6/Sbtav6DXhBfX/t"
"pf+3////hv/XSvTekn6UGF6X//tpf+3////g3+9N7/6V6tD//d/sMJf+3///35Bk0/tddJNt"
"V/H0v//Yhf+3//daX5AkR+/03o3vpL//0v28ML/2////8H/tK10km7Wv/S/d/wzCBf+3/+/1"
"+/771elvSX//1d/pD/7f//WrfkGuP+0tX1b9IgRH//r63hL/2//7Xr/f1+/SpttJf/9em730"
"v/b//f1v/7V6er0r9L//XSttb1/9v//rptfr+1jY0ntUq/+197X1/9v/+0rS1/9XqqVtiqX/"
"9bQVtowrZDYPr/7D//b7SYa9pW2jCxu6V6//thG/aTdhLbC9/+3/+6VoK1/yKPYS3rSbaS//"
"hhLhhJhkMOwwlw15AgaP+3//aVpMMEc/aVhOGEuulfS//iFoMIJhhWKthhJYd2urBra922lB"
"ggmK1tJimK/eraSBf/asqIpgwVqGwYJBA2GCDhhA8IG2EDBAwQODBBw2GlFMLCKcDDCVVBu1"
"hJh6H/7Cjm0ExQanQMoUQ2F7IEF50DBLhokNghyGC5DBcEDnQHIgEOgFwYIKE1kNgOUGE0wo"
"OtoKw9f/a6DQaDC2Cw//sF/+xCn0gwvimg1vXW0//hhDQMIMEDQgwhDYiOLLhkhlBYMEDCxD"
"BBoMEO+I44/iIkCThILGBHgTiQyQaOxHIHh+EREa/xFBEM58fH/sIJ/6/wk///pP+l/kDwIK"
"////X/3r+uvStf///8ev0nrC+v9pZA8WvSr0g2l//7aXtpfqJTgi4GwGeP16QjtpJeQNAanX"
"tL+0tsJJehWwwgklX2GEgkmg6wxCBIgZiCCB+DrDChfCyBtDOdkcDMMcMLEREf//////////"
"////////////////////4AIAIAAOAAABAwABAAAATAkAAAEBAwABAAAAcwIAAAIBAwABAAAA"
"AQAAAAMBAwABAAAABAAAAAYBAwABAAAAAQAAABEBBAABAAAACAAAABIBAwABAAAAAQAAABUB"
"AwABAAAAAQAAABYBAwABAAAAcwIAABcBBAABAAAABxMAABoBBQABAAAAvhMAABsBBQABAAAA"
"xhMAABwBAwABAAAAAQAAACgBAwABAAAAAgAAAAAAAAAAAMASAAAEAAAAwBIAAAQA";
#endif /* LEPTONICA_BMFDATA_H */

View File

@@ -0,0 +1,85 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_BMP_H
#define LEPTONICA_BMP_H
/*
* This file is here to describe the fields in the header of
* the BMP file. These fields are not used directly in Leptonica.
* The only thing we use are the sizes of these two headers.
* Furthermore, because of potential namespace conflicts with
* the typedefs and defined sizes, we have changed the names
* to protect anyone who may also need to use the original definitions.
* Thanks to J. D. Bryan for pointing out the potential problems when
* developing on Win32 compatible systems.
*/
/*-------------------------------------------------------------*
* BMP file header *
*-------------------------------------------------------------*/
struct BMP_FileHeader
{
l_int16 bfType; /* file type; must be "BM" */
l_int16 bfSize; /* length of the file;
sizeof(BMP_FileHeader) +
sizeof(BMP_InfoHeader) +
size of color table +
size of DIB bits */
l_int16 bfFill1; /* remainder of the bfSize field */
l_int16 bfReserved1; /* don't care (set to 0)*/
l_int16 bfReserved2; /* don't care (set to 0)*/
l_int16 bfOffBits; /* offset from beginning of file */
l_int16 bfFill2; /* remainder of the bfOffBits field */
};
typedef struct BMP_FileHeader BMP_FH;
#define BMP_FHBYTES sizeof(BMP_FH)
/*-------------------------------------------------------------*
* BMP info header *
*-------------------------------------------------------------*/
struct BMP_InfoHeader
{
l_int32 biSize; /* size of the BMP_InfoHeader struct */
l_int32 biWidth; /* bitmap width in pixels */
l_int32 biHeight; /* bitmap height in pixels */
l_int16 biPlanes; /* number of bitmap planes */
l_int16 biBitCount; /* number of bits per pixel */
l_int32 biCompression; /* compression format (0 == uncompressed) */
l_int32 biSizeImage; /* size of image in bytes */
l_int32 biXPelsPerMeter; /* pixels per meter in x direction */
l_int32 biYPelsPerMeter; /* pixels per meter in y direction */
l_int32 biClrUsed; /* number of colors used */
l_int32 biClrImportant; /* number of important colors used */
};
typedef struct BMP_InfoHeader BMP_IH;
#define BMP_IHBYTES sizeof(BMP_IH)
#endif /* LEPTONICA_BMP_H */

380
windows/libs/include/capi.h Normal file
View File

@@ -0,0 +1,380 @@
#ifndef TESSERACT_API_CAPI_H__
#define TESSERACT_API_CAPI_H__
#ifdef TESS_CAPI_INCLUDE_BASEAPI
# include "baseapi.h"
# include "pageiterator.h"
# include "resultiterator.h"
# include "renderer.h"
#else
# include "platform.h"
# include <stdio.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef TESS_CALL
# if defined(WIN32)
# define TESS_CALL __cdecl
# else
# define TESS_CALL
# endif
#endif
#ifndef BOOL
# define BOOL int
# define TRUE 1
# define FALSE 0
#endif
#ifdef TESS_CAPI_INCLUDE_BASEAPI
typedef tesseract::TessResultRenderer TessResultRenderer;
typedef tesseract::TessTextRenderer TessTextRenderer;
typedef tesseract::TessHOcrRenderer TessHOcrRenderer;
typedef tesseract::TessPDFRenderer TessPDFRenderer;
typedef tesseract::TessUnlvRenderer TessUnlvRenderer;
typedef tesseract::TessBoxTextRenderer TessBoxTextRenderer;
typedef tesseract::TessBaseAPI TessBaseAPI;
typedef tesseract::PageIterator TessPageIterator;
typedef tesseract::ResultIterator TessResultIterator;
typedef tesseract::MutableIterator TessMutableIterator;
typedef tesseract::ChoiceIterator TessChoiceIterator;
typedef tesseract::OcrEngineMode TessOcrEngineMode;
typedef tesseract::PageSegMode TessPageSegMode;
typedef tesseract::ImageThresholder TessImageThresholder;
typedef tesseract::PageIteratorLevel TessPageIteratorLevel;
typedef tesseract::DictFunc TessDictFunc;
typedef tesseract::ProbabilityInContextFunc TessProbabilityInContextFunc;
// typedef tesseract::ParamsModelClassifyFunc TessParamsModelClassifyFunc;
typedef tesseract::FillLatticeFunc TessFillLatticeFunc;
typedef tesseract::Dawg TessDawg;
typedef tesseract::TruthCallback TessTruthCallback;
typedef tesseract::CubeRecoContext TessCubeRecoContext;
typedef tesseract::Orientation TessOrientation;
typedef tesseract::ParagraphJustification TessParagraphJustification;
typedef tesseract::WritingDirection TessWritingDirection;
typedef tesseract::TextlineOrder TessTextlineOrder;
typedef PolyBlockType TessPolyBlockType;
#else
typedef struct TessResultRenderer TessResultRenderer;
typedef struct TessTextRenderer TessTextRenderer;
typedef struct TessHOcrRenderer TessHOcrRenderer;
typedef struct TessPDFRenderer TessPDFRenderer;
typedef struct TessUnlvRenderer TessUnlvRenderer;
typedef struct TessBoxTextRenderer TessBoxTextRenderer;
typedef struct TessBaseAPI TessBaseAPI;
typedef struct TessPageIterator TessPageIterator;
typedef struct TessResultIterator TessResultIterator;
typedef struct TessMutableIterator TessMutableIterator;
typedef struct TessChoiceIterator TessChoiceIterator;
typedef enum TessOcrEngineMode { OEM_TESSERACT_ONLY, OEM_CUBE_ONLY, OEM_TESSERACT_CUBE_COMBINED, OEM_DEFAULT } TessOcrEngineMode;
typedef enum TessPageSegMode { PSM_OSD_ONLY, PSM_AUTO_OSD, PSM_AUTO_ONLY, PSM_AUTO, PSM_SINGLE_COLUMN, PSM_SINGLE_BLOCK_VERT_TEXT,
PSM_SINGLE_BLOCK, PSM_SINGLE_LINE, PSM_SINGLE_WORD, PSM_CIRCLE_WORD, PSM_SINGLE_CHAR, PSM_SPARSE_TEXT,
PSM_SPARSE_TEXT_OSD, PSM_COUNT } TessPageSegMode;
typedef enum TessPageIteratorLevel { RIL_BLOCK, RIL_PARA, RIL_TEXTLINE, RIL_WORD, RIL_SYMBOL} TessPageIteratorLevel;
typedef enum TessPolyBlockType { PT_UNKNOWN, PT_FLOWING_TEXT, PT_HEADING_TEXT, PT_PULLOUT_TEXT, PT_EQUATION, PT_INLINE_EQUATION,
PT_TABLE, PT_VERTICAL_TEXT, PT_CAPTION_TEXT, PT_FLOWING_IMAGE, PT_HEADING_IMAGE,
PT_PULLOUT_IMAGE, PT_HORZ_LINE, PT_VERT_LINE, PT_NOISE, PT_COUNT } TessPolyBlockType;
typedef enum TessOrientation { ORIENTATION_PAGE_UP, ORIENTATION_PAGE_RIGHT, ORIENTATION_PAGE_DOWN, ORIENTATION_PAGE_LEFT } TessOrientation;
typedef enum TessParagraphJustification { JUSTIFICATION_UNKNOWN, JUSTIFICATION_LEFT, JUSTIFICATION_CENTER, JUSTIFICATION_RIGHT } TessParagraphJustification;
typedef enum TessWritingDirection { WRITING_DIRECTION_LEFT_TO_RIGHT, WRITING_DIRECTION_RIGHT_TO_LEFT, WRITING_DIRECTION_TOP_TO_BOTTOM } TessWritingDirection;
typedef enum TessTextlineOrder { TEXTLINE_ORDER_LEFT_TO_RIGHT, TEXTLINE_ORDER_RIGHT_TO_LEFT, TEXTLINE_ORDER_TOP_TO_BOTTOM } TessTextlineOrder;
typedef struct ETEXT_DESC ETEXT_DESC;
#endif
struct Pix;
struct Boxa;
struct Pixa;
/* General free functions */
TESS_API const char*
TESS_CALL TessVersion();
TESS_API void TESS_CALL TessDeleteText(char* text);
TESS_API void TESS_CALL TessDeleteTextArray(char** arr);
TESS_API void TESS_CALL TessDeleteIntArray(int* arr);
#ifdef TESS_CAPI_INCLUDE_BASEAPI
TESS_API void TESS_CALL TessDeleteBlockList(BLOCK_LIST* block_list);
#endif
/* Renderer API */
TESS_API TessResultRenderer* TESS_CALL TessTextRendererCreate(const char* outputbase);
TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate(const char* outputbase);
TESS_API TessResultRenderer* TESS_CALL TessHOcrRendererCreate2(const char* outputbase, BOOL font_info);
TESS_API TessResultRenderer* TESS_CALL TessPDFRendererCreate(const char* outputbase, const char* datadir);
TESS_API TessResultRenderer* TESS_CALL TessUnlvRendererCreate(const char* outputbase);
TESS_API TessResultRenderer* TESS_CALL TessBoxTextRendererCreate(const char* outputbase);
TESS_API void TESS_CALL TessDeleteResultRenderer(TessResultRenderer* renderer);
TESS_API void TESS_CALL TessResultRendererInsert(TessResultRenderer* renderer, TessResultRenderer* next);
TESS_API TessResultRenderer*
TESS_CALL TessResultRendererNext(TessResultRenderer* renderer);
TESS_API BOOL TESS_CALL TessResultRendererBeginDocument(TessResultRenderer* renderer, const char* title);
TESS_API BOOL TESS_CALL TessResultRendererAddImage(TessResultRenderer* renderer, TessBaseAPI* api);
TESS_API BOOL TESS_CALL TessResultRendererEndDocument(TessResultRenderer* renderer);
TESS_API const char* TESS_CALL TessResultRendererExtention(TessResultRenderer* renderer);
TESS_API const char* TESS_CALL TessResultRendererTitle(TessResultRenderer* renderer);
TESS_API int TESS_CALL TessResultRendererImageNum(TessResultRenderer* renderer);
/* Base API */
TESS_API TessBaseAPI*
TESS_CALL TessBaseAPICreate();
TESS_API void TESS_CALL TessBaseAPIDelete(TessBaseAPI* handle);
TESS_API size_t TESS_CALL TessBaseAPIGetOpenCLDevice(TessBaseAPI* handle, void **device);
TESS_API void TESS_CALL TessBaseAPISetInputName( TessBaseAPI* handle, const char* name);
TESS_API const char* TESS_CALL TessBaseAPIGetInputName(TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPISetInputImage(TessBaseAPI* handle, struct Pix* pix);
TESS_API struct Pix* TESS_CALL TessBaseAPIGetInputImage(TessBaseAPI* handle);
TESS_API int TESS_CALL TessBaseAPIGetSourceYResolution(TessBaseAPI* handle);
TESS_API const char* TESS_CALL TessBaseAPIGetDatapath(TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPISetOutputName(TessBaseAPI* handle, const char* name);
TESS_API BOOL TESS_CALL TessBaseAPISetVariable(TessBaseAPI* handle, const char* name, const char* value);
TESS_API BOOL TESS_CALL TessBaseAPISetDebugVariable(TessBaseAPI* handle, const char* name, const char* value);
TESS_API BOOL TESS_CALL TessBaseAPIGetIntVariable( const TessBaseAPI* handle, const char* name, int* value);
TESS_API BOOL TESS_CALL TessBaseAPIGetBoolVariable( const TessBaseAPI* handle, const char* name, BOOL* value);
TESS_API BOOL TESS_CALL TessBaseAPIGetDoubleVariable(const TessBaseAPI* handle, const char* name, double* value);
TESS_API const char*
TESS_CALL TessBaseAPIGetStringVariable(const TessBaseAPI* handle, const char* name);
TESS_API void TESS_CALL TessBaseAPIPrintVariables( const TessBaseAPI* handle, FILE* fp);
TESS_API BOOL TESS_CALL TessBaseAPIPrintVariablesToFile(const TessBaseAPI* handle, const char* filename);
#ifdef TESS_CAPI_INCLUDE_BASEAPI
TESS_API BOOL TESS_CALL TessBaseAPIGetVariableAsString(TessBaseAPI* handle, const char* name, STRING* val);
#endif
#ifdef TESS_CAPI_INCLUDE_BASEAPI
TESS_API int TESS_CALL TessBaseAPIInit(TessBaseAPI* handle, const char* datapath, const char* language,
TessOcrEngineMode mode, char** configs, int configs_size,
const STRING* vars_vec, size_t vars_vec_size,
const STRING* vars_values, size_t vars_values_size, BOOL set_only_init_params);
#endif
TESS_API int TESS_CALL TessBaseAPIInit1(TessBaseAPI* handle, const char* datapath, const char* language, TessOcrEngineMode oem,
char** configs, int configs_size);
TESS_API int TESS_CALL TessBaseAPIInit2(TessBaseAPI* handle, const char* datapath, const char* language, TessOcrEngineMode oem);
TESS_API int TESS_CALL TessBaseAPIInit3(TessBaseAPI* handle, const char* datapath, const char* language);
TESS_API int TESS_CALL TessBaseAPIInit4(TessBaseAPI* handle, const char* datapath, const char* language, TessOcrEngineMode mode,
char** configs, int configs_size,
char** vars_vec, char** vars_values, size_t vars_vec_size,
BOOL set_only_non_debug_params);
TESS_API const char*
TESS_CALL TessBaseAPIGetInitLanguagesAsString(const TessBaseAPI* handle);
TESS_API char**
TESS_CALL TessBaseAPIGetLoadedLanguagesAsVector(const TessBaseAPI* handle);
TESS_API char**
TESS_CALL TessBaseAPIGetAvailableLanguagesAsVector(const TessBaseAPI* handle);
TESS_API int TESS_CALL TessBaseAPIInitLangMod(TessBaseAPI* handle, const char* datapath, const char* language);
TESS_API void TESS_CALL TessBaseAPIInitForAnalysePage(TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPIReadConfigFile(TessBaseAPI* handle, const char* filename);
TESS_API void TESS_CALL TessBaseAPIReadDebugConfigFile(TessBaseAPI* handle, const char* filename);
TESS_API void TESS_CALL TessBaseAPISetPageSegMode(TessBaseAPI* handle, TessPageSegMode mode);
TESS_API TessPageSegMode
TESS_CALL TessBaseAPIGetPageSegMode(const TessBaseAPI* handle);
TESS_API char* TESS_CALL TessBaseAPIRect(TessBaseAPI* handle, const unsigned char* imagedata,
int bytes_per_pixel, int bytes_per_line,
int left, int top, int width, int height);
TESS_API void TESS_CALL TessBaseAPIClearAdaptiveClassifier(TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPISetImage(TessBaseAPI* handle, const unsigned char* imagedata, int width, int height,
int bytes_per_pixel, int bytes_per_line);
TESS_API void TESS_CALL TessBaseAPISetImage2(TessBaseAPI* handle, struct Pix* pix);
TESS_API void TESS_CALL TessBaseAPISetSourceResolution(TessBaseAPI* handle, int ppi);
TESS_API void TESS_CALL TessBaseAPISetRectangle(TessBaseAPI* handle, int left, int top, int width, int height);
#ifdef TESS_CAPI_INCLUDE_BASEAPI
TESS_API void TESS_CALL TessBaseAPISetThresholder(TessBaseAPI* handle, TessImageThresholder* thresholder);
#endif
TESS_API struct Pix*
TESS_CALL TessBaseAPIGetThresholdedImage( TessBaseAPI* handle);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetRegions( TessBaseAPI* handle, struct Pixa** pixa);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetTextlines( TessBaseAPI* handle, struct Pixa** pixa, int** blockids);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetTextlines1( TessBaseAPI* handle, const BOOL raw_image, const int raw_padding,
struct Pixa** pixa, int** blockids, int** paraids);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetStrips( TessBaseAPI* handle, struct Pixa** pixa, int** blockids);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetWords( TessBaseAPI* handle, struct Pixa** pixa);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetConnectedComponents(TessBaseAPI* handle, struct Pixa** cc);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetComponentImages( TessBaseAPI* handle, const TessPageIteratorLevel level, const BOOL text_only,
struct Pixa** pixa, int** blockids);
TESS_API struct Boxa*
TESS_CALL TessBaseAPIGetComponentImages1( TessBaseAPI* handle, const TessPageIteratorLevel level, const BOOL text_only,
const BOOL raw_image, const int raw_padding,
struct Pixa** pixa, int** blockids, int** paraids);
TESS_API int TESS_CALL TessBaseAPIGetThresholdedImageScaleFactor(const TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPIDumpPGM(TessBaseAPI* handle, const char* filename);
TESS_API TessPageIterator*
TESS_CALL TessBaseAPIAnalyseLayout(TessBaseAPI* handle);
TESS_API int TESS_CALL TessBaseAPIRecognize(TessBaseAPI* handle, ETEXT_DESC* monitor);
TESS_API int TESS_CALL TessBaseAPIRecognizeForChopTest(TessBaseAPI* handle, ETEXT_DESC* monitor);
TESS_API BOOL TESS_CALL TessBaseAPIProcessPages(TessBaseAPI* handle, const char* filename, const char* retry_config,
int timeout_millisec, TessResultRenderer* renderer);
TESS_API BOOL TESS_CALL TessBaseAPIProcessPage(TessBaseAPI* handle, struct Pix* pix, int page_index, const char* filename,
const char* retry_config, int timeout_millisec, TessResultRenderer* renderer);
TESS_API TessResultIterator*
TESS_CALL TessBaseAPIGetIterator(TessBaseAPI* handle);
TESS_API TessMutableIterator*
TESS_CALL TessBaseAPIGetMutableIterator(TessBaseAPI* handle);
TESS_API char* TESS_CALL TessBaseAPIGetUTF8Text(TessBaseAPI* handle);
TESS_API char* TESS_CALL TessBaseAPIGetHOCRText(TessBaseAPI* handle, int page_number);
TESS_API char* TESS_CALL TessBaseAPIGetBoxText(TessBaseAPI* handle, int page_number);
TESS_API char* TESS_CALL TessBaseAPIGetUNLVText(TessBaseAPI* handle);
TESS_API int TESS_CALL TessBaseAPIMeanTextConf(TessBaseAPI* handle);
TESS_API int* TESS_CALL TessBaseAPIAllWordConfidences(TessBaseAPI* handle);
TESS_API BOOL TESS_CALL TessBaseAPIAdaptToWordStr(TessBaseAPI* handle, TessPageSegMode mode, const char* wordstr);
TESS_API void TESS_CALL TessBaseAPIClear(TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPIEnd(TessBaseAPI* handle);
TESS_API int TESS_CALL TessBaseAPIIsValidWord(TessBaseAPI* handle, const char* word);
TESS_API BOOL TESS_CALL TessBaseAPIGetTextDirection(TessBaseAPI* handle, int* out_offset, float* out_slope);
#ifdef TESS_CAPI_INCLUDE_BASEAPI
TESS_API void TESS_CALL TessBaseAPISetDictFunc(TessBaseAPI* handle, TessDictFunc f);
TESS_API void TESS_CALL TessBaseAPIClearPersistentCache(TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPISetProbabilityInContextFunc(TessBaseAPI* handle, TessProbabilityInContextFunc f);
TESS_API void TESS_CALL TessBaseAPISetFillLatticeFunc(TessBaseAPI* handle, TessFillLatticeFunc f);
TESS_API BOOL TESS_CALL TessBaseAPIDetectOS(TessBaseAPI* handle, OSResults* results);
TESS_API void TESS_CALL TessBaseAPIGetFeaturesForBlob(TessBaseAPI* handle, TBLOB* blob, INT_FEATURE_STRUCT* int_features,
int* num_features, int* FeatureOutlineIndex);
TESS_API ROW* TESS_CALL TessFindRowForBox(BLOCK_LIST* blocks, int left, int top, int right, int bottom);
TESS_API void TESS_CALL TessBaseAPIRunAdaptiveClassifier(TessBaseAPI* handle, TBLOB* blob, int num_max_matches,
int* unichar_ids, float* ratings, int* num_matches_returned);
#endif
TESS_API const char*
TESS_CALL TessBaseAPIGetUnichar(TessBaseAPI* handle, int unichar_id);
#ifdef TESS_CAPI_INCLUDE_BASEAPI
TESS_API const TessDawg*
TESS_CALL TessBaseAPIGetDawg(const TessBaseAPI* handle, int i);
TESS_API int TESS_CALL TessBaseAPINumDawgs(const TessBaseAPI* handle);
#endif
#ifdef TESS_CAPI_INCLUDE_BASEAPI
TESS_API ROW* TESS_CALL TessMakeTessOCRRow(float baseline, float xheight, float descender, float ascender);
TESS_API TBLOB*
TESS_CALL TessMakeTBLOB(Pix* pix);
TESS_API void TESS_CALL TessNormalizeTBLOB(TBLOB* tblob, ROW* row, BOOL numeric_mode);
TESS_API TessOcrEngineMode
TESS_CALL TessBaseAPIOem(const TessBaseAPI* handle);
TESS_API void TESS_CALL TessBaseAPIInitTruthCallback(TessBaseAPI* handle, TessTruthCallback* cb);
TESS_API TessCubeRecoContext*
TESS_CALL TessBaseAPIGetCubeRecoContext(const TessBaseAPI* handle);
#endif
TESS_API void TESS_CALL TessBaseAPISetMinOrientationMargin(TessBaseAPI* handle, double margin);
#ifdef TESS_CAPI_INCLUDE_BASEAPI
TESS_API void TESS_CALL TessBaseGetBlockTextOrientations(TessBaseAPI* handle, int** block_orientation, BOOL** vertical_writing);
TESS_API BLOCK_LIST*
TESS_CALL TessBaseAPIFindLinesCreateBlockList(TessBaseAPI* handle);
#endif
/* Page iterator */
TESS_API void TESS_CALL TessPageIteratorDelete(TessPageIterator* handle);
TESS_API TessPageIterator*
TESS_CALL TessPageIteratorCopy(const TessPageIterator* handle);
TESS_API void TESS_CALL TessPageIteratorBegin(TessPageIterator* handle);
TESS_API BOOL TESS_CALL TessPageIteratorNext(TessPageIterator* handle, TessPageIteratorLevel level);
TESS_API BOOL TESS_CALL TessPageIteratorIsAtBeginningOf(const TessPageIterator* handle, TessPageIteratorLevel level);
TESS_API BOOL TESS_CALL TessPageIteratorIsAtFinalElement(const TessPageIterator* handle, TessPageIteratorLevel level,
TessPageIteratorLevel element);
TESS_API BOOL TESS_CALL TessPageIteratorBoundingBox(const TessPageIterator* handle, TessPageIteratorLevel level,
int* left, int* top, int* right, int* bottom);
TESS_API TessPolyBlockType
TESS_CALL TessPageIteratorBlockType(const TessPageIterator* handle);
TESS_API struct Pix*
TESS_CALL TessPageIteratorGetBinaryImage(const TessPageIterator* handle, TessPageIteratorLevel level);
TESS_API struct Pix*
TESS_CALL TessPageIteratorGetImage(const TessPageIterator* handle, TessPageIteratorLevel level, int padding,
struct Pix* original_image, int* left, int* top);
TESS_API BOOL TESS_CALL TessPageIteratorBaseline(const TessPageIterator* handle, TessPageIteratorLevel level,
int* x1, int* y1, int* x2, int* y2);
TESS_API void TESS_CALL TessPageIteratorOrientation(TessPageIterator* handle, TessOrientation* orientation,
TessWritingDirection* writing_direction, TessTextlineOrder* textline_order,
float* deskew_angle);
TESS_API void TESS_CALL TessPageIteratorParagraphInfo(TessPageIterator* handle, TessParagraphJustification* justification,
BOOL *is_list_item, BOOL *is_crown, int *first_line_indent);
/* Result iterator */
TESS_API void TESS_CALL TessResultIteratorDelete(TessResultIterator* handle);
TESS_API TessResultIterator*
TESS_CALL TessResultIteratorCopy(const TessResultIterator* handle);
TESS_API TessPageIterator*
TESS_CALL TessResultIteratorGetPageIterator(TessResultIterator* handle);
TESS_API const TessPageIterator*
TESS_CALL TessResultIteratorGetPageIteratorConst(const TessResultIterator* handle);
TESS_API TessChoiceIterator*
TESS_CALL TessResultIteratorGetChoiceIterator(const TessResultIterator* handle);
TESS_API BOOL TESS_CALL TessResultIteratorNext(TessResultIterator* handle, TessPageIteratorLevel level);
TESS_API char* TESS_CALL TessResultIteratorGetUTF8Text(const TessResultIterator* handle, TessPageIteratorLevel level);
TESS_API float TESS_CALL TessResultIteratorConfidence(const TessResultIterator* handle, TessPageIteratorLevel level);
TESS_API const char*
TESS_CALL TessResultIteratorWordRecognitionLanguage(const TessResultIterator* handle);
TESS_API const char*
TESS_CALL TessResultIteratorWordFontAttributes(const TessResultIterator* handle, BOOL* is_bold, BOOL* is_italic,
BOOL* is_underlined, BOOL* is_monospace, BOOL* is_serif,
BOOL* is_smallcaps, int* pointsize, int* font_id);
TESS_API BOOL TESS_CALL TessResultIteratorWordIsFromDictionary(const TessResultIterator* handle);
TESS_API BOOL TESS_CALL TessResultIteratorWordIsNumeric(const TessResultIterator* handle);
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsSuperscript(const TessResultIterator* handle);
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsSubscript(const TessResultIterator* handle);
TESS_API BOOL TESS_CALL TessResultIteratorSymbolIsDropcap(const TessResultIterator* handle);
TESS_API void TESS_CALL TessChoiceIteratorDelete(TessChoiceIterator* handle);
TESS_API BOOL TESS_CALL TessChoiceIteratorNext(TessChoiceIterator* handle);
TESS_API const char* TESS_CALL TessChoiceIteratorGetUTF8Text(const TessChoiceIterator* handle);
TESS_API float TESS_CALL TessChoiceIteratorConfidence(const TessChoiceIterator* handle);
#ifdef __cplusplus
}
#endif
#endif /* TESSERACT_API_CAPI_H__ */

View File

@@ -0,0 +1,114 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_CCBORD_H
#define LEPTONICA_CCBORD_H
/*
* ccbord.h
*
* CCBord: represents a single connected component
* CCBorda: an array of CCBord
*/
/* Use in ccbaStepChainsToPixCoords() */
enum {
CCB_LOCAL_COORDS = 1,
CCB_GLOBAL_COORDS = 2
};
/* Use in ccbaGenerateSPGlobalLocs() */
enum {
CCB_SAVE_ALL_PTS = 1,
CCB_SAVE_TURNING_PTS = 2
};
/* CCBord contains:
*
* (1) a minimally-clipped bitmap of the component (pix),
* (2) a boxa consisting of:
* for the primary component:
* (xul, yul) pixel location in global coords
* (w, h) of the bitmap
* for the hole components:
* (x, y) in relative coordinates in primary component
* (w, h) of the hole border (which is 2 pixels
* larger in each direction than the hole itself)
* (3) a pta ('start') of the initial border pixel location for each
* closed curve, all in relative coordinates of the primary
* component. This is given for the primary component,
* followed by the hole components, if any.
* (4) a refcount of the ccbord; used internally when a ccbord
* is accessed from a ccborda (array of ccbord)
* (5) a ptaa for the chain code for the border in relative
* coordinates, where the first pta is the exterior border
* and all other pta are for interior borders (holes)
* (6) a ptaa for the global pixel loc rendition of the border,
* where the first pta is the exterior border and all other
* pta are for interior borders (holes).
* This is derived from the local or step chain code.
* (7) a numaa for the chain code for the border as orientation
* directions between successive border pixels, where
* the first numa is the exterior border and all other
* numa are for interior borders (holes). This is derived
* from the local chain code. The 8 directions are 0 - 7.
* (8) a pta for a single chain for each c.c., comprised of outer
* and hole borders, plus cut paths between them, all in
* local coords.
* (9) a pta for a single chain for each c.c., comprised of outer
* and hole borders, plus cut paths between them, all in
* global coords.
*/
struct CCBord
{
struct Pix *pix; /* component bitmap (min size) */
struct Boxa *boxa; /* regions of each closed curve */
struct Pta *start; /* initial border pixel locations */
l_int32 refcount; /* number of handles; start at 1 */
struct Ptaa *local; /* ptaa of chain pixels (local) */
struct Ptaa *global; /* ptaa of chain pixels (global) */
struct Numaa *step; /* numaa of chain code (step dir) */
struct Pta *splocal; /* pta of single chain (local) */
struct Pta *spglobal; /* pta of single chain (global) */
};
typedef struct CCBord CCBORD;
struct CCBorda
{
struct Pix *pix; /* input pix (may be null) */
l_int32 w; /* width of pix */
l_int32 h; /* height of pix */
l_int32 n; /* number of ccbord in ptr array */
l_int32 nalloc; /* number of ccbord ptrs allocated */
struct CCBord **ccb; /* ccb ptr array */
};
typedef struct CCBorda CCBORDA;
#endif /* LEPTONICA_CCBORD_H */

View File

@@ -0,0 +1,165 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_DEWARP_H
#define LEPTONICA_DEWARP_H
/*
* dewarp.h
*
* Data structure to hold arrays and results for generating
* horizontal and vertical disparity arrays based on textlines.
* Each disparity array is two-dimensional. The vertical disparity
* array gives a vertical displacement, relative to the lowest point
* in the textlines. The horizontal disparty array gives a horizontal
* displacement, relative to the minimum values (for even pages)
* or maximum values (for odd pages) of the left and right ends of
* full textlines. Horizontal alignment always involves translations
* away from the book gutter.
*
* We have intentionally separated the process of building models
* from the rendering process that uses the models. For any page,
* the building operation either creates an actual model (that is,
* a model with at least the vertical disparity being computed, and
* for which the 'success' flag is set) or fails to create a model.
* However, at rendering time, a page can have one of two different
* types of models.
* (1) A valid model is an actual model that meets the rendering
* constraints, which are limits on model curvature parameters.
* See dewarpaTestForValidModel() for details.
* Valid models are identified by dewarpaInsertRefModels(),
* which sets the 'vvalid' and 'hvalid' fields. Only valid
* models are used for rendering.
* (2) A reference model is used by a page that doesn't have
* a valid model, but has a nearby valid model of the same
* parity (even/odd page) that it can use. The range in pages
* to search for a valid model is given by the 'maxdist' field.
*
* If a valid vertical disparity model (VDM) is not available,
* just use the input image. Otherwise, assuming the VDM is available:
* (a) with useboth == 0, we use only the VDM.
* (b) with useboth == 1, we require using the VDM and, if a valid
* horizontal disparity model (HDM) is available, we also use it.
*
* The 'maxdist' parameter is input when the dewarpa is created.
* The other rendering parameters have default values given in dewarp.c.
* All parameters used by rendering can be set (or reset) using accessors.
*
* After dewarping, use of the VDM will cause all points on each
* altered curve to have a y-value equal to the minimum. Use of
* the HDA will cause the left and right edges of the textlines
* to be vertically aligned if they had been typeset flush-left
* and flush-right, respectively.
*
* The sampled disparity arrays are expanded to full resolution,
* using linear interpolation, and this is further expanded
* by slope continuation to the right and below if the image
* is larger than the full resolution disparity arrays. Then
* the disparity correction can be applied to the input image.
* If the input pix are 2x reduced, the expansion from sampled
* to full res uses the product of (sampling) * (redfactor).
*
* The most accurate results are produced at full resolution, and
* this is generally recommended.
*/
/* Note on versioning of the serialization of this data structure:
* The dewarping utility and the stored data can be expected to change.
* In most situations, the serialized version is ephemeral -- it is
* not needed after being used. No functions will be provided to
* convert between different versions. */
#define DEWARP_VERSION_NUMBER 4
struct L_Dewarpa
{
l_int32 nalloc; /* size of dewarp ptr array */
l_int32 maxpage; /* maximum page number in array */
struct L_Dewarp **dewarp; /* array of ptrs to page dewarp */
struct L_Dewarp **dewarpcache; /* array of ptrs to cached dewarps */
struct Numa *namodels; /* list of page numbers for pages */
/* with page models */
struct Numa *napages; /* list of page numbers with either */
/* page models or ref page models */
l_int32 redfactor; /* reduction factor of input: 1 or 2 */
l_int32 sampling; /* disparity arrays sampling factor */
l_int32 minlines; /* min number of long lines required */
l_int32 maxdist; /* max distance for getting ref pages */
l_int32 max_linecurv; /* maximum abs line curvature, */
/* in micro-units */
l_int32 min_diff_linecurv; /* minimum abs diff line curvature */
/* in micro-units */
l_int32 max_diff_linecurv; /* maximum abs diff line curvature */
/* in micro-units */
l_int32 max_edgeslope; /* maximum abs left or right edge */
/* slope, in milli-units */
l_int32 max_edgecurv; /* maximum abs left or right edge */
/* curvature, in micro-units */
l_int32 max_diff_edgecurv; /* maximum abs diff left-right */
/* edge curvature, in micro-units */
l_int32 useboth; /* use both disparity arrays if */
/* available; just vertical otherwise */
l_int32 modelsready; /* invalid models have been removed */
/* and refs built against valid set */
};
typedef struct L_Dewarpa L_DEWARPA;
struct L_Dewarp
{
struct L_Dewarpa *dewa; /* ptr to parent (not owned) */
struct Pix *pixs; /* source pix, 1 bpp */
struct FPix *sampvdispar; /* sampled vert disparity array */
struct FPix *samphdispar; /* sampled horiz disparity array */
struct FPix *fullvdispar; /* full vert disparity array */
struct FPix *fullhdispar; /* full horiz disparity array */
struct Numa *namidys; /* sorted y val of midpoint each line */
struct Numa *nacurves; /* sorted curvature of each line */
l_int32 w; /* width of source image */
l_int32 h; /* height of source image */
l_int32 pageno; /* page number; important for reuse */
l_int32 sampling; /* sampling factor of disparity arrays */
l_int32 redfactor; /* reduction factor of pixs: 1 or 2 */
l_int32 minlines; /* min number of long lines required */
l_int32 nlines; /* number of long lines found */
l_int32 mincurv; /* min line curvature in micro-units */
l_int32 maxcurv; /* max line curvature in micro-units */
l_int32 leftslope; /* left edge slope in milli-units */
l_int32 rightslope; /* right edge slope in milli-units */
l_int32 leftcurv; /* left edge curvature in micro-units */
l_int32 rightcurv; /* right edge curvature in micro-units */
l_int32 nx; /* number of sampling pts in x-dir */
l_int32 ny; /* number of sampling pts in y-dir */
l_int32 hasref; /* 0 if normal; 1 if has a refpage */
l_int32 refpage; /* page with disparity model to use */
l_int32 vsuccess; /* sets to 1 if vert disparity builds */
l_int32 hsuccess; /* sets to 1 if horiz disparity builds */
l_int32 vvalid; /* sets to 1 if valid vert disparity */
l_int32 hvalid; /* sets to 1 if valid horiz disparity */
l_int32 debug; /* sets to 1 if debug output requested */
};
typedef struct L_Dewarp L_DEWARP;
#endif /* LEPTONICA_DEWARP_H */

View File

@@ -0,0 +1,11 @@
#if !defined (L_BIG_ENDIAN) && !defined (L_LITTLE_ENDIAN)
# if 0
# ifdef __BIG_ENDIAN__
# define L_BIG_ENDIAN
# else
# define L_LITTLE_ENDIAN
# endif
# else
# define L_LITTLE_ENDIAN
# endif
#endif

View File

@@ -0,0 +1,495 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_ENVIRON_H
#define LEPTONICA_ENVIRON_H
/*------------------------------------------------------------------------*
* Defines and includes differ for Unix and Windows. Also for Windows, *
* differentiate between conditionals based on platform and compiler. *
* For platforms: *
* _WIN32 => Windows, 32- or 64-bit *
* _WIN64 => Windows, 64-bit only *
* __CYGWIN__ => Cygwin *
* For compilers: *
* __GNUC__ => gcc *
* _MSC_VER => msvc *
*------------------------------------------------------------------------*/
/* MS VC++ does not provide stdint.h, so define the missing types here */
#ifndef _MSC_VER
#include <stdint.h>
#else
/* Note that _WIN32 is defined for both 32 and 64 bit applications,
whereas _WIN64 is defined only for the latter */
#ifdef _WIN64
typedef __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else
typedef int intptr_t;
typedef unsigned int uintptr_t;
#endif
/* VC++6 doesn't seem to have powf, expf. */
#if (_MSC_VER < 1400)
#define powf(x, y) (float)pow((double)(x), (double)(y))
#define expf(x) (float)exp((double)(x))
#endif
#endif /* _MSC_VER */
/* Windows specifics */
#ifdef _WIN32
/* DLL EXPORTS and IMPORTS */
#if defined(LIBLEPT_EXPORTS)
#define LEPT_DLL __declspec(dllexport)
#elif defined(LIBLEPT_IMPORTS)
#define LEPT_DLL __declspec(dllimport)
#else
#define LEPT_DLL
#endif
#else /* non-Windows specifics */
#include <stdint.h>
#define LEPT_DLL
#endif /* _WIN32 */
typedef intptr_t l_intptr_t;
typedef uintptr_t l_uintptr_t;
/*--------------------------------------------------------------------*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
* USER CONFIGURABLE *
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
* Environment variables with I/O libraries *
* Manual Configuration Only: NOT AUTO_CONF *
*--------------------------------------------------------------------*/
/*
* Leptonica provides interfaces to link to several external image
* I/O libraries, plus zlib. Setting any of these to 0 here causes
* non-functioning stubs to be linked.
*/
#if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD)
#define HAVE_LIBJPEG 0
#define HAVE_LIBTIFF 0
#define HAVE_LIBPNG 0
#define HAVE_LIBZ 0
#define HAVE_LIBGIF 0
#define HAVE_LIBUNGIF 0
#define HAVE_LIBWEBP 0
#define HAVE_LIBJP2K 0
/* Leptonica supports both OpenJPEG 2.0 and 2.1. If you have a
* version of openjpeg (HAVE_LIBJP2K) that is not 2.1, set the
* path to the openjpeg.h header in angle brackets here. */
#define LIBJP2K_HEADER <openjpeg-2.1/openjpeg.h>
#endif /* ! HAVE_CONFIG_H etc. */
/*
* On linux systems, you can do I/O between Pix and memory. Specifically,
* you can compress (write compressed data to memory from a Pix) and
* uncompress (read from compressed data in memory to a Pix).
* For jpeg, png, jp2k, gif, pnm and bmp, these use the non-posix GNU
* functions fmemopen() and open_memstream(). These functions are not
* available on other systems.
* To use these functions in linux, you must define HAVE_FMEMOPEN to 1.
* To use them on MacOS, which does not support these functions, set it to 0.
*/
#if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(_MSC_VER)
#define HAVE_FMEMOPEN 1
#endif /* ! HAVE_CONFIG_H etc. */
/*--------------------------------------------------------------------*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
* USER CONFIGURABLE *
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
* Environ variables for image I/O without external libraries *
*--------------------------------------------------------------------*/
/*
* Leptonica supplies I/O support without using external libraries for:
* * image read/write for bmp, pnm
* * header read for jp2k
* * image wrapping write for pdf and ps.
* Setting any of these to 0 causes non-functioning stubs to be linked.
*/
#define USE_BMPIO 0
#define USE_PNMIO 0
#define USE_JP2KHEADER 0
#define USE_PDFIO 0
#define USE_PSIO 0
/*--------------------------------------------------------------------*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
* USER CONFIGURABLE *
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
* Optional subdirectory translation for read/write to /tmp *
*--------------------------------------------------------------------*/
/*
* It is desirable on Windows to have all temp files written to the same
* subdirectory of the Windows <Temp> directory, because files under <Temp>
* persist after reboot, and the regression tests write a lot of files.
* Consequently, all temp files on Windows are written to <Temp>/leptonica/
* or subdirectories of it, with the translation:
* /tmp/xxx --> <Temp>/leptonica/xxx
*
* This is not the case for Unix, but we provide an option for reading
* and writing on Unix with this translation:
* /tmp/xxx --> /tmp/leptonica/xxx
* By default, leptonica is distributed for Unix without this translation
* (except on Cygwin, which runs on Windows).
*/
#if defined (__CYGWIN__)
#define ADD_LEPTONICA_SUBDIR 1
#else
#define ADD_LEPTONICA_SUBDIR 0
#endif
/*--------------------------------------------------------------------*
* Built-in types *
*--------------------------------------------------------------------*/
typedef signed char l_int8;
typedef unsigned char l_uint8;
typedef short l_int16;
typedef unsigned short l_uint16;
typedef int l_int32;
typedef unsigned int l_uint32;
typedef float l_float32;
typedef double l_float64;
#ifdef COMPILER_MSVC
typedef __int64 l_int64;
typedef unsigned __int64 l_uint64;
#else
typedef long long l_int64;
typedef unsigned long long l_uint64;
#endif /* COMPILER_MSVC */
/*------------------------------------------------------------------------*
* Standard macros *
*------------------------------------------------------------------------*/
#ifndef L_MIN
#define L_MIN(x,y) (((x) < (y)) ? (x) : (y))
#endif
#ifndef L_MAX
#define L_MAX(x,y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef L_ABS
#define L_ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
#endif
#ifndef L_SIGN
#define L_SIGN(x) (((x) < 0) ? -1 : 1)
#endif
#ifndef UNDEF
#define UNDEF -1
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/*--------------------------------------------------------------------*
* Environment variables for endian dependence *
*--------------------------------------------------------------------*/
/*
* To control conditional compilation, one of two variables
*
* L_LITTLE_ENDIAN (e.g., for Intel X86)
* L_BIG_ENDIAN (e.g., for Sun SPARC, Mac Power PC)
*
* is defined when the GCC compiler is invoked.
* All code should compile properly for both hardware architectures.
*/
/*------------------------------------------------------------------------*
* Simple search state variables *
*------------------------------------------------------------------------*/
enum {
L_NOT_FOUND = 0,
L_FOUND = 1
};
/*------------------------------------------------------------------------*
* Path separator conversion *
*------------------------------------------------------------------------*/
enum {
UNIX_PATH_SEPCHAR = 0,
WIN_PATH_SEPCHAR = 1
};
/*------------------------------------------------------------------------*
* Timing structs *
*------------------------------------------------------------------------*/
typedef void *L_TIMER;
struct L_WallTimer {
l_int32 start_sec;
l_int32 start_usec;
l_int32 stop_sec;
l_int32 stop_usec;
};
typedef struct L_WallTimer L_WALLTIMER;
/*------------------------------------------------------------------------*
* Standard memory allocation *
* *
* These specify the memory management functions that are used *
* on all heap data except for Pix. Memory management for Pix *
* also defaults to malloc and free. See pix1.c for details. *
*------------------------------------------------------------------------*/
#define MALLOC(blocksize) malloc(blocksize)
#define CALLOC(numelem, elemsize) calloc(numelem, elemsize)
#define REALLOC(ptr, blocksize) realloc(ptr, blocksize)
#define FREE(ptr) free(ptr)
/*------------------------------------------------------------------------*
* Control printing of error, warning, and info messages *
* *
* To omit all messages to stderr, simply define NO_CONSOLE_IO on the *
* command line. For finer grained control, we have a mechanism *
* based on the message severity level. The following assumes that *
* NO_CONSOLE_IO is not defined. *
* *
* Messages are printed if the message severity is greater than or equal *
* to the current severity threshold. The current severity threshold *
* is the greater of the compile-time severity, which is the minimum *
* severity that can be reported, and the run-time severity, which is *
* the severity threshold at the moment. *
* *
* The compile-time threshold determines which messages are compiled *
* into the library for potential printing. Messages below the *
* compile-time threshold are omitted and can never be printed. The *
* default compile-time threshold is L_SEVERITY_INFO, but this may be *
* overridden by defining MINIMUM_SEVERITY to the desired enumeration *
* identifier on the compiler command line. Defining NO_CONSOLE_IO on *
* the command line is the same as setting MINIMUM_SEVERITY to *
* L_SEVERITY_NONE. *
* *
* The run-time threshold determines which messages are printed during *
* library execution. It defaults to the compile-time threshold but *
* may be changed either statically by defining DEFAULT_SEVERITY to *
* the desired enumeration identifier on the compiler command line, or *
* dynamically by calling setMsgSeverity() to specify a new threshold. *
* The run-time threshold may also be set from the value of the *
* environment variable LEPT_MSG_SEVERITY by calling setMsgSeverity() *
* and specifying L_SEVERITY_EXTERNAL. *
* *
* In effect, the compile-time threshold setting says, "Generate code *
* to permit messages of equal or greater severity than this to be *
* printed, if desired," whereas the run-time threshold setting says, *
* "Print messages that have an equal or greater severity than this." *
*------------------------------------------------------------------------*/
enum {
L_SEVERITY_EXTERNAL = 0, /* Get the severity from the environment */
L_SEVERITY_ALL = 1, /* Lowest severity: print all messages */
L_SEVERITY_DEBUG = 2, /* Print debugging and higher messages */
L_SEVERITY_INFO = 3, /* Print informational and higher messages */
L_SEVERITY_WARNING = 4, /* Print warning and higher messages */
L_SEVERITY_ERROR = 5, /* Print error and higher messages */
L_SEVERITY_NONE = 6 /* Highest severity: print no messages */
};
/* No message less than the compile-time threshold will ever be
* reported, regardless of the current run-time threshold. This allows
* selection of the set of messages to include in the library. For
* example, setting the threshold to L_SEVERITY_WARNING eliminates all
* informational messages from the library. With that setting, both
* warning and error messages would be printed unless setMsgSeverity()
* was called, or DEFAULT_SEVERITY was redefined, to set the run-time
* severity to L_SEVERITY_ERROR. In that case, only error messages
* would be printed.
*
* This mechanism makes the library smaller and faster, by eliminating
* undesired message reporting and the associated run-time overhead for
* message threshold checking, because code for messages whose severity
* is lower than MINIMUM_SEVERITY won't be generated.
*
* A production library might typically permit WARNING and higher
* messages to be generated, and a development library might permit
* DEBUG and higher. The actual messages printed (as opposed to
* generated) would depend on the current run-time severity threshold.
*/
#ifdef NO_CONSOLE_IO
#undef MINIMUM_SEVERITY
#undef DEFAULT_SEVERITY
#define MINIMUM_SEVERITY L_SEVERITY_NONE
#define DEFAULT_SEVERITY L_SEVERITY_NONE
#else
#ifndef MINIMUM_SEVERITY
#define MINIMUM_SEVERITY L_SEVERITY_INFO /* Compile-time default */
#endif
#ifndef DEFAULT_SEVERITY
#define DEFAULT_SEVERITY MINIMUM_SEVERITY /* Run-time default */
#endif
#endif
/* The run-time message severity threshold is defined in utils.c. */
LEPT_DLL extern l_int32 LeptMsgSeverity;
/*
* Usage
* =====
* Messages are of two types.
*
* (1) The messages
* ERROR_INT(a,b,c) : returns l_int32
* ERROR_FLOAT(a,b,c) : returns l_float32
* ERROR_PTR(a,b,c) : returns void*
* are used to return from functions and take a fixed set of parameters:
* a : <message string>
* b : procName
* c : <return value from function>
* where procName is the name of the local variable naming the function.
*
* (2) The purely informational L_* messages
* L_ERROR(a,...)
* L_WARNING(a,...)
* L_INFO(a,...)
* do not take a return value, but they take at least two parameters:
* a : <message string> with optional format conversions
* v1 : procName (this must be included as the first vararg)
* v2, ... : optional varargs to match format converters in the message
*
* To return an error from a function that returns void, use:
* L_ERROR(<message string>, procName, [...])
* return;
*
* Implementation details
* ======================
* Messages are defined with the IF_SEV macro. The first parameter is
* the message severity, the second is the function to call if the
* message is to be printed, and the third is the return value if the
* message is to be suppressed. For example, we might have an
* informational message defined as:
*
* IF_SEV(L_SEVERITY_INFO, fprintf(.......), 0)
*
* The macro expands into a conditional. Because the first comparison
* is between two constants, an optimizing compiler will remove either
* the comparison (if it's true) or the entire macro expansion (if it
* is false). This means that there is no run-time overhead for
* messages whose severity falls below the minimum specified at compile
* time, and for others the overhead is one (not two) comparisons.
*
* The L_nnn() macros below do not return a value, but because the
* conditional operator requires one for the false condition, we
* specify a void expression.
*/
#ifdef NO_CONSOLE_IO
#define PROCNAME(name)
#define ERROR_INT(a,b,c) ((l_int32)(c))
#define ERROR_FLOAT(a,b,c) ((l_float32)(c))
#define ERROR_PTR(a,b,c) ((void *)(c))
#define L_ERROR(a,...)
#define L_WARNING(a,...)
#define L_INFO(a,...)
#else
#define PROCNAME(name) static const char procName[] = name
#define IF_SEV(l,t,f) \
((l) >= MINIMUM_SEVERITY && (l) >= LeptMsgSeverity ? (t) : (f))
#define ERROR_INT(a,b,c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorInt((a),(b),(c)), (l_int32)(c))
#define ERROR_FLOAT(a,b,c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorFloat((a),(b),(c)), (l_float32)(c))
#define ERROR_PTR(a,b,c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorPtr((a),(b),(c)), (void *)(c))
#define L_ERROR(a,...) \
IF_SEV(L_SEVERITY_ERROR, \
(void)fprintf(stderr, "Error in %s: " a, __VA_ARGS__), \
(void)0)
#define L_WARNING(a,...) \
IF_SEV(L_SEVERITY_WARNING, \
(void)fprintf(stderr, "Warning in %s: " a, __VA_ARGS__), \
(void)0)
#define L_INFO(a,...) \
IF_SEV(L_SEVERITY_INFO, \
(void)fprintf(stderr, "Info in %s: " a, __VA_ARGS__), \
(void)0)
#if 0 /* Alternative method for controlling L_* message output */
#define L_ERROR(a,...) \
{ if (L_SEVERITY_ERROR >= MINIMUM_SEVERITY && \
L_SEVERITY_ERROR >= LeptMsgSeverity) \
fprintf(stderr, "Error in %s: " a, __VA_ARGS__) \
}
#define L_WARNING(a,...) \
{ if (L_SEVERITY_WARNING >= MINIMUM_SEVERITY && \
L_SEVERITY_WARNING >= LeptMsgSeverity) \
fprintf(stderr, "Warning in %s: " a, __VA_ARGS__) \
}
#define L_INFO(a,...) \
{ if (L_SEVERITY_INFO >= MINIMUM_SEVERITY && \
L_SEVERITY_INFO >= LeptMsgSeverity) \
fprintf(stderr, "Info in %s: " a, __VA_ARGS__) \
}
#endif
#endif /* NO_CONSOLE_IO */
/*------------------------------------------------------------------------*
* snprintf() renamed in MSVC *
*------------------------------------------------------------------------*/
#ifdef _MSC_VER
#define snprintf(buf, size, ...) _snprintf_s(buf, size, _TRUNCATE, __VA_ARGS__)
#endif
#endif /* LEPTONICA_ENVIRON_H */

View File

@@ -0,0 +1,34 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_FREETYPE_H
#define LEPTONICA_FREETYPE_H
#define LEPTONICA_FT_RESOLUTION 96
typedef struct ft_library_st FT_LIBRARY;
#endif /* LEPTONICA_FREETYPE_H */

View File

@@ -0,0 +1,88 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_GPLOT_H
#define LEPTONICA_GPLOT_H
/*
* gplot.h
*
* Data structures and parameters for generating gnuplot files
*/
#define GPLOT_VERSION_NUMBER 1
#define NUM_GPLOT_STYLES 5
enum GPLOT_STYLE {
GPLOT_LINES = 0,
GPLOT_POINTS = 1,
GPLOT_IMPULSES = 2,
GPLOT_LINESPOINTS = 3,
GPLOT_DOTS = 4
};
#define NUM_GPLOT_OUTPUTS 6
enum GPLOT_OUTPUT {
GPLOT_NONE = 0,
GPLOT_PNG = 1,
GPLOT_PS = 2,
GPLOT_EPS = 3,
GPLOT_X11 = 4,
GPLOT_LATEX = 5
};
enum GPLOT_SCALING {
GPLOT_LINEAR_SCALE = 0, /* default */
GPLOT_LOG_SCALE_X = 1,
GPLOT_LOG_SCALE_Y = 2,
GPLOT_LOG_SCALE_X_Y = 3
};
extern const char *gplotstylenames[]; /* used in gnuplot cmd file */
extern const char *gplotfilestyles[]; /* used in simple file input */
extern const char *gplotfileoutputs[]; /* used in simple file input */
struct GPlot
{
char *rootname; /* for cmd, data, output */
char *cmdname; /* command file name */
struct Sarray *cmddata; /* command file contents */
struct Sarray *datanames; /* data file names */
struct Sarray *plotdata; /* plot data (1 string/file) */
struct Sarray *plottitles; /* title for each individual plot */
struct Numa *plotstyles; /* plot style for individual plots */
l_int32 nplots; /* current number of plots */
char *outname; /* output file name */
l_int32 outformat; /* GPLOT_OUTPUT values */
l_int32 scaling; /* GPLOT_SCALING values */
char *title; /* optional */
char *xlabel; /* optional x axis label */
char *ylabel; /* optional y axis label */
};
typedef struct GPlot GPLOT;
#endif /* LEPTONICA_GPLOT_H */

View File

@@ -0,0 +1,84 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_HEAP_H
#define LEPTONICA_HEAP_H
/*
* heap.h
*
* Expandable priority queue configured as a heap for arbitrary void* data
*
* The L_Heap is used to implement a priority queue. The elements
* in the heap are ordered in either increasing or decreasing key value.
* The key is a float field 'keyval' that is required to be
* contained in the elements of the queue.
*
* The heap is a simple binary tree with the following constraints:
* - the key of each node is >= the keys of the two children
* - the tree is complete, meaning that each level (1, 2, 4, ...)
* is filled and the last level is filled from left to right
*
* The tree structure is implicit in the queue array, with the
* array elements numbered as a breadth-first search of the tree
* from left to right. It is thus guaranteed that the largest
* (or smallest) key belongs to the first element in the array.
*
* Heap sort is used to sort the array. Once an array has been
* sorted as a heap, it is convenient to use it as a priority queue,
* because the min (or max) elements are always at the root of
* the tree (element 0), and once removed, the heap can be
* resorted in not more than log[n] steps, where n is the number
* of elements on the heap. Likewise, if an arbitrary element is
* added to the end of the array A, the sorted heap can be restored
* in not more than log[n] steps.
*
* A L_Heap differs from a L_Queue in that the elements in the former
* are sorted by a key. Internally, the array is maintained
* as a queue, with a pointer to the end of the array. The
* head of the array always remains at array[0]. The array is
* maintained (sorted) as a heap. When an item is removed from
* the head, the last item takes its place (thus reducing the
* array length by 1), and this is followed by array element
* swaps to restore the heap property. When an item is added,
* it goes at the end of the array, and is swapped up to restore
* the heap. If the ptr array is full, adding another item causes
* the ptr array size to double.
*
* For further implementation details, see heap.c.
*/
struct L_Heap
{
l_int32 nalloc; /* size of allocated ptr array */
l_int32 n; /* number of elements stored in the heap */
void **array; /* ptr array */
l_int32 direction; /* L_SORT_INCREASING or L_SORT_DECREASING */
};
typedef struct L_Heap L_HEAP;
#endif /* LEPTONICA_HEAP_H */

View File

@@ -0,0 +1,205 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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.
*====================================================================*/
/*
* General features of image I/O in leptonica
*
* At present, there are 9 file formats for images that can be read
* and written:
* png (requires libpng, libz)
* jpeg (requires libjpeg)
* tiff (requires libtiff, libz)
* gif (requires libgif)
* webp (requires libwebp)
* jp2 (requires libopenjp2)
* bmp (no library required)
* pnm (no library required)
* spix (no library required)
* Additionally, there are two file formats for writing (only) images:
* PostScript (requires libpng, libz, libjpeg, libtiff)
* pdf (requires libpng, libz, libjpeg, libtiff)
*
* For all 9 read/write formats, leptonica provides interconversion
* between pix (with raster data) and formatted image data:
* Conversion from pix (typically compression):
* pixWrite(): pix --> file
* pixWriteStream(): pix --> filestream (aka FILE*)
* pixWriteMem(): pix --> memory buffer
* Conversion to pix (typically decompression):
* pixRead(): file --> pix
* pixReadStream(): filestream --> pix
* pixReadMem(): memory buffer --> pix
*
* Conversions for which the image data is not compressed are:
* * uncompressed tiff (IFF_TIFF)
* * bmp
* * pnm
* * spix (fast serialization that copies the pix raster data)
*
* The image header (metadata) information can be read from either
* the compressed file or a memory buffer, for all 9 formats.
*/
#ifndef LEPTONICA_IMAGEIO_H
#define LEPTONICA_IMAGEIO_H
/* ------------------ Image file format types -------------- */
/*
* The IFF_DEFAULT flag is used to write the file out in the
* same (input) file format that the pix was read from. If the pix
* was not read from file, the input format field will be
* IFF_UNKNOWN and the output file format will be chosen to
* be compressed and lossless; namely, IFF_TIFF_G4 for d = 1
* and IFF_PNG for everything else. IFF_JP2 is for jpeg2000, which
* is not supported in leptonica.
*
* In the future, new format types that have defined extensions
* will be added before IFF_DEFAULT, and will be kept in sync with
* the file format extensions in writefile.c. The positions of
* file formats before IFF_DEFAULT will remain invariant.
*/
enum {
IFF_UNKNOWN = 0,
IFF_BMP = 1,
IFF_JFIF_JPEG = 2,
IFF_PNG = 3,
IFF_TIFF = 4,
IFF_TIFF_PACKBITS = 5,
IFF_TIFF_RLE = 6,
IFF_TIFF_G3 = 7,
IFF_TIFF_G4 = 8,
IFF_TIFF_LZW = 9,
IFF_TIFF_ZIP = 10,
IFF_PNM = 11,
IFF_PS = 12,
IFF_GIF = 13,
IFF_JP2 = 14,
IFF_WEBP = 15,
IFF_LPDF = 16,
IFF_DEFAULT = 17,
IFF_SPIX = 18
};
/* ---------------------- Format header ids --------------------- */
enum {
BMP_ID = 0x4d42,
TIFF_BIGEND_ID = 0x4d4d, /* MM - for 'motorola' */
TIFF_LITTLEEND_ID = 0x4949 /* II - for 'intel' */
};
/* ------------- Hinting bit flags in jpeg reader --------------- */
enum {
L_JPEG_READ_LUMINANCE = 1, /* only want luminance data; no chroma */
L_JPEG_FAIL_ON_BAD_DATA = 2 /* don't return possibly damaged pix */
};
/* ------------------ Pdf formated encoding types --------------- */
enum {
L_JPEG_ENCODE = 1, /* use dct encoding: 8 and 32 bpp, no cmap */
L_G4_ENCODE = 2, /* use ccitt g4 fax encoding: 1 bpp */
L_FLATE_ENCODE = 3, /* use flate encoding: any depth, cmap ok */
L_JP2K_ENCODE = 4 /* use jp2k encoding: 8 and 32 bpp, no cmap */
};
/* ------------------ Compressed image data --------------------- */
/*
* In use, either datacomp or data85 will be produced, depending
* on whether the data needs to be ascii85 encoded. PostScript
* requires ascii85 encoding; pdf does not.
*
* For the colormap (flate compression only), PostScript uses ascii85
* encoding and pdf uses a bracketed array of space-separated
* hex-encoded rgb triples. Only tiff g4 (type == L_G4_ENCODE) uses
* the minisblack field.
*/
struct L_Compressed_Data
{
l_int32 type; /* encoding type: L_JPEG_ENCODE, etc */
l_uint8 *datacomp; /* gzipped raster data */
size_t nbytescomp; /* number of compressed bytes */
char *data85; /* ascii85-encoded gzipped raster data */
size_t nbytes85; /* number of ascii85 encoded bytes */
char *cmapdata85; /* ascii85-encoded uncompressed cmap */
char *cmapdatahex; /* hex pdf array for the cmap */
l_int32 ncolors; /* number of colors in cmap */
l_int32 w; /* image width */
l_int32 h; /* image height */
l_int32 bps; /* bits/sample; typ. 1, 2, 4 or 8 */
l_int32 spp; /* samples/pixel; typ. 1 or 3 */
l_int32 minisblack; /* tiff g4 photometry */
l_int32 predictor; /* flate data has PNG predictors */
size_t nbytes; /* number of uncompressed raster bytes */
l_int32 res; /* resolution (ppi) */
};
typedef struct L_Compressed_Data L_COMP_DATA;
/* ------------------------ Pdf multi-image flags ------------------------ */
enum {
L_FIRST_IMAGE = 1, /* first image to be used */
L_NEXT_IMAGE = 2, /* intermediate image; not first or last */
L_LAST_IMAGE = 3 /* last image to be used */
};
/* ------------------ Intermediate pdf generation data -------------------- */
/*
* This accumulates data for generating a pdf of a single page consisting
* of an arbitrary number of images.
*
* None of the strings have a trailing newline.
*/
struct L_Pdf_Data
{
char *title; /* optional title for pdf */
l_int32 n; /* number of images */
l_int32 ncmap; /* number of colormaps */
struct L_Ptra *cida; /* array of compressed image data */
char *id; /* %PDF-1.2 id string */
char *obj1; /* catalog string */
char *obj2; /* metadata string */
char *obj3; /* pages string */
char *obj4; /* page string (variable data) */
char *obj5; /* content string (variable data) */
char *poststream; /* post-binary-stream string */
char *trailer; /* trailer string (variable data) */
struct Pta *xy; /* store (xpt, ypt) array */
struct Pta *wh; /* store (wpt, hpt) array */
struct Box *mediabox; /* bounding region for all images */
struct Sarray *saprex; /* pre-binary-stream xobject strings */
struct Sarray *sacmap; /* colormap pdf object strings */
struct L_Dna *objsize; /* sizes of each pdf string object */
struct L_Dna *objloc; /* location of each pdf string object */
l_int32 xrefloc; /* location of xref */
};
typedef struct L_Pdf_Data L_PDF_DATA;
#endif /* LEPTONICA_IMAGEIO_H */

View File

@@ -0,0 +1,133 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_JBCLASS_H
#define LEPTONICA_JBCLASS_H
/*
* jbclass.h
*
* JbClasser
* JbData
*/
/* The JbClasser struct holds all the data accumulated during the
* classification process that can be used for a compressed
* jbig2-type representation of a set of images. This is created
* in an initialization process and added to as the selected components
* on each successive page are analyzed. */
struct JbClasser
{
struct Sarray *safiles; /* input page image file names */
l_int32 method; /* JB_RANKHAUS, JB_CORRELATION */
l_int32 components; /* JB_CONN_COMPS, JB_CHARACTERS or */
/* JB_WORDS */
l_int32 maxwidth; /* max component width allowed */
l_int32 maxheight; /* max component height allowed */
l_int32 npages; /* number of pages already processed */
l_int32 baseindex; /* number of components already processed */
/* on fully processed pages */
struct Numa *nacomps; /* number of components on each page */
l_int32 sizehaus; /* size of square struct element for haus */
l_float32 rankhaus; /* rank val of haus match, each way */
l_float32 thresh; /* thresh value for correlation score */
l_float32 weightfactor; /* corrects thresh value for heaver */
/* components; use 0 for no correction */
struct Numa *naarea; /* w * h of each template, without extra */
/* border pixels */
l_int32 w; /* max width of original src images */
l_int32 h; /* max height of original src images */
l_int32 nclass; /* current number of classes */
l_int32 keep_pixaa; /* If zero, pixaa isn't filled */
struct Pixaa *pixaa; /* instances for each class; unbordered */
struct Pixa *pixat; /* templates for each class; bordered */
/* and not dilated */
struct Pixa *pixatd; /* templates for each class; bordered */
/* and dilated */
struct NumaHash *nahash; /* Hash table to find templates by size */
struct Numa *nafgt; /* fg areas of undilated templates; */
/* only used for rank < 1.0 */
struct Pta *ptac; /* centroids of all bordered cc */
struct Pta *ptact; /* centroids of all bordered template cc */
struct Numa *naclass; /* array of class ids for each component */
struct Numa *napage; /* array of page nums for each component */
struct Pta *ptaul; /* array of UL corners at which the */
/* template is to be placed for each */
/* component */
struct Pta *ptall; /* similar to ptaul, but for LL corners */
};
typedef struct JbClasser JBCLASSER;
/* The JbData struct holds all the data required for
* the compressed jbig-type representation of a set of images.
* The data can be written to file, read back, and used
* to regenerate an approximate version of the original,
* which differs in two ways from the original:
* (1) It uses a template image for each c.c. instead of the
* original instance, for each occurrence on each page.
* (2) It discards components with either a height or width larger
* than the maximuma, given here by the lattice dimensions
* used for storing the templates. */
struct JbData
{
struct Pix *pix; /* template composite for all classes */
l_int32 npages; /* number of pages */
l_int32 w; /* max width of original page images */
l_int32 h; /* max height of original page images */
l_int32 nclass; /* number of classes */
l_int32 latticew; /* lattice width for template composite */
l_int32 latticeh; /* lattice height for template composite */
struct Numa *naclass; /* array of class ids for each component */
struct Numa *napage; /* array of page nums for each component */
struct Pta *ptaul; /* array of UL corners at which the */
/* template is to be placed for each */
/* component */
};
typedef struct JbData JBDATA;
/* Classifier methods */
enum {
JB_RANKHAUS = 0,
JB_CORRELATION = 1
};
/* For jbGetComponents(): type of component to extract from images */
enum {
JB_CONN_COMPS = 0,
JB_CHARACTERS = 1,
JB_WORDS = 2
};
/* These parameters are used for naming the two files
* in which the jbig2-like compressed data is stored. */
#define JB_TEMPLATE_EXT ".templates.png"
#define JB_DATA_EXT ".data"
#endif /* LEPTONICA_JBCLASS_H */

View File

@@ -0,0 +1,45 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*====================================================================*/
#ifdef _WIN32
#ifndef LEPTONICA_LEPTWIN_H
#define LEPTONICA_LEPTWIN_H
#include "allheaders.h"
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
LEPT_DLL extern HBITMAP pixGetWindowsHBITMAP( PIX *pixs );
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LEPTONICA_LEPTWIN_H */
#endif /* _WIN32 */

View File

@@ -0,0 +1,87 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_LIST_H
#define LEPTONICA_LIST_H
/*
* list.h
*
* Cell for double-linked lists
*
* This allows composition of a list of cells with
* prev, next and data pointers. Generic data
* structures hang on the list cell data pointers.
*
* The list is not circular because that would add much
* complexity in traversing the list under general
* conditions where list cells can be added and removed.
* The only disadvantage of not having the head point to
* the last cell is that the list must be traversed to
* find its tail. However, this traversal is fast, and
* the listRemoveFromTail() function updates the tail
* so there is no searching overhead with repeated use.
*
* The list macros are used to run through a list, and their
* use is encouraged. They are invoked, e.g., as
*
* DLLIST *head, *elem;
* ...
* L_BEGIN_LIST_FORWARD(head, elem)
* <do something with elem and/or elem->data >
* L_END_LIST
*
*/
struct DoubleLinkedList
{
struct DoubleLinkedList *prev;
struct DoubleLinkedList *next;
void *data;
};
typedef struct DoubleLinkedList DLLIST;
/* Simple list traverse macros */
#define L_BEGIN_LIST_FORWARD(head, element) \
{ \
DLLIST *_leptvar_nextelem_; \
for ((element) = (head); (element); (element) = _leptvar_nextelem_) { \
_leptvar_nextelem_ = (element)->next;
#define L_BEGIN_LIST_REVERSE(tail, element) \
{ \
DLLIST *_leptvar_prevelem_; \
for ((element) = (tail); (element); (element) = _leptvar_prevelem_) { \
_leptvar_prevelem_ = (element)->prev;
#define L_END_LIST }}
#endif /* LEPTONICA_LIST_H */

View File

@@ -0,0 +1,229 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_MORPH_H
#define LEPTONICA_MORPH_H
/*
* morph.h
*
* Contains the following structs:
* struct Sel
* struct Sela
* struct Kernel
*
* Contains definitions for:
* morphological b.c. flags
* structuring element types
* runlength flags for granulometry
* direction flags for grayscale morphology
* morphological operation flags
* standard border size
* grayscale intensity scaling flags
* morphological tophat flags
* arithmetic and logical operator flags
* grayscale morphology selection flags
* distance function b.c. flags
* image comparison flags
* color content flags
*/
/*-------------------------------------------------------------------------*
* Sel and Sel array *
*-------------------------------------------------------------------------*/
#define SEL_VERSION_NUMBER 1
struct Sel
{
l_int32 sy; /* sel height */
l_int32 sx; /* sel width */
l_int32 cy; /* y location of sel origin */
l_int32 cx; /* x location of sel origin */
l_int32 **data; /* {0,1,2}; data[i][j] in [row][col] order */
char *name; /* used to find sel by name */
};
typedef struct Sel SEL;
struct Sela
{
l_int32 n; /* number of sel actually stored */
l_int32 nalloc; /* size of allocated ptr array */
struct Sel **sel; /* sel ptr array */
};
typedef struct Sela SELA;
/*-------------------------------------------------------------------------*
* Kernel *
*-------------------------------------------------------------------------*/
#define KERNEL_VERSION_NUMBER 2
struct L_Kernel
{
l_int32 sy; /* kernel height */
l_int32 sx; /* kernel width */
l_int32 cy; /* y location of kernel origin */
l_int32 cx; /* x location of kernel origin */
l_float32 **data; /* data[i][j] in [row][col] order */
};
typedef struct L_Kernel L_KERNEL;
/*-------------------------------------------------------------------------*
* Morphological boundary condition flags *
*
* Two types of boundary condition for erosion.
* The global variable MORPH_BC takes on one of these two values.
* See notes in morph.c for usage.
*-------------------------------------------------------------------------*/
enum {
SYMMETRIC_MORPH_BC = 0,
ASYMMETRIC_MORPH_BC = 1
};
/*-------------------------------------------------------------------------*
* Structuring element types *
*-------------------------------------------------------------------------*/
enum {
SEL_DONT_CARE = 0,
SEL_HIT = 1,
SEL_MISS = 2
};
/*-------------------------------------------------------------------------*
* Runlength flags for granulometry *
*-------------------------------------------------------------------------*/
enum {
L_RUN_OFF = 0,
L_RUN_ON = 1
};
/*-------------------------------------------------------------------------*
* Direction flags for grayscale morphology, granulometry, *
* composable Sels, convolution, etc. *
*-------------------------------------------------------------------------*/
enum {
L_HORIZ = 1,
L_VERT = 2,
L_BOTH_DIRECTIONS = 3
};
/*-------------------------------------------------------------------------*
* Morphological operation flags *
*-------------------------------------------------------------------------*/
enum {
L_MORPH_DILATE = 1,
L_MORPH_ERODE = 2,
L_MORPH_OPEN = 3,
L_MORPH_CLOSE = 4,
L_MORPH_HMT = 5
};
/*-------------------------------------------------------------------------*
* Grayscale intensity scaling flags *
*-------------------------------------------------------------------------*/
enum {
L_LINEAR_SCALE = 1,
L_LOG_SCALE = 2
};
/*-------------------------------------------------------------------------*
* Morphological tophat flags *
*-------------------------------------------------------------------------*/
enum {
L_TOPHAT_WHITE = 0,
L_TOPHAT_BLACK = 1
};
/*-------------------------------------------------------------------------*
* Arithmetic and logical operator flags *
* (use on grayscale images and Numas) *
*-------------------------------------------------------------------------*/
enum {
L_ARITH_ADD = 1,
L_ARITH_SUBTRACT = 2,
L_ARITH_MULTIPLY = 3, /* on numas only */
L_ARITH_DIVIDE = 4, /* on numas only */
L_UNION = 5, /* on numas only */
L_INTERSECTION = 6, /* on numas only */
L_SUBTRACTION = 7, /* on numas only */
L_EXCLUSIVE_OR = 8 /* on numas only */
};
/*-------------------------------------------------------------------------*
* Min/max selection flags *
*-------------------------------------------------------------------------*/
enum {
L_CHOOSE_MIN = 1, /* useful in a downscaling "erosion" */
L_CHOOSE_MAX = 2, /* useful in a downscaling "dilation" */
L_CHOOSE_MAX_MIN_DIFF = 3 /* useful in a downscaling contrast */
};
/*-------------------------------------------------------------------------*
* Distance function b.c. flags *
*-------------------------------------------------------------------------*/
enum {
L_BOUNDARY_BG = 1, /* assume bg outside image */
L_BOUNDARY_FG = 2 /* assume fg outside image */
};
/*-------------------------------------------------------------------------*
* Image comparison flags *
*-------------------------------------------------------------------------*/
enum {
L_COMPARE_XOR = 1,
L_COMPARE_SUBTRACT = 2,
L_COMPARE_ABS_DIFF = 3
};
/*-------------------------------------------------------------------------*
* Color content flags *
*-------------------------------------------------------------------------*/
enum {
L_MAX_DIFF_FROM_AVERAGE_2 = 1,
L_MAX_MIN_DIFF_FROM_2 = 2,
L_MAX_DIFF = 3
};
/*-------------------------------------------------------------------------*
* Standard size of border added around images for special processing *
*-------------------------------------------------------------------------*/
static const l_int32 ADDED_BORDER = 32; /* pixels, not bits */
#endif /* LEPTONICA_MORPH_H */

1122
windows/libs/include/pix.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,86 @@
///////////////////////////////////////////////////////////////////////
// File: platform.h
// Description: Place holder
// Author:
// Created:
//
// (C) Copyright 2006, Google Inc.
// 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.
//
///////////////////////////////////////////////////////////////////////
#ifndef TESSERACT_CCUTIL_PLATFORM_H__
#define TESSERACT_CCUTIL_PLATFORM_H__
#include <string.h>
#define DLLSYM
#ifdef _WIN32
#ifdef __GNUC__
#define ultoa _ultoa
#endif /* __GNUC__ */
#define SIGNED
#if defined(_MSC_VER)
#define snprintf _snprintf
#if (_MSC_VER <= 1400)
#define vsnprintf _vsnprintf
#endif /* (_MSC_VER <= 1400) */
#endif /* defined(_MSC_VER) */
#else
#define __UNIX__
#include <limits.h>
#ifndef PATH_MAX
#define MAX_PATH 4096
#else
#define MAX_PATH PATH_MAX
#endif
#define SIGNED signed
#endif
#ifdef _WIN32
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
#if defined(TESS_EXPORTS)
#define TESS_API __declspec(dllexport)
#elif defined(TESS_IMPORTS)
#define TESS_API __declspec(dllimport)
#else
#define TESS_API
#endif
#define TESS_LOCAL
#else
#if __GNUC__ >= 4
#if defined(TESS_EXPORTS) || defined(TESS_IMPORTS)
#define TESS_API __attribute__ ((visibility ("default")))
#define TESS_LOCAL __attribute__ ((visibility ("hidden")))
#else
#define TESS_API
#define TESS_LOCAL
#endif
#else
#define TESS_API
#define TESS_LOCAL
#endif
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
#define _TESS_FILE_BASENAME_ \
(strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#else // Unices
#define _TESS_FILE_BASENAME_ \
(strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#endif
#endif // TESSERACT_CCUTIL_PLATFORM_H__

View File

@@ -0,0 +1,91 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_PTRA_H
#define LEPTONICA_PTRA_H
/*
* Contains the following structs:
* struct L_Ptra
* struct L_Ptraa
*
* Contains definitions for:
* L_Ptra compaction flags for removal
* L_Ptra shifting flags for insert
* L_Ptraa accessor flags
*/
/*------------------------------------------------------------------------*
* Generic Ptr Array Structs *
*------------------------------------------------------------------------*/
/* Generic pointer array */
struct L_Ptra
{
l_int32 nalloc; /* size of allocated ptr array */
l_int32 imax; /* greatest valid index */
l_int32 nactual; /* actual number of stored elements */
void **array; /* ptr array */
};
typedef struct L_Ptra L_PTRA;
/* Array of generic pointer arrays */
struct L_Ptraa
{
l_int32 nalloc; /* size of allocated ptr array */
struct L_Ptra **ptra; /* array of ptra */
};
typedef struct L_Ptraa L_PTRAA;
/*------------------------------------------------------------------------*
* Array flags *
*------------------------------------------------------------------------*/
/* Flags for removal from L_Ptra */
enum {
L_NO_COMPACTION = 1, /* null the pointer only */
L_COMPACTION = 2 /* compact the array */
};
/* Flags for insertion into L_Ptra */
enum {
L_AUTO_DOWNSHIFT = 0, /* choose based on number of holes */
L_MIN_DOWNSHIFT = 1, /* downshifts min # of ptrs below insert */
L_FULL_DOWNSHIFT = 2 /* downshifts all ptrs below insert */
};
/* Accessor flags for L_Ptraa */
enum {
L_HANDLE_ONLY = 0, /* ptr to L_Ptra; caller can inspect only */
L_REMOVE = 1 /* caller owns; destroy or save in L_Ptraa */
};
#endif /* LEPTONICA_PTRA_H */

View File

@@ -0,0 +1,74 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_QUEUE_H
#define LEPTONICA_QUEUE_H
/*
* queue.h
*
* Expandable pointer queue for arbitrary void* data.
*
* The L_Queue is a fifo that implements a queue of void* pointers.
* It can be used to hold a queue of any type of struct.
*
* Internally, it maintains two counters:
* nhead: location of head (in ptrs) from the beginning
* of the array.
* nelem: number of ptr elements stored in the queue.
*
* The element at the head of the queue, which is the next to
* be removed, is array[nhead]. The location at the tail of the
* queue to which the next element will be added is
* array[nhead + nelem].
*
* As items are added to the queue, nelem increases.
* As items are removed, nhead increases and nelem decreases.
* Any time the tail reaches the end of the allocated array,
* all the pointers are shifted to the left, so that the head
* is at the beginning of the array.
* If the array becomes more than 3/4 full, it doubles in size.
*
* The auxiliary stack can be used in a wrapper for re-using
* items popped from the queue. It is not made by default.
*
* For further implementation details, see queue.c.
*/
struct L_Queue
{
l_int32 nalloc; /* size of allocated ptr array */
l_int32 nhead; /* location of head (in ptrs) from the */
/* beginning of the array */
l_int32 nelem; /* number of elements stored in the queue */
void **array; /* ptr array */
struct L_Stack *stack; /* auxiliary stack */
};
typedef struct L_Queue L_QUEUE;
#endif /* LEPTONICA_QUEUE_H */

View File

@@ -0,0 +1,231 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_READBARCODE_H
#define LEPTONICA_READBARCODE_H
/* ----------------------------------------------------------------- *
* Flags for method of extracting barcode widths *
* ----------------------------------------------------------------- */
enum {
L_USE_WIDTHS = 1, /* use histogram of barcode widths */
L_USE_WINDOWS = 2 /* find best window for decoding transitions */
};
/* ----------------------------------------------------------------- *
* Flags for barcode formats *
* These are used both to identify a barcode format and to identify *
* the decoding method to use on a barcode. *
* ----------------------------------------------------------------- */
enum {
L_BF_UNKNOWN = 0, /* unknown format */
L_BF_ANY = 1, /* try decoding with all known formats */
L_BF_CODE128 = 2, /* decode with Code128 format */
L_BF_EAN8 = 3, /* decode with EAN8 format */
L_BF_EAN13 = 4, /* decode with EAN13 format */
L_BF_CODE2OF5 = 5, /* decode with Code 2 of 5 format */
L_BF_CODEI2OF5 = 6, /* decode with Interleaved 2 of 5 format */
L_BF_CODE39 = 7, /* decode with Code39 format */
L_BF_CODE93 = 8, /* decode with Code93 format */
L_BF_CODABAR = 9, /* decode with Code93 format */
L_BF_UPCA = 10 /* decode with UPC A format */
};
/* ----------------------------------------------------------------- *
* Currently supported formats *
* Update these arrays as new formats are added. *
* ----------------------------------------------------------------- */
static const l_int32 SupportedBarcodeFormat[] = {
L_BF_CODE2OF5,
L_BF_CODEI2OF5,
L_BF_CODE93,
L_BF_CODE39,
L_BF_CODABAR,
L_BF_UPCA,
L_BF_EAN13
};
static const char *SupportedBarcodeFormatName[] = {
"Code2of5",
"CodeI2of5",
"Code93",
"Code39",
"Codabar",
"Upca",
"Ean13"
};
static const l_int32 NumSupportedBarcodeFormats = 7;
/* ----------------------------------------------------------------- *
* Code 2 of 5 symbology *
* ----------------------------------------------------------------- */
static const char *Code2of5[] = {
"111121211", "211111112", "112111112", "212111111", /* 0 - 3 */
"111121112", "211121111", "112121111", "111111212", /* 4 - 7 */
"211111211", "112111211", /* 8 - 9 */
"21211", "21112" /* Start, Stop */
};
static const l_int32 C25_START = 10;
static const l_int32 C25_STOP = 11;
/* ----------------------------------------------------------------- *
* Code Interleaved 2 of 5 symbology *
* ----------------------------------------------------------------- */
static const char *CodeI2of5[] = {
"11221", "21112", "12112", "22111", "11212", /* 0 - 4 */
"21211", "12211", "11122", "21121", "12121", /* 5 - 9 */
"1111", "211" /* start, stop */
};
static const l_int32 CI25_START = 10;
static const l_int32 CI25_STOP = 11;
/* ----------------------------------------------------------------- *
* Code 93 symbology *
* ----------------------------------------------------------------- */
static const char *Code93[] = {
"131112", "111213", "111312", "111411", "121113", /* 0: 0 - 4 */
"121212", "121311", "111114", "131211", "141111", /* 5: 5 - 9 */
"211113", "211212", "211311", "221112", "221211", /* 10: A - E */
"231111", "112113", "112212", "112311", "122112", /* 15: F - J */
"132111", "111123", "111222", "111321", "121122", /* 20: K - O */
"131121", "212112", "212211", "211122", "211221", /* 25: P - T */
"221121", "222111", "112122", "112221", "122121", /* 30: U - Y */
"123111", "121131", "311112", "311211", "321111", /* 35: Z,-,.,SP,$ */
"112131", "113121", "211131", "131221", "312111", /* 40: /,+,%,($),(%) */
"311121", "122211", "111141" /* 45: (/),(+), Start */
};
/* Use "[]{}#" to represent special codes 43-47 */
static const char Code93Val[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%[]{}#";
static const l_int32 C93_START = 47;
static const l_int32 C93_STOP = 47;
/* ----------------------------------------------------------------- *
* Code 39 symbology *
* ----------------------------------------------------------------- */
static const char *Code39[] = {
"111221211", "211211112", "112211112", "212211111", /* 0: 0 - 3 */
"111221112", "211221111", "112221111", "111211212", /* 4: 4 - 7 */
"211211211", "112211211", "211112112", "112112112", /* 8: 8 - B */
"212112111", "111122112", "211122111", "112122111", /* 12: C - F */
"111112212", "211112211", "112112211", "111122211", /* 16: G - J */
"211111122", "112111122", "212111121", "111121122", /* 20: K - N */
"211121121", "112121121", "111111222", "211111221", /* 24: O - R */
"112111221", "111121221", "221111112", "122111112", /* 28: S - V */
"222111111", "121121112", "221121111", "122121111", /* 32: W - Z */
"121111212", "221111211", "122111211", "121212111", /* 36: -,.,SP,$ */
"121211121", "121112121", "111212121", "121121211" /* 40: /,+,%,* */
};
/* Use "*" to represent the Start and Stop codes (43) */
static const char Code39Val[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*";
static const l_int32 C39_START = 43;
static const l_int32 C39_STOP = 43;
/* ----------------------------------------------------------------- *
* Codabar symbology *
* ----------------------------------------------------------------- */
static const char *Codabar[] = {
"1111122", "1111221", "1112112", "2211111", "1121121", /* 0: 0 - 4 */
"2111121", "1211112", "1211211", "1221111", "2112111", /* 5: 5 - 9 */
"1112211", "1122111", "2111212", "2121112", "2121211", /* 10: -,$,:,/,. */
"1121212", "1122121", "1212112", "1112122", "1112221" /* 15: +,A,B,C,D */
};
/* Ascii representations for codes 16-19: (A or T), (B or N), (C or *),
* (D or E). These are used in pairs for the Start and Stop codes. */
static const char CodabarVal[] = "0123456789-$:/.+ABCD";
/* ----------------------------------------------------------------- *
* UPC-A symbology *
* ----------------------------------------------------------------- */
static const char *Upca[] = {
"3211", "2221", "2122", "1411", "1132", /* 0: 0 - 4 */
"1231", "1114", "1312", "1213", "3112", /* 5: 5 - 9 */
"111", "111", "11111" /* 10: Start, Stop, Mid */
};
static const l_int32 UPCA_START = 10;
static const l_int32 UPCA_STOP = 11;
static const l_int32 UPCA_MID = 12;
/* ----------------------------------------------------------------- *
* Code128 symbology *
* ----------------------------------------------------------------- */
static const char *Code128[] = {
"212222", "222122", "222221", "121223", "121322", /* 0 - 4 */
"131222", "122213", "122312", "132212", "221213", /* 5 - 9 */
"221312", "231212", "112232", "122132", "122231", /* 10 - 14 */
"113222", "123122", "123221", "223211", "221132", /* 15 - 19 */
"221231", "213212", "223112", "312131", "311222", /* 20 - 24 */
"321122", "321221", "312212", "322112", "322211", /* 25 - 29 */
"212123", "212321", "232121", "111323", "131123", /* 30 - 34 */
"131321", "112313", "132113", "132311", "211313", /* 35 - 39 */
"231113", "231311", "112133", "112331", "132131", /* 40 - 44 */
"113123", "113321", "133121", "313121", "211331", /* 45 - 49 */
"231131", "213113", "213311", "213131", "311123", /* 50 - 54 */
"311321", "331121", "312113", "312311", "332111", /* 55 - 59 */
"314111", "221411", "431111", "111224", "111422", /* 60 - 64 */
"121124", "121421", "141122", "141221", "112214", /* 65 - 69 */
"112412", "122114", "122411", "142112", "142211", /* 70 - 74 */
"241211", "221114", "413111", "241112", "134111", /* 75 - 79 */
"111242", "121142", "121241", "114212", "124112", /* 80 - 84 */
"124211", "411212", "421112", "421211", "212141", /* 85 - 89 */
"214121", "412121", "111143", "111341", "131141", /* 90 - 94 */
"114113", "114311", "411113", "411311", "113141", /* 95 - 99 */
"114131", "311141", "411131", "211412", "211214", /* 100 - 104 */
"211232", "2331112" /* 105 - 106 */
};
static const l_int32 C128_FUN_3 = 96; /* in A or B only; in C it is 96 */
static const l_int32 C128_FUNC_2 = 97; /* in A or B only; in C it is 97 */
static const l_int32 C128_SHIFT = 98; /* in A or B only; in C it is 98 */
static const l_int32 C128_GOTO_C = 99; /* in A or B only; in C it is 99 */
static const l_int32 C128_GOTO_B = 100;
static const l_int32 C128_GOTO_A = 101;
static const l_int32 C128_FUNC_1 = 102;
static const l_int32 C128_START_A = 103;
static const l_int32 C128_START_B = 104;
static const l_int32 C128_START_C = 105;
static const l_int32 C128_STOP = 106;
/* code 128 symbols are 11 units */
static const l_int32 C128_SYMBOL_WIDTH = 11;
#endif /* LEPTONICA_READBARCODE_H */

View File

@@ -0,0 +1,257 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_RECOG_H
#define LEPTONICA_RECOG_H
/*
* recog.h
*
* A simple utility for training and recognizing individual
* machine-printed text characters. In an application, one can
* envision using a number of these, one for each trained set.
*
* In training mode, a set of labelled bitmaps is presented, either
* one at a time, or in a directory, or in a pixa. If in a directory,
* or a pixa, the labelling text string must be embedded in the
* text field of the image file.
*
* Any number of recognizers (L_Recog) can be trained and then used
* together in an array (L_Recoga). All these trained structures
* can be serialized to file and read back. The serialized version
* holds all the bitmaps used for training, plus, for arbitrary
* character sets, the UTF8 representation and the lookup table
* mapping from the character representation to index.
*
* There are three levels of "sets" here:
*
* (1) Example set: the examples representing a character that
* were printed in the same way, so that they can be combined
* without scaling to form an "average" template for the character.
* In the recognition phase, we use either this aligned average,
* or the individual bitmaps. All examples in the set are given
* the same character label. Example: the letter 'a' in the
* predominant font in a book.
*
* (2) Character set (represented by L_Recog, a single recognizer):
* The set of different characters, each of which is described
* by (1). Each element of the set has a different character
* label. Example: the digits '0' through '9' that are used for
* page numbering in a book.
*
* (3) Recognizer set (represented by L_Recoga, an array of recogs):
* A set of recognizers, each of which is described by (2).
* In general, we do not want to combine the character sets
* with the same labels within different recognizer sets,
* because the bitmaps can differ in font type, style or size.
* Example 1: the letter 'a' can be printed in two very different
* ways (either with a large loop or with a smaller loop in
* the lower half); both share the same label but need to be
* distinguished so that they are not mixed when averaging.
* Example 2: a recognizer trained for a book may be missing
* some characters, so we need to supplement it with another
* "generic" or "bootstrap" recognizer that has the additional
* characters from a variety of sources. Bootstrap recognizers
* must be run in a mode where all characters are scaled.
*
* In the recognition process, for each component in an input image,
* each recognizer (L_Recog) records the best match (highest
* correlation score). If there is more than one recognizer, these
* results are aggregated to find the best match for each character
* for all the recognizers, and this is stored in L_Recoga.
*/
#define RECOG_VERSION_NUMBER 1
struct L_Recoga {
l_int32 n; /* number of recogs */
l_int32 nalloc; /* number of recog ptrs allocated */
struct L_Recog **recog; /* recog ptr array */
struct L_Rcha *rcha; /* stores the array of best chars */
};
typedef struct L_Recoga L_RECOGA;
struct L_Recog {
l_int32 scalew; /* scale all examples to this width; */
/* use 0 prevent horizontal scaling */
l_int32 scaleh; /* scale all examples to this height; */
/* use 0 prevent vertical scaling */
l_int32 templ_type; /* template type: either an average of */
/* examples (L_USE_AVERAGE) or the set */
/* of all examples (L_USE_ALL) */
l_int32 maxarraysize; /* initialize container arrays to this */
l_int32 setsize; /* size of character set */
l_int32 threshold; /* for binarizing if depth > 1 */
l_int32 maxyshift; /* vertical jiggle on nominal centroid */
/* alignment; typically 0 or 1 */
l_float32 asperity_fr; /* +- allowed fractional asperity ratio */
l_int32 charset_type; /* one of L_ARABIC_NUMERALS, etc. */
l_int32 charset_size; /* expected number of classes in charset */
char *bootdir; /* dir with bootstrap pixa charsets */
char *bootpattern; /* file pattern for bootstrap pixa charsets */
char *bootpath; /* path for single bootstrap pixa charset */
l_int32 min_nopad; /* min number of samples without padding */
l_int32 max_afterpad; /* max number of samples after padding */
l_int32 samplenum; /* keep track of number of training samples */
l_int32 minwidth_u; /* min width of averaged unscaled templates */
l_int32 maxwidth_u; /* max width of averaged unscaled templates */
l_int32 minheight_u; /* min height of averaged unscaled templates */
l_int32 maxheight_u; /* max height of averaged unscaled templates */
l_int32 minwidth; /* min width of averaged scaled templates */
l_int32 maxwidth; /* max width of averaged scaled templates */
l_int32 ave_done; /* set to 1 when averaged bitmaps are made */
l_int32 train_done; /* set to 1 when training is complete or */
/* identification has started */
l_int32 min_splitw; /* min component width kept in splitting */
l_int32 min_splith; /* min component height kept in splitting */
l_int32 max_splith; /* max component height kept in splitting */
struct Sarray *sa_text; /* text array for arbitrary char set */
struct L_Dna *dna_tochar; /* index-to-char lut for arbitrary char set */
l_int32 *centtab; /* table for finding centroids */
l_int32 *sumtab; /* table for finding pixel sums */
char *fname; /* serialized filename (if read) */
struct Pixaa *pixaa_u; /* all unscaled bitmaps for each class */
struct Pixa *pixa_u; /* averaged unscaled bitmaps for each class */
struct Ptaa *ptaa_u; /* centroids of all unscaled bitmaps */
struct Pta *pta_u; /* centroids of unscaled averaged bitmaps */
struct Numaa *naasum_u; /* area of all unscaled bitmap examples */
struct Numa *nasum_u; /* area of unscaled averaged bitmaps */
struct Pixaa *pixaa; /* all bitmap examples for each class */
struct Pixa *pixa; /* averaged bitmaps for each class */
struct Ptaa *ptaa; /* centroids of all bitmap examples */
struct Pta *pta; /* centroids of averaged bitmaps */
struct Numaa *naasum; /* area of all bitmap examples */
struct Numa *nasum; /* area of averaged bitmaps */
struct Pixa *pixa_tr; /* input training images */
struct Pixa *pixadb_ave; /* unscaled and scaled averaged bitmaps */
struct Pixa *pixa_id; /* input images for identifying */
struct Pix *pixdb_ave; /* debug: best match of input against ave. */
struct Pix *pixdb_range; /* debug: best matches within range */
struct Pixa *pixadb_boot; /* debug: bootstrap training results */
struct Pixa *pixadb_split; /* debug: splitting results */
struct L_Bmf *bmf; /* bmf fonts */
l_int32 bmf_size; /* font size of bmf; default is 6 pt */
struct L_Rdid *did; /* temp data used for image decoding */
struct L_Rch *rch; /* temp data used for holding best char */
struct L_Rcha *rcha; /* temp data used for array of best chars */
l_int32 bootrecog; /* 1 if using bootstrap samples; else 0 */
l_int32 index; /* recog index in recoga; -1 if no parent */
struct L_Recoga *parent; /* ptr to parent array; can be null */
};
typedef struct L_Recog L_RECOG;
/*
* Data returned from correlation matching on a single character
*/
struct L_Rch {
l_int32 index; /* index of best template */
l_float32 score; /* correlation score of best template */
char *text; /* character string of best template */
l_int32 sample; /* index of best sample (within the best */
/* template class, if all samples are used) */
l_int32 xloc; /* x-location of template (delx + shiftx) */
l_int32 yloc; /* y-location of template (dely + shifty) */
l_int32 width; /* width of best template */
};
typedef struct L_Rch L_RCH;
/*
* Data returned from correlation matching on an array of characters
*/
struct L_Rcha {
struct Numa *naindex; /* indices of best templates */
struct Numa *nascore; /* correlation scores of best templates */
struct Sarray *satext; /* character strings of best templates */
struct Numa *nasample; /* indices of best samples */
struct Numa *naxloc; /* x-locations of templates (delx + shiftx) */
struct Numa *nayloc; /* y-locations of templates (dely + shifty) */
struct Numa *nawidth; /* widths of best templates */
};
typedef struct L_Rcha L_RCHA;
/*
* Data used for decoding a line of characters.
*/
struct L_Rdid {
struct Pix *pixs; /* clone of pix to be decoded */
l_int32 **counta; /* count array for each averaged template */
l_int32 **delya; /* best y-shift array per averaged template */
l_int32 narray; /* number of averaged templates */
l_int32 size; /* size of count array (width of pixs) */
l_int32 *setwidth; /* setwidths for each template */
struct Numa *nasum; /* pixel count in pixs by column */
struct Numa *namoment; /* first moment of pixels in pixs by column */
l_int32 fullarrays; /* 1 if full arrays are made; 0 otherwise */
l_float32 *beta; /* channel coeffs for template fg term */
l_float32 *gamma; /* channel coeffs for bit-and term */
l_float32 *trellisscore; /* score on trellis */
l_int32 *trellistempl; /* template on trellis (for backtrack) */
struct Numa *natempl; /* indices of best path templates */
struct Numa *naxloc; /* x locations of best path templates */
struct Numa *nadely; /* y locations of best path templates */
struct Numa *nawidth; /* widths of best path templates */
struct Numa *nascore; /* correlation scores: best path templates */
struct Numa *natempl_r; /* indices of best rescored templates */
struct Numa *naxloc_r; /* x locations of best rescoredtemplates */
struct Numa *nadely_r; /* y locations of best rescoredtemplates */
struct Numa *nawidth_r; /* widths of best rescoredtemplates */
struct Numa *nascore_r; /* correlation scores: rescored templates */
};
typedef struct L_Rdid L_RDID;
/*-------------------------------------------------------------------------*
* Flags for selecting processing *
*-------------------------------------------------------------------------*/
enum {
L_SELECT_UNSCALED = 0, /* select the unscaled bitmaps */
L_SELECT_SCALED = 1, /* select the scaled bitmaps */
L_SELECT_BOTH = 2 /* select both unscaled and scaled */
};
/*-------------------------------------------------------------------------*
* Flags for determining what to test against *
*-------------------------------------------------------------------------*/
enum {
L_USE_AVERAGE = 0, /* form template from class average */
L_USE_ALL = 1 /* match against all elements of each class */
};
/*-------------------------------------------------------------------------*
* Flags for describing limited character sets *
*-------------------------------------------------------------------------*/
enum {
L_UNKNOWN = 0, /* character set type is not specified */
L_ARABIC_NUMERALS = 1, /* 10 digits */
L_LC_ROMAN_NUMERALS = 2, /* 7 lower-case letters (i,v,x,l,c,d,m) */
L_UC_ROMAN_NUMERALS = 3, /* 7 upper-case letters (I,V,X,L,C,D,M) */
L_LC_ALPHA = 4, /* 26 lower-case letters */
L_UC_ALPHA = 5 /* 26 upper-case letters */
};
#endif /* LEPTONICA_RECOG_H */

View File

@@ -0,0 +1,135 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_REGUTILS_H
#define LEPTONICA_REGUTILS_H
/*
* regutils.h
*
* Contains this regression test parameter packaging struct
* struct L_RegParams
*
* The regression test utility allows you to write regression tests
* that compare results with existing "golden files" and with
* compiled in data.
*
* Regression tests can be called in three ways.
* For example, for distance_reg:
*
* Case 1: distance_reg [generate]
* This generates golden files in /tmp for the reg test.
*
* Case 2: distance_reg compare
* This runs the test against the set of golden files. It
* appends to 'outfile.txt' either "SUCCESS" or "FAILURE",
* as well as the details of any parts of the test that failed.
* It writes to a temporary file stream (fp)
*
* Case 3: distance_reg display
* This runs the test but makes no comparison of the output
* against the set of golden files. In addition, this displays
* images and plots that are specified in the test under
* control of the display variable. Display is enabled only
* for this case. Using 'display' on the command line is optional.
*
* Regression tests follow the pattern given below. Tests are
* automatically numbered sequentially, and it is convenient to
* comment each with a number to keep track (for comparison tests
* and for debugging). In an actual case, comparisons of pix and
* of files can occur in any order. We give a specific order here
* for clarity.
*
* L_REGPARAMS *rp; // holds data required by the test functions
*
* // Setup variables; optionally open stream
* if (regTestSetup(argc, argv, &rp))
* return 1;
*
* // Test pairs of generated pix for identity. This compares
* // two pix; no golden file is generated.
* regTestComparePix(rp, pix1, pix2); // 0
*
* // Test pairs of generated pix for similarity. This compares
* // two pix; no golden file is generated. The last arg determines
* // if stats are to be written to stderr.
* regTestCompareSimilarPix(rp, pix1, pix2, 15, 0.001, 0); // 1
*
* // Generation of <newfile*> outputs and testing for identity
* // These files can be anything, of course.
* regTestCheckFile(rp, <newfile0>); // 2
* regTestCheckFile(rp, <newfile1>); // 3
*
* // Test pairs of output golden files for identity. Here we
* // are comparing golden files 2 and 3.
* regTestCompareFiles(rp, 2, 3); // 4
*
* // "Write and check". This writes a pix using a canonical
* // formulation for the local filename and either:
* // case 1: generates a golden file
* // case 2: compares the local file with a golden file
* // case 3: generates local files and displays
* // Here we write the pix compressed with png and jpeg, respectively;
* // Then check against the golden file. The internal @index
* // is incremented; it is embedded in the local filename and,
* // if generating, in the golden file as well.
* regTestWritePixAndCheck(rp, pix1, IFF_PNG); // 5
* regTestWritePixAndCheck(rp, pix2, IFF_JFIF_JPEG); // 6
*
* // Display if reg test was called in 'display' mode
* pixDisplayWithTitle(pix1, 100, 100, NULL, rp->display);
*
* // Clean up and output result
* regTestCleanup(rp);
*/
/*-------------------------------------------------------------------------*
* Regression test parameter packer *
*-------------------------------------------------------------------------*/
struct L_RegParams
{
FILE *fp; /* stream to temporary output file for compare mode */
char *testname; /* name of test, without '_reg' */
char *tempfile; /* name of temp file for compare mode output */
l_int32 mode; /* generate, compare or display */
l_int32 index; /* index into saved files for this test; 0-based */
l_int32 success; /* overall result of the test */
l_int32 display; /* 1 if in display mode; 0 otherwise */
L_TIMER tstart; /* marks beginning of the reg test */
};
typedef struct L_RegParams L_REGPARAMS;
/* Running modes for the test */
enum {
L_REG_GENERATE = 0,
L_REG_COMPARE = 1,
L_REG_DISPLAY = 2
};
#endif /* LEPTONICA_REGUTILS_H */

View File

@@ -0,0 +1,66 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_STACK_H
#define LEPTONICA_STACK_H
/*
* stack.h
*
* Expandable pointer stack for arbitrary void* data.
*
* The L_Stack is an array of void * ptrs, onto which arbitrary
* objects can be stored. At any time, the number of
* stored objects is stack->n. The object at the bottom
* of the stack is at array[0]; the object at the top of
* the stack is at array[n-1]. New objects are added
* to the top of the stack, at the first available location,
* which is array[n]. Objects are removed from the top of the
* stack. When an attempt is made to remove an object from an
* empty stack, the result is null. When the stack becomes
* filled, so that n = nalloc, the size is doubled.
*
* The auxiliary stack can be used to store and remove
* objects for re-use. It must be created by a separate
* call to pstackCreate(). [Just imagine the chaos if
* pstackCreate() created the auxiliary stack!]
* pstackDestroy() checks for the auxiliary stack and removes it.
*/
/* Note that array[n] is the first null ptr in the array */
struct L_Stack
{
l_int32 nalloc; /* size of ptr array */
l_int32 n; /* number of stored elements */
void **array; /* ptr array */
struct L_Stack *auxstack; /* auxiliary stack */
};
typedef struct L_Stack L_STACK;
#endif /* LEPTONICA_STACK_H */

View File

@@ -0,0 +1,48 @@
/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- 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 LEPTONICA_STRINGCODE_H
#define LEPTONICA_STRINGCODE_H
/*
* stringcode.h
*
* Data structure to hold accumulating generated code for storing
* and extracing serializable leptonica objects (e.g., pixa, recog).
*/
struct L_StrCode
{
l_int32 fileno; /* index for function and output file names */
l_int32 ifunc; /* index into struct currently being stored */
SARRAY *function; /* store case code for extraction */
SARRAY *data; /* store base64 encoded data as strings */
SARRAY *descr; /* store line in description table */
l_int32 n; /* number of data strings */
};
typedef struct L_StrCode L_STRCODE;
#endif /* LEPTONICA_STRINGCODE_H */

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