~ubuntu-branches/debian/experimental/cuneiform/experimental

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/dif/src/dif.c

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, libm.diff, swapbytes.diff
  • Date: 2010-09-14 15:53:54 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914155354-hhxaa13xmhb82e3e
Tags: 1.0.0+dfsg-1
* New upstream release (closes: #575419).
* New maintainer (closes: #543893).
* Document in README.source how to repackage upstream tarball.
* Update debian/copyright.
  + Document that the package is auto-buildable.
  + Document which files were stripped from the upstream tarball.
  + Convert to the DEP-5 format.
* Drop README.Debian, no longer needed.
* Rewrite debian/rules from scratch using dh.
  + Bump debhelper minimum version to 7.4.4 (for cmake support).
  + Turn on MAKE_VERBOSE_MAKEFILE.
  + Disable call to dh_makeshlibs to avoid creation of spurious
    calls to ldconfig in postrm/postinst.
  + Add get-orig-source target.
* Remove unused overrides.
* Link to GraphicsMagick rather than ImageMagick:
  + Build-depend on graphicsmagick-libmagick-dev-compat.
  + Add patch to properly initialize the library. [graphicsmagick.diff]    
* Bump standards version to 3.9.1 (no changes needed).
* Force upgrade of ocrodjvu to at least 0.4.2; earlier versions of ocrodjvu
  don't support this version of Cuneiform.
* List all the supported languages in the package description.
* Update the manual page.
  + Document --dotmatrix, --fax and --singlecolumn options.
  + Document all output formats.
  + Don't use hyphen as minus sign.
  + Fix a few formatting issues.
* Drop Vcs-* fields.
* Add watch file.
* Add patch from Dmitrijs Ledkovs to link the lao library with libm.
  [libm.diff]
* Add patch for a for a more portable function to swap byte order.
  [swapbytes.diff]
* Set Architecture to any; there's no good reason to limit it.
* Run rudimentary tests at build time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 1993-2008, Cognitive Technologies
3
3
All rights reserved.
4
4
 
5
 
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
 
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
7
 
 
8
 
      * ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
 
        ���� ����������� �� ��������� �����, ���� ������ ������� � �����������
10
 
        ����� �� ��������.
11
 
      * ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
 
        ������ ����������, ������������ ��� ���������������, ������ �����������
13
 
        ��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
 
        ����������� ����� �� ��������.
15
 
      * �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
 
        ���� ������������ � �������� �������� ��������� �/��� �����������
17
 
        ���������, ���������� �� ���� ��, ��� ���������������� �����������
18
 
        ����������.
19
 
 
20
 
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
 
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
 
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
 
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
 
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
 
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
 
������������� ������, ��������� � �������������� ��� ���������� ����������
27
 
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
 
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
 
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
 
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
 
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
5
Разрешается повторное распространение и использование как в виде исходного кода,
 
6
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
 
7
 
 
8
      * При повторном распространении исходного кода должны оставаться указанное
 
9
        выше уведомление об авторском праве, этот список условий и последующий
 
10
        отказ от гарантий.
 
11
      * При повторном распространении двоичного кода в документации и/или в
 
12
        других материалах, поставляемых при распространении, должны сохраняться
 
13
        указанная выше информация об авторском праве, этот список условий и
 
14
        последующий отказ от гарантий.
 
15
      * Ни название Cognitive Technologies, ни имена ее сотрудников не могут
 
16
        быть использованы в качестве средства поддержки и/или продвижения
 
17
        продуктов, основанных на этом ПО, без предварительного письменного
 
18
        разрешения.
 
19
 
 
20
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
 
21
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
 
22
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
 
23
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
 
24
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
 
25
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
 
26
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
 
27
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
 
28
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
 
29
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
 
30
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
 
31
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
32
32
 
33
33
Redistribution and use in source and binary forms, with or without modification,
34
34
are permitted provided that the following conditions are met:
57
57
#include<string.h>
58
58
#include "dif.h"
59
59
#include "stick.h"
60
 
extern void init_diskrim(Word8* raster,Int16 height ,Int16 width);
61
 
extern Int16 Diskrim(Word8 let,Word8* raster,
62
 
      Int16 D_X,Int16 dx,Int16 dy,Word8, Int16 );
63
 
extern Word8   stick_recog(Word8 let, STICK_CHARS *l, STICK_CHARS *r,
 
60
extern void init_diskrim(uchar* raster,int16_t height ,int16_t width);
 
61
extern int16_t Diskrim(uchar let,uchar* raster,
 
62
      int16_t D_X,int16_t dx,int16_t dy,uchar, int16_t );
 
63
extern uchar   stick_recog(uchar let, STICK_CHARS *l, STICK_CHARS *r,
64
64
                STICK_SIGNUMS *s);
65
 
extern Word8 lnhead_stick_center_study(lnhead *lin,Int16 dy,Int16 dx,
 
65
extern uchar lnhead_stick_center_study(lnhead *lin,int16_t dy,int16_t dx,
66
66
        STICK_CHARS *res_left_chars,STICK_CHARS *res_right_chars,
67
67
        STICK_SIGNUMS *res_signums);
68
 
extern Int32 lnhead_stick_get_incline(lnhead *pool ,int dy, int dx );
69
 
extern void  clear_right_bites(Word8 *RASTER, Int16 NWIDTH, Int16 WBYTE, Int16 NHEIGHT);
70
 
extern  Word16 typ_thin_stick(lnhead *lin,Int16 dy,Int16 dx);
71
 
extern  Int16 LeftDistance(Word8 *RASTER, Int16 NWIDTH);
72
 
extern  Int16 RightDistance(Word8 *RASTER, Int16 NWIDTH);
 
68
extern int32_t lnhead_stick_get_incline(lnhead *pool ,int dy, int dx );
 
69
extern void  clear_right_bites(uchar *RASTER, int16_t NWIDTH, int16_t WBYTE, int16_t NHEIGHT);
 
70
extern  uint16_t typ_thin_stick(lnhead *lin,int16_t dy,int16_t dx);
 
71
extern  int16_t LeftDistance(uchar *RASTER, int16_t NWIDTH);
 
72
extern  int16_t RightDistance(uchar *RASTER, int16_t NWIDTH);
73
73
 
74
 
Word8   alphabet[256];
 
74
uchar   alphabet[256];
75
75
Bool32  digit_mode = FALSE, dif_adding_mode ;
76
 
Word8   language;
77
 
Int32   dif_typ_of_font=0;
 
76
uchar   language;
 
77
int32_t   dif_typ_of_font=0;
78
78
#include "minmax.h"
79
79
 
80
 
extern Int16 broken_ii;
81
 
extern Word8 broken_flag;
82
 
Word8  cutl_flag, cutr_flag;
 
80
extern int16_t broken_ii;
 
81
extern uchar broken_flag;
 
82
uchar  cutl_flag, cutr_flag;
83
83
 
84
 
DIF_FUNC(void)  DIFSetFont( Int32 typ_of_font)
 
84
DIF_FUNC(void)  DIFSetFont( int32_t typ_of_font)
85
85
{
86
86
dif_typ_of_font=typ_of_font;
87
87
return;
90
90
DIF_FUNC(Bool32)  DIFInit( RecRaster *r, Bool32 broken, Bool32 broken_II,
91
91
    Bool32 cut_left, Bool32 cut_right)
92
92
{
93
 
   broken_ii = (Int16)(broken_II!=0);
94
 
   broken_flag=(Word8)broken;
95
 
   cutl_flag=(Word8)(cut_left!=0);
96
 
   cutr_flag=(Word8)(cut_right!=0);
97
 
   init_diskrim(r->Raster,(Int16)r->lnPixHeight,(Int16)r->lnPixWidth);
 
93
   broken_ii = (int16_t)(broken_II!=0);
 
94
   broken_flag=(uchar)broken;
 
95
   cutl_flag=(uchar)(cut_left!=0);
 
96
   cutr_flag=(uchar)(cut_right!=0);
 
97
   init_diskrim(r->Raster,(int16_t)r->lnPixHeight,(int16_t)r->lnPixWidth);
98
98
   return TRUE;
99
99
}
100
100
 
102
102
                                          RecVersions* res )
103
103
{
104
104
 int i, pen;
105
 
 Int16  dx,dy ;
 
105
 int16_t  dx,dy ;
106
106
 int    maxprob;
107
107
 
108
 
 dy=(Int16)r->lnPixHeight;
109
 
 dx=(Int16)r->lnPixWidth;
 
108
 dy=(int16_t)r->lnPixHeight;
 
109
 dx=(int16_t)r->lnPixWidth;
110
110
 
111
111
 for(maxprob=i=0;i<res->lnAltCnt;i++)
112
112
    if( res->Alt[i].Prob>maxprob )
115
115
 for(i=0;i<res->lnAltCnt;i++)
116
116
    {
117
117
 
118
 
    pen = Diskrim((char)(res->Alt[i].Code),r->Raster,(Int16)REC_GW_WORD8(dx),(Int16)dx,(Int16)dy,0,0);
 
118
    pen = Diskrim((char)(res->Alt[i].Code),r->Raster,(int16_t)REC_GW_WORD8(dx),(int16_t)dx,(int16_t)dy,0,0);
119
119
    if( pen<0 && broken_flag && broken_ii )
120
120
        { // broken II
121
121
        switch( pen )
141
141
 
142
142
}
143
143
 
144
 
Word8 dif_down_prob(Word8 prob, Word8 dis)
 
144
uchar dif_down_prob(uchar prob, uchar dis)
145
145
{
146
146
if( prob>dis )
147
147
    prob -= dis;
150
150
return prob;
151
151
}
152
152
 
153
 
DIF_FUNC(Bool32)  DIFStick_expert( Int16 dx,Int16 dy , Word8 *pool,
 
153
DIF_FUNC(Bool32)  DIFStick_expert( int16_t dx,int16_t dy , uchar *pool,
154
154
                                                                             RecVersions* res )
155
155
{
156
156
STICK_CHARS     res_left_chars={0},res_right_chars={0};
157
157
STICK_SIGNUMS   res_signums={0};
158
 
Int16           i ;
159
 
Word8           ret=0, r;
 
158
int16_t           i ;
 
159
uchar           ret=0, r;
160
160
 
161
161
if( !pool)
162
162
    return FALSE;
313
313
}
314
314
 
315
315
 
316
 
DIF_FUNC(Int32)  DIFGet_incline( RecRaster*  r, Word8 *pool)
 
316
DIF_FUNC(int32_t)  DIFGet_incline( RecRaster*  r, uchar *pool)
317
317
{
318
 
 Int16 dx,dy ;
 
318
 int16_t dx,dy ;
319
319
 
320
 
 dy=(Int16)r->lnPixHeight;
321
 
 dx=(Int16)r->lnPixWidth;
 
320
 dy=(int16_t)r->lnPixHeight;
 
321
 dx=(int16_t)r->lnPixWidth;
322
322
 
323
323
 if(!pool) return -1;
324
324
 
330
330
   return;
331
331
 }
332
332
 
333
 
 DIF_FUNC(Int16) DIFGetErr(void)
 
333
 DIF_FUNC(int16_t) DIFGetErr(void)
334
334
 {
335
335
   return TRUE;
336
336
 }
337
337
 
338
338
 
339
 
DIF_FUNC(Int16) DIFLeftDistance(Word8 *RASTER, Int16 NWIDTH)
 
339
DIF_FUNC(int16_t) DIFLeftDistance(uchar *RASTER, int16_t NWIDTH)
340
340
{
341
341
return LeftDistance(RASTER, NWIDTH);
342
342
}
343
343
 
344
 
DIF_FUNC(Int16) DIFRightDistance(Word8 *RASTER, Int16 NWIDTH)
 
344
DIF_FUNC(int16_t) DIFRightDistance(uchar *RASTER, int16_t NWIDTH)
345
345
{
346
346
return RightDistance(RASTER, NWIDTH);
347
347
}
348
348
 
349
 
DIF_FUNC(void) DIFClearRightZone(Word8 *RASTER, Int16 NWIDTH, Int16 WBYTE, Int16 NHEIGHT)
 
349
DIF_FUNC(void) DIFClearRightZone(uchar *RASTER, int16_t NWIDTH, int16_t WBYTE, int16_t NHEIGHT)
350
350
{
351
351
clear_right_bites(RASTER, NWIDTH, WBYTE, NHEIGHT);
352
352
return;
371
371
return TRUE;
372
372
}
373
373
 
374
 
DIF_FUNC(Bool32) DIF_SetLanguage(Word8 lang)
 
374
DIF_FUNC(Bool32) DIF_SetLanguage(uchar lang)
375
375
{
376
376
language=lang;
377
377
return TRUE;
378
378
}
379
379
 
380
380
 
381
 
DIF_FUNC(Word16) DIF_typ_thin_stick(Word8 *lin,Int16 dy,Int16 dx)
 
381
DIF_FUNC(uint16_t) DIF_typ_thin_stick(uchar *lin,int16_t dy,int16_t dx)
382
382
{
383
383
return  typ_thin_stick((lnhead *)lin, dy, dx);
384
384
}