~ubuntu-branches/ubuntu/precise/cuneiform/precise

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/abrtools.c

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, c-assert.diff, slovenian-slv.diff
  • Date: 2011-01-26 21:53:07 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110126215307-62x61mcesr607qb7
Tags: 1.0.0+dfsg-2
* Upload to unstable.
* Explicitly build-depend on pkg-config. Thanks to Stefano Rivera for the
  bug report.
* Add Vcs-* fields.
* Use the standard C assert() macro, rather than custom Cuneiform one.
  [c-assert.diff]
* Pass CFLAGS, CXXFLAGS and LDFLAGS (get from dpkg-buildflags) to cmake
  (closes: #608345). Thanks to Sami Liedes for the bug report.
  + Build depend on dpkg-dev (>= 1.15.7).
* Pass --parallel to dh.
  + Bump debhelper minimum version to 7.4.10.
* Update debian/copyright to the latest DEP-5 version.
* Bump year in debian/copyright.
* Explicitly link to GraphicsMagick (rather than via the ImageMagick
  compatibility layer).
* Don't ship /usr/lib/cuneiform/*.so symlinks. These libraries are
  considered private, at least until #598616 is fixed.
* Rename some private variables in debian/rules to make them lowercase.
* Update patch headers.
* Provide proper ‘build-arch’ and ‘build-indep’ targets in debian/rules.
* Document input format in the manual page (closes: #572061). Thanks to
  Janusz S. Bień for the bug report.
* Use ‘slv’ (rather than ‘slo’) as language code for Slovenian.
  [slovenian-slv.diff]
* Fix package description: Slovenian is supported, Slovak is not.
* Improve documentation of the language (-l) option (closes: #602512).
  Thanks to Jari Aalto for the bug report.
* Install reasons file for vrms.

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:
59
59
#include <string.h>
60
60
#define  MLTPLR 64
61
61
 
62
 
static BYTE pen_over_b2[8]={ 0,0,20,80,120,200,220,240 };
63
 
static INT  x_beg, y_beg, delta_x, delta_y;
64
 
static INT  orient;
65
 
static BYTE pen_for_convex[6] = { 0, 32, 48, 64, 128, 240 };
 
62
static uchar pen_over_b2[8]={ 0,0,20,80,120,200,220,240 };
 
63
static int16_t  x_beg, y_beg, delta_x, delta_y;
 
64
static int16_t  orient;
 
65
static uchar pen_for_convex[6] = { 0, 32, 48, 64, 128, 240 };
66
66
 
67
67
 
68
68
void abris_reset()
71
71
 abriflag=leftfl=rightfl=topfl=botfl=0;
72
72
}
73
73
 
74
 
INT make_histo ( BYTE *array, BYTE max_num)
 
74
int16_t make_histo ( uchar *array, uchar max_num)
75
75
{
76
 
INT i,j, mode_val;
 
76
int16_t i,j, mode_val;
77
77
 
78
78
 memset(histo,0,128);
79
79
 histo_max_value = 0;
84
84
   j = array[i];
85
85
   histo[j] ++;
86
86
   if ( j > histo_max_value )
87
 
     histo_max_value = (BYTE)j;
 
87
     histo_max_value = (uchar)j;
88
88
  }
89
89
 for (i=0, j=0; i <= histo_max_value; i++)
90
90
  {
100
100
 interval *int1;
101
101
 c_comp *cp1;
102
102
 cell *a;
103
 
 BYTE *rpsum, *rpln, *rpleft, *rpright, *rpwid;
104
 
 BYTE intbeg, intend, intlth;
105
 
 INT  Lc1, lc1, nc,
 
103
 uchar *rpsum, *rpln, *rpleft, *rpright, *rpwid;
 
104
 uchar intbeg, intend, intlth;
 
105
 int16_t  Lc1, lc1, nc,
106
106
      hw, hm, rowd, cold;
107
107
 
108
108
 Z=&string;
124
124
 ncells--;
125
125
 
126
126
 {
127
 
  INT h = gl_maxrow - gl_minrow; INT w = gl_maxcol - gl_mincol;
 
127
  int16_t h = gl_maxrow - gl_minrow; int16_t w = gl_maxcol - gl_mincol;
128
128
   memset(l_abr,255,h);
129
129
   memset(r_abr,255,h);
130
130
   memset(top,255,w);
149
149
  cold=a->col - gl_mincol;  // cell_to_box_relative col
150
150
  cp1 = a->env;
151
151
  Lc1=cp1->nl;        // number of lines in component
152
 
  Lp1=(lnhead *) ( (CHAR *)cp1 + cp1->lines + 2); // beginning of first line
 
152
  Lp1=(lnhead *) ( (char *)cp1 + cp1->lines + 2); // beginning of first line
153
153
  Lp2=Lp1;
154
154
  for (lc1=0; lc1 < Lc1; lc1++)
155
155
  {
169
169
        intlth=int1->l;
170
170
        intbeg=intend-intlth;
171
171
        {
172
 
            BYTE bhm = (BYTE)hm;
173
 
            BYTE bfl = fullh-hm;
174
 
            LONG i, e = intend;
 
172
            uchar bhm = (uchar)hm;
 
173
            uchar bfl = fullh-hm;
 
174
            int32_t i, e = intend;
175
175
            for (i=intbeg; i<e; i++)
176
176
            {
177
 
                if ((BYTE)bhm < (BYTE)top[i] ) top[i]=bhm;
178
 
                if ((BYTE)bfl < (BYTE)bot[i] ) bot[i]=bfl;
 
177
                if ((uchar)bhm < (uchar)top[i] ) top[i]=bhm;
 
178
                if ((uchar)bfl < (uchar)bot[i] ) bot[i]=bfl;
179
179
            }
180
180
        }
181
181
        intend=fullw-intend;
187
187
      }
188
188
      if (Lp1->h > 1)  total_num_black_int += Lp1->h;
189
189
 
190
 
      Lp2=Lp1=(lnhead *) ((CHAR *)Lp2+Lp2->lth);   // next line
 
190
      Lp2=Lp1=(lnhead *) ((char *)Lp2+Lp2->lth);   // next line
191
191
  }  // for all lines
192
192
 }  // while all cells
193
193
 
208
208
}
209
209
/***************************************/
210
210
void make_wid()
211
 
{ INT i, ns; BYTE *pfun;
 
211
{ int16_t i, ns; uchar *pfun;
212
212
 if (sfl & 1) return;
213
213
 swt=0;
214
214
 for (i=0, pfun=wid; i<fullh; pfun++,i++)
221
221
}
222
222
/*************************************/
223
223
void make_left_max()
224
 
{ INT i; BYTE *pfun, sb, nb;
 
224
{ int16_t i; uchar *pfun, sb, nb;
225
225
 if (leftfl & 1) return;
226
226
 leftfl |= 1;
227
227
 lmin1=lmin2=255;
228
228
 lmax=0;
229
229
 for (i=0, pfun=l_abr; i< fullh/3; i++,pfun++)
230
230
  {
231
 
   if (lmin1 > *pfun)  { lmin1 = *pfun; lxmin11=(BYTE)i; }
232
 
   if (lmin1 == *pfun)                  lxmin12=(BYTE)i;
 
231
   if (lmin1 > *pfun)  { lmin1 = *pfun; lxmin11=(uchar)i; }
 
232
   if (lmin1 == *pfun)                  lxmin12=(uchar)i;
233
233
  }
234
234
 for (i=fullh-i, pfun=&l_abr[i]; i<fullh; i++,pfun++)
235
235
  {
236
 
   if (lmin2 > *pfun)  { lmin2 = *pfun; lxmin21=(BYTE)i; }
237
 
   if (lmin2 == *pfun)                  lxmin22=(BYTE)i;
 
236
   if (lmin2 > *pfun)  { lmin2 = *pfun; lxmin21=(uchar)i; }
 
237
   if (lmin2 == *pfun)                  lxmin22=(uchar)i;
238
238
  }
239
239
 
240
240
 ljmp=0;  lnmid=255;
242
242
  {
243
243
    if (linh[i] < lnmid) lnmid=linh[i];
244
244
    nb=*pfun;
245
 
    if (lmax < nb) {  lmax=nb; lxmax1=(BYTE)i; }
246
 
    if (lmax == nb)   lxmax2=(BYTE)i;
247
 
    if ((nb > sb) && (ljmp==0))   { ljmp=1; ljmp1=(BYTE)i; }  // 1st right jump
248
 
    if ((nb < sb) && (ljmp > 0))  { ljmp=2; ljmp2=(BYTE)i; }  // last left jump
 
245
    if (lmax < nb) {  lmax=nb; lxmax1=(uchar)i; }
 
246
    if (lmax == nb)   lxmax2=(uchar)i;
 
247
    if ((nb > sb) && (ljmp==0))   { ljmp=1; ljmp1=(uchar)i; }  // 1st right jump
 
248
    if ((nb < sb) && (ljmp > 0))  { ljmp=2; ljmp2=(uchar)i; }  // last left jump
249
249
  }
250
250
}
251
251
 
252
252
void make_right_max()
253
253
{
254
 
 INT i; BYTE *pfun, sb, nb;
 
254
 int16_t i; uchar *pfun, sb, nb;
255
255
 if (rightfl & 1) return;
256
256
 rightfl |= 1;
257
257
 rmin1=rmin2=255;
258
258
 rmax=0;
259
259
 for (i=0, pfun=r_abr; i< fullh/3; i++,pfun++)
260
260
  {
261
 
   if (rmin1 > *pfun)  { rmin1 = *pfun; rxmin11=(BYTE)i; }
262
 
   if (rmin1 == *pfun)                  rxmin12=(BYTE)i;
 
261
   if (rmin1 > *pfun)  { rmin1 = *pfun; rxmin11=(uchar)i; }
 
262
   if (rmin1 == *pfun)                  rxmin12=(uchar)i;
263
263
  }
264
264
 for (i=fullh-i, pfun=&r_abr[i]; i<fullh; i++,pfun++)
265
265
  {
266
 
   if (rmin2 > *pfun)  { rmin2 = *pfun; rxmin21=(BYTE)i; }
267
 
   if (rmin2 == *pfun)                  rxmin22=(BYTE)i;
 
266
   if (rmin2 > *pfun)  { rmin2 = *pfun; rxmin21=(uchar)i; }
 
267
   if (rmin2 == *pfun)                  rxmin22=(uchar)i;
268
268
  }
269
269
 
270
270
 rjmp=0;
271
271
 for (i=rxmin12, pfun=&r_abr[i], sb=*pfun; i<rxmin21; i++, pfun++,sb=nb)
272
272
  {
273
273
    nb=*pfun;
274
 
    if (rmax < nb) {  rmax=nb; rxmax1=(BYTE)i; }
275
 
    if (rmax == nb)   rxmax2=(BYTE)i;
276
 
    if ((nb > sb) && (rjmp==0))   { rjmp=1; rjmp1=(BYTE)i; }  // 1st  left  jump
277
 
    if ((nb < sb) && (rjmp > 0))  { rjmp=2; rjmp2=(BYTE)i; }  // last right jump
 
274
    if (rmax < nb) {  rmax=nb; rxmax1=(uchar)i; }
 
275
    if (rmax == nb)   rxmax2=(uchar)i;
 
276
    if ((nb > sb) && (rjmp==0))   { rjmp=1; rjmp1=(uchar)i; }  // 1st  left  jump
 
277
    if ((nb < sb) && (rjmp > 0))  { rjmp=2; rjmp2=(uchar)i; }  // last right jump
278
278
  }
279
279
}
280
280
 
281
281
void make_top_max()
282
 
{ INT i; BYTE *pfun;
 
282
{ int16_t i; uchar *pfun;
283
283
 if (topfl & 1) return;
284
284
 topfl |= 1;
285
285
 tmin1=tmin2=255;
286
286
 tmax=0;
287
287
 for (i=0, pfun=top; i< fullw/3; i++,pfun++)
288
288
  {
289
 
   if (tmin1 > *pfun)  { tmin1 = *pfun; txmin11=(BYTE)i; }
290
 
   if (tmin1 == *pfun)                  txmin12=(BYTE)i;
 
289
   if (tmin1 > *pfun)  { tmin1 = *pfun; txmin11=(uchar)i; }
 
290
   if (tmin1 == *pfun)                  txmin12=(uchar)i;
291
291
  }
292
292
 for (i=fullw-i; i<fullw; i++,pfun++)
293
293
  {
294
 
   if (tmin2 > *pfun)  { tmin2 = *pfun; txmin21=(BYTE)i; }
295
 
   if (tmin2 == *pfun)                  txmin22=(BYTE)i;
 
294
   if (tmin2 > *pfun)  { tmin2 = *pfun; txmin21=(uchar)i; }
 
295
   if (tmin2 == *pfun)                  txmin22=(uchar)i;
296
296
  }
297
297
 
298
298
 for (i=txmin12, pfun=&top[i]; i<txmin21; i++, pfun++)
299
299
  {
300
 
    if (tmax < *pfun) {  tmax=*pfun; txmax1=(BYTE)i; }
301
 
    if (tmax == *pfun)   txmax2=(BYTE)i;
 
300
    if (tmax < *pfun) {  tmax=*pfun; txmax1=(uchar)i; }
 
301
    if (tmax == *pfun)   txmax2=(uchar)i;
302
302
  }
303
303
}
304
304
 
305
305
 
306
306
void make_bot_max()
307
 
{ INT i; BYTE *pfun;
 
307
{ int16_t i; uchar *pfun;
308
308
 if (botfl & 1) return;
309
309
 botfl |= 1;
310
310
 bmin1=bmin2=255;
311
311
 bmax=0;
312
312
 for (i=0, pfun=bot; i< fullw/3; i++,pfun++)
313
313
  {
314
 
   if (bmin1 > *pfun)  { bmin1 = *pfun; bxmin11=(BYTE)i; }
315
 
   if (bmin1 == *pfun)                  bxmin12=(BYTE)i;
 
314
   if (bmin1 > *pfun)  { bmin1 = *pfun; bxmin11=(uchar)i; }
 
315
   if (bmin1 == *pfun)                  bxmin12=(uchar)i;
316
316
  }
317
317
 for (i=fullw-i; i<fullw; i++,pfun++)
318
318
  {
319
 
   if (bmin2 > *pfun)  { bmin2 = *pfun; bxmin21=(BYTE)i; }
320
 
   if (bmin2 == *pfun)                  bxmin22=(BYTE)i;
 
319
   if (bmin2 > *pfun)  { bmin2 = *pfun; bxmin21=(uchar)i; }
 
320
   if (bmin2 == *pfun)                  bxmin22=(uchar)i;
321
321
  }
322
322
 
323
323
 for (i=bxmin12, pfun=&bot[i]; i<bxmin21; i++, pfun++)
324
324
  {
325
 
    if (bmax < *pfun) {  bmax=*pfun; bxmax1=(BYTE)i; }
326
 
    if (bmax == *pfun)   bxmax2=(BYTE)i;
 
325
    if (bmax < *pfun) {  bmax=*pfun; bxmax1=(uchar)i; }
 
326
    if (bmax == *pfun)   bxmax2=(uchar)i;
327
327
  }
328
328
}
329
329
 
330
330
void    make_inter_white_histo()
331
331
{
332
 
BYTE i;
 
332
uchar i;
333
333
 
334
334
    histo_max_value = 0;
335
335
    memset( histo, 0, 128 );
342
342
    return;
343
343
}
344
344
 
345
 
BYTE    find_2int_zone( BYTE from, BYTE to, PBYTE beg, PBYTE end )
 
345
uchar    find_2int_zone( uchar from, uchar to, puchar beg, puchar end )
346
346
{
347
 
    BYTE ret_code, i;
348
 
    INT wb, we;
 
347
    uchar ret_code, i;
 
348
    int16_t wb, we;
349
349
    ret_code = NOT_FOUND_TWO_INT_ZONE;
350
350
    wb = we = -1;
351
351
    memset( histo, 0, 128 );
371
371
    if ( we - wb > 1 )
372
372
    {
373
373
        ret_code = FOUND_TWO_INT_ZONE;
374
 
        *beg = (BYTE)wb;
375
 
        *end = (BYTE)(we-1);
 
374
        *beg = (uchar)wb;
 
375
        *end = (uchar)(we-1);
376
376
    }
377
377
    return ret_code;
378
378
}
379
379
 
380
 
 BYTE    find_1int_zone( BYTE from, BYTE to, PBYTE beg, PBYTE end )
 
380
 uchar    find_1int_zone( uchar from, uchar to, puchar beg, puchar end )
381
381
{
382
 
    BYTE ret_code, i;
383
 
    INT wb, we;
 
382
    uchar ret_code, i;
 
383
    int16_t wb, we;
384
384
    ret_code = NOT_FOUND_ONE_INT_ZONE;
385
385
    wb = we = -1;
386
386
 
387
 
    for ( i = (BYTE)midh; i >= from; i-- )
 
387
    for ( i = (uchar)midh; i >= from; i-- )
388
388
    {
389
389
        if ( (linh[i] == 1) ||
390
390
             ( (linh[i] == 2) && (linh[i-1] == 1) &&
396
396
            break;
397
397
         }
398
398
    }
399
 
    for ( i = (BYTE)midh; i <= to; i++ )
 
399
    for ( i = (uchar)midh; i <= to; i++ )
400
400
    {
401
401
        if ( linh[i] == 1 )
402
402
            we = i;
408
408
    if ( we - wb >= ( (fullh + 9)/10 ) )
409
409
    {
410
410
        ret_code = FOUND_ONE_INT_ZONE;
411
 
        *beg = (BYTE)wb;
412
 
        *end = (BYTE)we;
 
411
        *beg = (uchar)wb;
 
412
        *end = (uchar)we;
413
413
    }
414
414
F1Z_Ret:
415
415
    return ret_code;
416
416
}
417
417
 
418
 
BYTE r_tail ( BYTE lev)
 
418
uchar r_tail ( uchar lev)
419
419
{
420
 
BYTE xtail=0, ltail, j, fl, tresh;
 
420
uchar xtail=0, ltail, j, fl, tresh;
421
421
 ltail = fullh / 5;
422
422
 
423
423
 for ( j = fullw -1; j >= midw; j--)
435
435
 tresh = fullw/10;
436
436
 if ( tresh > 0 )
437
437
    tresh--;
438
 
 fl = monotonous_decrease( l_abr, 1, (BYTE)(fullh - (fullh/4)), &j, tresh );
 
438
 fl = monotonous_decrease( l_abr, 1, (uchar)(fullh - (fullh/4)), &j, tresh );
439
439
 if ( fl == NOT_FOUND_MON_DECR )
440
440
    return 0;
441
441
 if ( top[fullw -1] > 3 )
442
442
    return 0;
443
 
 fl = monotonous_increase( r_abr, top[fullw -1], (BYTE)(fullh - 1), &j, 0 );
 
443
 fl = monotonous_increase( r_abr, top[fullw -1], (uchar)(fullh - 1), &j, 0 );
444
444
 if ( fl != NOT_FOUND_MON_INCR )
445
445
    return 0;
446
 
 fl = monotonous_increase( r_abr, (BYTE)(j + 2), (BYTE)(fullh - 1), &ltail, 0 );
 
446
 fl = monotonous_increase( r_abr, (uchar)(j + 2), (uchar)(fullh - 1), &ltail, 0 );
447
447
 if ( fl == FOUND_MON_INCR )
448
448
    return 1;
449
449
 return 0;
450
450
}
451
451
 
452
452
 
453
 
BYTE rb_corner()
 
453
uchar rb_corner()
454
454
{
455
455
#define PNL_ROUND_RBC  10      // Round abris at right bottom corner
456
456
 
457
 
 BYTE pen, shift;
458
 
 INT  fl, i1, i2, i3, i4, j1, j2, j3, j4;
 
457
 uchar pen, shift;
 
458
 int16_t  fl, i1, i2, i3, i4, j1, j2, j3, j4;
459
459
 
460
460
 make_right_max();
461
461
 i1=fullh-1; i2=i1-1; i3=i2-1; i4=i3-1;
493
493
 return pen;
494
494
}
495
495
 
496
 
BYTE a_rb_corner( INT cur_p )
 
496
uchar a_rb_corner( int16_t cur_p )
497
497
{
498
 
INT pnl_rbc, newprob;
 
498
int16_t pnl_rbc, newprob;
499
499
 
500
500
 pnl_rbc = rb_corner();
501
501
 if ( linh[fullh-2] == 2 )          // the bottom abris likes letter 'a'
504
504
 
505
505
 if (newprob <= 0 )
506
506
  newprob = 2;
507
 
 return( (BYTE)newprob );
 
507
 return( (uchar)newprob );
508
508
}
509
509
 
510
 
BYTE round_rb_corner()
 
510
uchar round_rb_corner()
511
511
{
512
512
#define PNL_NOT_ROUND_RBC  10      // Penalty for not round
513
513
                                   //  abris at right bottom corner
514
514
 
515
 
 BYTE pen;
516
 
 INT  st, bnd, prev, cur;
 
515
 uchar pen;
 
516
 int16_t  st, bnd, prev, cur;
517
517
 
518
518
 pen = 0;
519
519
 bnd = fullh - (fullh >> 2) - 1;
535
535
 return pen;
536
536
}
537
537
 
538
 
 BYTE test_bottom_corner( PBYTE abris, INT *size)
 
538
 uchar test_bottom_corner( puchar abris, int16_t *size)
539
539
{
540
540
 
541
 
 BYTE type;
542
 
 INT  pen, convex_st, concave_st, bnd, prev, cur;
 
541
 uchar type;
 
542
 int16_t  pen, convex_st, concave_st, bnd, prev, cur;
543
543
 
544
544
 pen = 0; type = 0;
545
545
 bnd = fullh - (fullh >> 2) - 1;
587
587
  return type;
588
588
}
589
589
 
590
 
INT two_int_over_b2 ( cell *curc, INT *loc_2_int)
 
590
int16_t two_int_over_b2 ( cell *curc, int16_t *loc_2_int)
591
591
// This procedure determines the apperance two black intervals near 2nd base
592
592
// This procedure is used by discriminaters of follow letters: 'b', 'h' and 'd'
593
593
{
594
 
INT twoint, retpen, h14, i;
595
 
BYTE  shift_from_top;
 
594
int16_t twoint, retpen, h14, i;
 
595
uchar  shift_from_top;
596
596
 
597
597
 retpen = 0;
598
598
 twoint = -1;
641
641
 return retpen;
642
642
}
643
643
 
644
 
 INT Let_bint_index( CHAR Let )
 
644
 int16_t Let_bint_index( char Let )
645
645
{
646
646
 switch (Let)
647
647
  {
657
657
}
658
658
 
659
659
#define GAP_MAX_SIZE 128
660
 
 INT gap_in_side(
661
 
       BYTE from, BYTE to, BYTE code_func, INT tresh, BYTE *flit)
 
660
 int16_t gap_in_side(
 
661
       uchar from, uchar to, uchar code_func, int16_t tresh, uchar *flit)
662
662
{
663
 
INT retgap;
664
 
BYTE fmax, fmin, xmax, xmin, i;
665
 
BYTE *func;
 
663
int16_t retgap;
 
664
uchar fmax, fmin, xmax, xmin, i;
 
665
uchar *func;
666
666
 
667
667
   *flit = 0; retgap = 0;
668
668
   switch ( code_func )
724
724
  return retgap;
725
725
}
726
726
 
727
 
void get_max_min ( PBYTE func, BYTE from, BYTE to,
728
 
                     PBYTE fmax, PBYTE fmin, PBYTE x_fmax, PBYTE x_fmin )
 
727
void get_max_min ( puchar func, uchar from, uchar to,
 
728
                     puchar fmax, puchar fmin, puchar x_fmax, puchar x_fmin )
729
729
{
730
 
BYTE i;
 
730
uchar i;
731
731
 
732
732
   for ( i=from, *fmax=0, *fmin=255; i < to; i++ )
733
733
    // find extremum onto interval (from, to) of the func:
739
739
    return;
740
740
}
741
741
 
742
 
 BYTE constancy_vally_lth (PBYTE func, BYTE from, BYTE to, BYTE tresh)
 
742
 uchar constancy_vally_lth (puchar func, uchar from, uchar to, uchar tresh)
743
743
{
744
 
BYTE i, cvlth, fl, beg, end;
 
744
uchar i, cvlth, fl, beg, end;
745
745
 
746
746
   cvlth = 0; fl = 0; beg = 0; end = 0;
747
747
   for ( i = from + 1; i < to - 1; i++, fl = 0 )
775
775
   return cvlth;
776
776
}
777
777
 
778
 
BYTE monotonous_decrease
779
 
        ( PBYTE func, BYTE from, BYTE to, PBYTE last_decr, BYTE tresh)
 
778
uchar monotonous_decrease
 
779
        ( puchar func, uchar from, uchar to, puchar last_decr, uchar tresh)
780
780
{
781
 
INT  delta;
782
 
BYTE ret_code, smooth_sum, i;
 
781
int16_t  delta;
 
782
uchar ret_code, smooth_sum, i;
783
783
 
784
784
    ret_code = FOUND_MON_DECR;
785
785
    for ( smooth_sum = 0, i = from; i < to - 1; i++ )
799
799
    return ret_code;
800
800
}
801
801
 
802
 
 BYTE monotonous_increase
803
 
        ( PBYTE func, BYTE from, BYTE to, PBYTE last_incr, BYTE tresh)
 
802
 uchar monotonous_increase
 
803
        ( puchar func, uchar from, uchar to, puchar last_incr, uchar tresh)
804
804
{
805
 
INT  delta;
806
 
BYTE ret_code, smooth_sum, i;
 
805
int16_t  delta;
 
806
uchar ret_code, smooth_sum, i;
807
807
 
808
808
    ret_code = FOUND_MON_INCR;
809
809
    for ( smooth_sum = 0, i = from; i < to - 1; i++ )
823
823
    return ret_code;
824
824
}
825
825
 
826
 
 INT top_end_bottom_weights_delta()
 
826
 int16_t top_end_bottom_weights_delta()
827
827
{
828
 
BYTE i, wto, wfrom;
829
 
INT  delta, wi, bot_sum, top_sum;
 
828
uchar i, wto, wfrom;
 
829
int16_t  delta, wi, bot_sum, top_sum;
830
830
 
831
831
    wi = 1;
832
832
    wto = midh - 1;
834
834
    if ( (fullh & wi) == 1 )      // fullh is odd
835
835
        wfrom = midh + 1;
836
836
    else                          // fullh is even
837
 
        wfrom = (BYTE)midh;
 
837
        wfrom = (uchar)midh;
838
838
 
839
839
    for ( top_sum = 0, i = 0; i <= wto; i++ )
840
840
        top_sum += sumh[i];
847
847
 
848
848
}
849
849
 
850
 
 BYTE new_prob( INT penalty )
 
850
 uchar new_prob( int16_t penalty )
851
851
{
852
 
BYTE ret_prob;
853
 
INT wprob;
 
852
uchar ret_prob;
 
853
int16_t wprob;
854
854
 
855
855
 wprob = cprob - penalty;
856
856
 if ( wprob < 2 )
857
857
  ret_prob = 2;
858
858
 else
859
 
  ret_prob = (BYTE)wprob;
 
859
  ret_prob = (uchar)wprob;
860
860
 return ret_prob;
861
861
}
862
862
 
863
 
void construct_line_by_two_points( BYTE x1, BYTE y1, BYTE x2, BYTE y2 )
 
863
void construct_line_by_two_points( uchar x1, uchar y1, uchar x2, uchar y2 )
864
864
{
865
865
    x_beg   = MLTPLR * x1;
866
866
    y_beg   = MLTPLR * y1;
873
873
    return;
874
874
}
875
875
 
876
 
INT get_x_coord( BYTE y_coord )
 
876
int16_t get_x_coord( uchar y_coord )
877
877
{
878
 
        INT xc;
 
878
        int16_t xc;
879
879
        //AK! add for no divide by zerro
880
880
                if ( delta_y )
881
881
                                        xc = x_beg + orient * ( (( (y_coord * MLTPLR) - y_beg ) * delta_x ) / delta_y );
884
884
                return xc;
885
885
}
886
886
 
887
 
BYTE test_against_convex( PBYTE func, BYTE from, BYTE to )
 
887
uchar test_against_convex( puchar func, uchar from, uchar to )
888
888
{
889
 
INT  x, i, dx;
890
 
BYTE pen, cnt;
891
 
LONG    total;
 
889
int16_t  x, i, dx;
 
890
uchar pen, cnt;
 
891
int32_t    total;
892
892
 
893
893
    pen = 0;
894
894
    total = 0;
895
895
    construct_line_by_two_points( func[from], from, func[to], to );
896
896
    for ( cnt = 0, i = from; i <= to; i++ )
897
897
    {
898
 
        x = get_x_coord( (BYTE)i );
 
898
        x = get_x_coord( (uchar)i );
899
899
        if ( ( dx = abs(x - (MLTPLR * func[i])) ) > 0 )
900
900
        {
901
901
            total += dx;