~ubuntu-branches/ubuntu/trusty/cuneiform/trusty

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/dif/src/sticchar.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:
85
85
        }
86
86
 
87
87
//////////////////////Functions prototypes///////////////////////////
88
 
Int16 set_stick_char (Word8 left[], Word8 right[], Int16 hooks[],
89
 
       Int16 dy, Int16 dx, Int16 opt, Int16 wide, Int16 corr_mode,
90
 
       Int16 skip_ul, Int16 skip_dl, Int16 skip_ur, Int16 skip_dr,
91
 
       Int16 inc_num,
 
88
int16_t set_stick_char (uchar left[], uchar right[], int16_t hooks[],
 
89
       int16_t dy, int16_t dx, int16_t opt, int16_t wide, int16_t corr_mode,
 
90
       int16_t skip_ul, int16_t skip_dl, int16_t skip_ur, int16_t skip_dr,
 
91
       int16_t inc_num,
92
92
                   STICK_CHARS *l, STICK_CHARS *r, STICK_SIGNUMS *s,
93
 
       Int16 *l_mode, Int16 *r_mode);
94
 
static Int16 fun_ge(Word8 fun[],Int16 n, Int16 level);
95
 
static Int16 fun_le(Word8 fun[],Int16 n, Int16 level);
96
 
static void calc_chars (STICK_CHARS *res, Int16 level, Int16 typ,
97
 
          Word8 fun[], Int16 n, Int16 skip_u, Int16 skip_d);
98
 
static Int16 study_nose_1(Word8 left[],Int16 n,Int16 level, Int16 width);
99
 
static void set_serifs(Word8 left[],Word8 right[],
100
 
                       STICK_CHARS *left_chars,STICK_CHARS *right_chars,
101
 
           Int16 skip_ul,Int16 skip_dl,Int16 skip_ur,Int16 skip_dr,
102
 
           Int16 l,Int16 r,Int16 dy,Int16 dx);
103
 
static void correct_serifs(Word8 left[],Word8 right[],
104
 
                       STICK_CHARS *left_chars,STICK_CHARS *right_chars,
105
 
           Int16 skip_ul,Int16 skip_dl,Int16 skip_ur,Int16 skip_dr,
106
 
           Int16 l,Int16 r,Int16 dy);
107
 
static Int16 correct_beam(STICK_CHARS *l, STICK_CHARS *r,Int16 lev,Int16 dist);
108
 
static Int16 correct_neck(STICK_CHARS *l, STICK_CHARS *r,Int16 lev,Int16 dist);
109
 
static void num_flag_conc (STICK_CHARS *res, Int16 width);
110
 
static void set_near ( Word8 fun[], Int16 skip_u, Int16 skip_d,
111
 
       Int16 n_full, Int16 lev, Int16 lim[],
112
 
       Int16 left[], Int16 right[], Int16 l_pos[], Int16 r_pos[],
113
 
       Int16 lb_pos[], Int16 le_pos[], Int16 rb_pos[], Int16 re_pos[],
114
 
       Int16 *sum_l_near_int, Int16 *sum_r_near_int);
115
 
static Int16 set_flags (STICK_CHARS *res, Int16 right[], Int16 left[],
116
 
         Int16 r_pos[], Int16 l_pos[],
117
 
         Int16 mb_pos[], Int16 me_pos[],Int16 cb_pos[], Int16 ce_pos[],
118
 
         Int16 sum_r, Int16 sum_l, Int16 ear);
119
 
static Int16 compress4(Int16 v);
120
 
static void set_long(Word8 fun[],Int16 skip_u,Int16 skip_d,Int16 n,
121
 
        Int16 lev,Int16 lim[], Int16 sl, Int16 sr,
122
 
        Int16 left[],Int16 right[],Int16 l_pos[],Int16 r_pos[],
123
 
              Int16 lb_pos[],Int16 le_pos[],Int16 rb_pos[],Int16 re_pos[],
124
 
        Int16 *ll,Int16 *rr);
125
 
static Int16 correct_two_zones(Int16 *kk,Int16 *mm,Int16 i,Int16 imax,Int16 extr_pos,
126
 
         Int16 lim[]);
127
 
static Int16 index_arr(Int16 v,Int16 limit[],Int16 n);
128
 
static void find_peak_new (Int16 *ind1, Int16 *ind2, Word8 fun[], Int16 nn,
129
 
  Int16 level, Int16 sr, Int16 *extr_pos, Word8 *extr_fun);
130
 
static Int16 typ_nose_1(Word8 left[],Int16 n,Int16 lim,Int16 lev);
131
 
static Bool16 find_first_ne(Word8 fun[],Int16 n,Int16 direct,Int16 level);
132
 
static void find_conc_new (Int16 *ind1, Int16 *ind2, Word8 fun[], Int16 nn,
133
 
  Int16 level, Int16 sl, Int16 *extr_pos, Word8 *extr_fun);
 
93
       int16_t *l_mode, int16_t *r_mode);
 
94
static int16_t fun_ge(uchar fun[],int16_t n, int16_t level);
 
95
static int16_t fun_le(uchar fun[],int16_t n, int16_t level);
 
96
static void calc_chars (STICK_CHARS *res, int16_t level, int16_t typ,
 
97
          uchar fun[], int16_t n, int16_t skip_u, int16_t skip_d);
 
98
static int16_t study_nose_1(uchar left[],int16_t n,int16_t level, int16_t width);
 
99
static void set_serifs(uchar left[],uchar right[],
 
100
                       STICK_CHARS *left_chars,STICK_CHARS *right_chars,
 
101
           int16_t skip_ul,int16_t skip_dl,int16_t skip_ur,int16_t skip_dr,
 
102
           int16_t l,int16_t r,int16_t dy,int16_t dx);
 
103
static void correct_serifs(uchar left[],uchar right[],
 
104
                       STICK_CHARS *left_chars,STICK_CHARS *right_chars,
 
105
           int16_t skip_ul,int16_t skip_dl,int16_t skip_ur,int16_t skip_dr,
 
106
           int16_t l,int16_t r,int16_t dy);
 
107
static int16_t correct_beam(STICK_CHARS *l, STICK_CHARS *r,int16_t lev,int16_t dist);
 
108
static int16_t correct_neck(STICK_CHARS *l, STICK_CHARS *r,int16_t lev,int16_t dist);
 
109
static void num_flag_conc (STICK_CHARS *res, int16_t width);
 
110
static void set_near ( uchar fun[], int16_t skip_u, int16_t skip_d,
 
111
       int16_t n_full, int16_t lev, int16_t lim[],
 
112
       int16_t left[], int16_t right[], int16_t l_pos[], int16_t r_pos[],
 
113
       int16_t lb_pos[], int16_t le_pos[], int16_t rb_pos[], int16_t re_pos[],
 
114
       int16_t *sum_l_near_int, int16_t *sum_r_near_int);
 
115
static int16_t set_flags (STICK_CHARS *res, int16_t right[], int16_t left[],
 
116
         int16_t r_pos[], int16_t l_pos[],
 
117
         int16_t mb_pos[], int16_t me_pos[],int16_t cb_pos[], int16_t ce_pos[],
 
118
         int16_t sum_r, int16_t sum_l, int16_t ear);
 
119
static int16_t compress4(int16_t v);
 
120
static void set_long(uchar fun[],int16_t skip_u,int16_t skip_d,int16_t n,
 
121
        int16_t lev,int16_t lim[], int16_t sl, int16_t sr,
 
122
        int16_t left[],int16_t right[],int16_t l_pos[],int16_t r_pos[],
 
123
              int16_t lb_pos[],int16_t le_pos[],int16_t rb_pos[],int16_t re_pos[],
 
124
        int16_t *ll,int16_t *rr);
 
125
static int16_t correct_two_zones(int16_t *kk,int16_t *mm,int16_t i,int16_t imax,int16_t extr_pos,
 
126
         int16_t lim[]);
 
127
static int16_t index_arr(int16_t v,int16_t limit[],int16_t n);
 
128
static void find_peak_new (int16_t *ind1, int16_t *ind2, uchar fun[], int16_t nn,
 
129
  int16_t level, int16_t sr, int16_t *extr_pos, uchar *extr_fun);
 
130
static int16_t typ_nose_1(uchar left[],int16_t n,int16_t lim,int16_t lev);
 
131
static Bool16 find_first_ne(uchar fun[],int16_t n,int16_t direct,int16_t level);
 
132
static void find_conc_new (int16_t *ind1, int16_t *ind2, uchar fun[], int16_t nn,
 
133
  int16_t level, int16_t sl, int16_t *extr_pos, uchar *extr_fun);
134
134
///////////////////////////////////////////////////////////////////////////
135
135
 
136
 
static Word8 tab_1[]=
 
136
static uchar tab_1[]=
137
137
        {
138
138
        120,    // 0. no left upper flag and left mode > 0
139
139
        80,     // 1. too down begin of nose
147
147
//////  12      // 9. MK: VERT FLAT NOSE (first 48, sec.12); PROBA 31.05.1993
148
148
        };
149
149
 
150
 
Int16 set_stick_char (Word8 left[], Word8 right[], Int16 hooks[],
151
 
       Int16 dy, Int16 dx, Int16 opt, Int16 wide, Int16 corr_mode,
152
 
       Int16 skip_ul, Int16 skip_dl, Int16 skip_ur, Int16 skip_dr,
153
 
//////       Int16 inc,
154
 
       Int16 inc_num,   // 10.12.1993
 
150
int16_t set_stick_char (uchar left[], uchar right[], int16_t hooks[],
 
151
       int16_t dy, int16_t dx, int16_t opt, int16_t wide, int16_t corr_mode,
 
152
       int16_t skip_ul, int16_t skip_dl, int16_t skip_ur, int16_t skip_dr,
 
153
//////       int16_t inc,
 
154
       int16_t inc_num,   // 10.12.1993
155
155
//////             STICK_CHARS *left_chars, STICK_CHARS *right_chars,
156
156
//////             STICK_SIGNUMS *signums,
157
157
                   STICK_CHARS *l, STICK_CHARS *r, STICK_SIGNUMS *s,
158
 
       Int16 *l_mode, Int16 *r_mode)
 
158
       int16_t *l_mode, int16_t *r_mode)
159
159
{
160
 
//////Int16 l,r;
161
 
Int16 lm, rm;
162
 
Int16 lll_dis;
 
160
//////int16_t l,r;
 
161
int16_t lm, rm;
 
162
int16_t lll_dis;
163
163
 
164
164
memset(s, 0 , sizeof(STICK_SIGNUMS));
165
165
rm = opt + (wide<<1) - 2;       /* right mode */
166
166
if( rm%4 )
167
167
        {
168
168
        rm = ((rm>>2)<<2)+2 ;  /* step = 2 */
169
 
        if( fun_ge(right,dy,(Int16)(rm-2))<fun_le(right,dy,(Int16)(rm+2)) )
 
169
        if( fun_ge(right,dy,(int16_t)(rm-2))<fun_le(right,dy,(int16_t)(rm+2)) )
170
170
                rm += 2;      /* select column (rm-2),(rm+2) */
171
171
        else
172
172
                rm -= 2;
181
181
//////  if( fun_ge(left,dy,l-2)<fun_le(left,dy,lm+2) )  // BEFORE 01.02.1993
182
182
//mkm3 =        fun_ge(left,dy,lm-2)<<8; //////////////////////////////////////
183
183
//mkm3 |=       fun_le(left,dy,lm+2);   /////////////////////////////////////////////
184
 
        if( fun_ge(left,dy,(Int16)(lm-2)) <= fun_le(left,dy,(Int16)(lm+2))+1 )  // 01.02.1993
 
184
        if( fun_ge(left,dy,(int16_t)(lm-2)) <= fun_le(left,dy,(int16_t)(lm+2))+1 )      // 01.02.1993
185
185
                lm += 2;    /* select black column */
186
186
        else
187
187
                lm -= 2;
198
198
s->lll_nose_1 = lll_dis >> 8;           // 00xx or 01xx => 0 or 1
199
199
s->dis_nose_1 = lll_dis & 0xFF;
200
200
 
201
 
s->typ_nose_1 = (Word8)typ_nose_1(left,dy,(Int16)((wide>4)?4:2),lm);
 
201
s->typ_nose_1 = (uchar)typ_nose_1(left,dy,(int16_t)((wide>4)?4:2),lm);
202
202
        /* typ_nose_1 - indicator normal (inc) nose 1 */
203
203
 
204
204
l->up_hook    = (hooks[0]>1);   /* hooks-signums ex. right down : */
205
 
l->down_hook  = (hooks[1]>1);   /*   �                            */
206
 
r->up_hook   = (hooks[2]>1);    /*   �  �                         */
207
 
r->down_hook = (hooks[3]>1);    /*   ����                         */
 
205
l->down_hook  = (hooks[1]>1);   /*   °                            */
 
206
r->up_hook   = (hooks[2]>1);    /*   °  °                         */
 
207
r->down_hook = (hooks[3]>1);    /*   °°°°                         */
208
208
 
209
 
s->height = (Word8)dy;
 
209
s->height = (uchar)dy;
210
210
s->width  = dx;
211
 
s->stick_width  =(Word8) wide;
 
211
s->stick_width  =(uchar) wide;
212
212
 
213
213
/*****************************  BEFORE 10.12.1993:
214
214
//////s->inc    = inc;          // before 03.06.1993
218
218
********************************/
219
219
 
220
220
s->inc = (inc_num!=0);
221
 
s->inc_num = (Int8)inc_num;     // 10.12.1993
 
221
s->inc_num = (char)inc_num;     // 10.12.1993
222
222
 
223
223
/* serifs checking */
224
224
set_serifs (left, right, l, r,
226
226
correct_serifs (left, right, l, r,
227
227
                skip_ul, skip_dl, skip_ur, skip_dr, lm, rm, dy);
228
228
 
229
 
if( !correct_beam(l,r,(Int16)(dy>9?dy/10:1),1) )
230
 
        correct_beam (l, r,(Int16)( dy>19 ? dy/10 : 2 ), 0);
 
229
if( !correct_beam(l,r,(int16_t)(dy>9?dy/10:1),1) )
 
230
        correct_beam (l, r,(int16_t)( dy>19 ? dy/10 : 2 ), 0);
231
231
 
232
232
correct_neck (l, r, 2, 0);
233
233
 
238
238
///*l_mode = left_mode_EEM = (lm-corr_mode)>>2; // 05.08.1993   SOPLI I WOPLI
239
239
///*r_mode = (rm-corr_mode)>>2;
240
240
    *l_mode = (lm-corr_mode)>>2;        // 07.01.1994
241
 
    s->left_mode  = (Word8)*l_mode;
 
241
    s->left_mode  = (uchar)*l_mode;
242
242
    *r_mode = (rm-corr_mode)>>2;
243
 
    s->right_mode =(Word8) *r_mode;
 
243
    s->right_mode =(uchar) *r_mode;
244
244
//////s->full_width = l->max_flag + wide + r->max_flag; // 07.01.1994   ###
245
245
s->full_width = (s->right_mode - s->left_mode + 1) +    // 07.01.1994
246
246
                l->max_flag + r->max_flag;
249
249
}
250
250
 
251
251
 
252
 
static Int16 fun_ge(Word8 fun[],Int16 n, Int16 level)
 
252
static int16_t fun_ge(uchar fun[],int16_t n, int16_t level)
253
253
{
254
 
Int16 i,s,f;
 
254
int16_t i,s,f;
255
255
for(s=i=0;i<n;i++)
256
256
        {
257
257
        f=fun[i];
260
260
return(s);
261
261
}
262
262
 
263
 
static Int16 fun_le(Word8 fun[],Int16 n, Int16 level)
 
263
static int16_t fun_le(uchar fun[],int16_t n, int16_t level)
264
264
{
265
 
Int16 i,s,f;
 
265
int16_t i,s,f;
266
266
for(s=i=0;i<n;i++)
267
267
        {
268
268
        f=fun[i];
271
271
return(s);
272
272
}
273
273
 
274
 
static void calc_chars (STICK_CHARS *res, Int16 level, Int16 typ,
275
 
          Word8 fun[], Int16 n, Int16 skip_u, Int16 skip_d)
 
274
static void calc_chars (STICK_CHARS *res, int16_t level, int16_t typ,
 
275
          uchar fun[], int16_t n, int16_t skip_u, int16_t skip_d)
276
276
{
277
277
#define SIZ 6
278
 
Int16 r, l, sr=2, sl=2, sum_r, sum_l;
279
 
Int16 left[5],  l_pos[5], lb_pos[5], le_pos[5];
280
 
Int16 right[5], r_pos[5], rb_pos[5], re_pos[5];
281
 
Int16 lim[SIZ];
 
278
int16_t r, l, sr=2, sl=2, sum_r, sum_l;
 
279
int16_t left[5],  l_pos[5], lb_pos[5], le_pos[5];
 
280
int16_t right[5], r_pos[5], rb_pos[5], re_pos[5];
 
281
int16_t lim[SIZ];
282
282
 
283
283
if( level<0 )
284
284
        level = 0;
308
308
                left, right, l_pos, r_pos,
309
309
                lb_pos, le_pos, rb_pos, re_pos, &l, &r);
310
310
 
311
 
        /*                    �                */
312
 
        /*                    �                */
313
 
        /*     left[]         �     right[]    */
314
 
        /*                    �                */
315
 
        /*                    �                */
 
311
        /*                    і                */
 
312
        /*                    і                */
 
313
        /*     left[]         і     right[]    */
 
314
        /*                    і                */
 
315
        /*                    і                */
316
316
        /*                  level              */
317
317
        /*     right :  conc       mount       */
318
318
        /*     left  :  mount      conc        */
329
329
return;
330
330
}
331
331
 
332
 
static Int16 study_nose_1(Word8 left[],Int16 n,Int16 level, Int16 width)
 
332
static int16_t study_nose_1(uchar left[],int16_t n,int16_t level, int16_t width)
333
333
{
334
 
Int16  i = -1, ii, nn=n>>1, dis=0 ,minim, imin  ,s , lmin ;
 
334
int16_t  i = -1, ii, nn=n>>1, dis=0 ,minim, imin  ,s , lmin ;
335
335
 
336
336
if( level==0 )
337
337
        return(0);                                              // 0000 !!!
422
422
return( dis );
423
423
}
424
424
 
425
 
static void set_serifs(Word8 left[],Word8 right[],
 
425
static void set_serifs(uchar left[],uchar right[],
426
426
                       STICK_CHARS *left_chars,STICK_CHARS *right_chars,
427
 
           Int16 skip_ul,Int16 skip_dl,Int16 skip_ur,Int16 skip_dr,
428
 
           Int16 l,Int16 r,Int16 dy,Int16 dx)
 
427
           int16_t skip_ul,int16_t skip_dl,int16_t skip_ur,int16_t skip_dr,
 
428
           int16_t l,int16_t r,int16_t dy,int16_t dx)
429
429
{
430
 
Int16 l1,l2,r1,r2,dy_u=dy/6,dy_d=dy-1-dy/6,d=(dx-1)<<2;
 
430
int16_t l1,l2,r1,r2,dy_u=dy/6,dy_d=dy-1-dy/6,d=(dx-1)<<2;
431
431
 
432
432
r1 = MIN(r+4,d); r2 = MIN(r+8,d); /* r1-one,r2-two step in right direct */
433
433
if( r1==r2 )
477
477
return;
478
478
}
479
479
 
480
 
static void correct_serifs(Word8 left[],Word8 right[],
 
480
static void correct_serifs(uchar left[],uchar right[],
481
481
                       STICK_CHARS *left_chars,STICK_CHARS *right_chars,
482
 
           Int16 skip_ul,Int16 skip_dl,Int16 skip_ur,Int16 skip_dr,
483
 
           Int16 l,Int16 r,Int16 dy)
 
482
           int16_t skip_ul,int16_t skip_dl,int16_t skip_ur,int16_t skip_dr,
 
483
           int16_t l,int16_t r,int16_t dy)
484
484
{
485
 
Int16 dy_u=dy/6;
 
485
int16_t dy_u=dy/6;
486
486
 
487
487
/* right upper serif */
488
488
if( left_chars->up_serif==2 && right_chars->up_serif==0 )
534
534
return;
535
535
}
536
536
 
537
 
static Int16 correct_beam(STICK_CHARS *l, STICK_CHARS *r,Int16 lev,Int16 dist)
 
537
static int16_t correct_beam(STICK_CHARS *l, STICK_CHARS *r,int16_t lev,int16_t dist)
538
538
{
539
 
Int16 i,lm,rm,lmn,rmn,t,dist1=MAX(dist,1);
 
539
int16_t i,lm,rm,lmn,rmn,t,dist1=MAX(dist,1);
540
540
for(i=0;i<2;i++) /* study zones 0,1,2 */
541
541
        {
542
542
        lm  = l->mount[i];      rm  = r->mount[i];
586
586
return(0);
587
587
}
588
588
 
589
 
static Int16 correct_neck(STICK_CHARS *l, STICK_CHARS *r,Int16 lev,Int16 dist)
 
589
static int16_t correct_neck(STICK_CHARS *l, STICK_CHARS *r,int16_t lev,int16_t dist)
590
590
{
591
 
Int16 i,lm,rm,lmn,rmn;
 
591
int16_t i,lm,rm,lmn,rmn;
592
592
for(i=0;i<2;i++) /* study zones 0,1,2 */
593
593
        {
594
594
        lm  = l->conc[i];       rm  = r->conc[i];
636
636
return(0);
637
637
}
638
638
 
639
 
static void num_flag_conc (STICK_CHARS *res, Int16 width)
 
639
static void num_flag_conc (STICK_CHARS *res, int16_t width)
640
640
{
641
 
Int16 i, t, sc, sf, n;
642
 
Int16 max_flag=0;
 
641
int16_t i, t, sc, sf, n;
 
642
int16_t max_flag=0;
643
643
for (sc=sf=n=i=0; i<5 ;i++)
644
644
        {
645
645
        if(res->mount[i]>0 )
659
659
        if(res->mount[i]>t)
660
660
                n++;
661
661
 
662
 
res -> num_flags =(Word8) sf;          /* number of flags      */
663
 
res -> num_concs =(Word8) sc;          /* number of concaves   */
664
 
res -> num_long_flags = (Word8) n;      /* number of long flags */
665
 
res -> max_flag =(Word8) max_flag;      // 06.01.1994
 
662
res -> num_flags =(uchar) sf;          /* number of flags      */
 
663
res -> num_concs =(uchar) sc;          /* number of concaves   */
 
664
res -> num_long_flags = (uchar) n;      /* number of long flags */
 
665
res -> max_flag =(uchar) max_flag;      // 06.01.1994
666
666
 
667
667
return;
668
668
}
669
669
 
670
 
static void set_near ( Word8 fun[], Int16 skip_u, Int16 skip_d,
671
 
//////       Int16 n, Int16 lev, Int16 lim[],
672
 
       Int16 n_full, Int16 lev, Int16 lim[],
673
 
       Int16 left[], Int16 right[], Int16 l_pos[], Int16 r_pos[],
674
 
       Int16 lb_pos[], Int16 le_pos[], Int16 rb_pos[], Int16 re_pos[],
675
 
       Int16 *sum_l_near_int, Int16 *sum_r_near_int)
 
670
static void set_near ( uchar fun[], int16_t skip_u, int16_t skip_d,
 
671
//////       int16_t n, int16_t lev, int16_t lim[],
 
672
       int16_t n_full, int16_t lev, int16_t lim[],
 
673
       int16_t left[], int16_t right[], int16_t l_pos[], int16_t r_pos[],
 
674
       int16_t lb_pos[], int16_t le_pos[], int16_t rb_pos[], int16_t re_pos[],
 
675
       int16_t *sum_l_near_int, int16_t *sum_r_near_int)
676
676
{                                                       // 28.01.1994
677
677
                                // NOTA BAENE: 28.01.1994 LEMAN call to OLEG;
678
678
                                // CHANGE  "n"  to  "n_full"  (BBB)
679
679
                                // and USE NOW  "nn"  ONLY!!!
680
680
                                // (TAK GOVORIL ZARATUSTRA)
681
 
Int16 i, k, b, e, ex,  nn = n_full - skip_d;
682
 
Word8  level=(Word8)lev, f; // NB: Int16 lev, Word8 level;
683
 
Int16 nL, nR;   // 28.01.1994 (OLD l, r);
 
681
int16_t i, k, b, e, ex,  nn = n_full - skip_d;
 
682
uchar  level=(uchar)lev, f; // NB: int16_t lev, uchar level;
 
683
int16_t nL, nR;   // 28.01.1994 (OLD l, r);
684
684
 
685
685
///for (l=r=0,i=skip_u;i<nn;i++) //this cykl find near mounts for any interval:
686
686
for (nL=nR=0,i=skip_u; i<nn; i++)  {                    // 28.01.1994
731
731
return;
732
732
}
733
733
 
734
 
static Int16 set_flags (STICK_CHARS *res, Int16 right[], Int16 left[],
735
 
         Int16 r_pos[], Int16 l_pos[],
736
 
         Int16 mb_pos[], Int16 me_pos[],Int16 cb_pos[], Int16 ce_pos[],
737
 
         Int16 sum_r, Int16 sum_l, Int16 ear)
 
734
static int16_t set_flags (STICK_CHARS *res, int16_t right[], int16_t left[],
 
735
         int16_t r_pos[], int16_t l_pos[],
 
736
         int16_t mb_pos[], int16_t me_pos[],int16_t cb_pos[], int16_t ce_pos[],
 
737
         int16_t sum_r, int16_t sum_l, int16_t ear)
738
738
{
739
 
Int16 i;
 
739
int16_t i;
740
740
 
741
741
for(i=0;i<5;i++)
742
742
        {
743
 
        res->mount[i] = (Word8)compress4(right[i]);
744
 
        res->m_pos[i] = (Word8)r_pos[i];
745
 
        res->mb_pos[i] = (Word8)mb_pos[i];
746
 
        res->me_pos[i] = (Word8)me_pos[i];
 
743
        res->mount[i] = (uchar)compress4(right[i]);
 
744
        res->m_pos[i] = (uchar)r_pos[i];
 
745
        res->mb_pos[i] = (uchar)mb_pos[i];
 
746
        res->me_pos[i] = (uchar)me_pos[i];
747
747
 
748
 
        res->conc[i]  =(Word8) compress4(left[i]);
749
 
        res->c_pos[i] =(Word8) l_pos[i];
750
 
        res->cb_pos[i] = (Word8)cb_pos[i];
751
 
        res->ce_pos[i] =(Word8) ce_pos[i];
 
748
        res->conc[i]  =(uchar) compress4(left[i]);
 
749
        res->c_pos[i] =(uchar) l_pos[i];
 
750
        res->cb_pos[i] = (uchar)cb_pos[i];
 
751
        res->ce_pos[i] =(uchar) ce_pos[i];
752
752
        }
753
 
res->m_meandr = (Word8)sum_r;
754
 
res->c_meandr = (Word8)sum_l;
755
 
res->main_ear = (Word8)ear  ;
 
753
res->m_meandr = (uchar)sum_r;
 
754
res->c_meandr = (uchar)sum_l;
 
755
res->main_ear = (uchar)ear  ;
756
756
 
757
757
return(1);
758
758
}
759
759
 
760
 
static Int16 compress4(Int16 v)
 
760
static int16_t compress4(int16_t v)
761
761
{
762
762
if ( v==0 )                     // 0  1  2  3  4  5  6  7  8  9 10 11  v
763
763
        return(0);              // 0  1  1  1  1  1  2  2  2  2  3  3  OLEG
774
774
return( v );
775
775
}
776
776
 
777
 
static void set_long(Word8 fun[],Int16 skip_u,Int16 skip_d,Int16 n,
778
 
        Int16 lev,Int16 lim[], Int16 sl, Int16 sr,
779
 
        Int16 left[],Int16 right[],Int16 l_pos[],Int16 r_pos[],
780
 
              Int16 lb_pos[],Int16 le_pos[],Int16 rb_pos[],Int16 re_pos[],
781
 
        Int16 *ll,Int16 *rr)
 
777
static void set_long(uchar fun[],int16_t skip_u,int16_t skip_d,int16_t n,
 
778
        int16_t lev,int16_t lim[], int16_t sl, int16_t sr,
 
779
        int16_t left[],int16_t right[],int16_t l_pos[],int16_t r_pos[],
 
780
              int16_t lb_pos[],int16_t le_pos[],int16_t rb_pos[],int16_t re_pos[],
 
781
        int16_t *ll,int16_t *rr)
782
782
{
783
 
Int16 i,k,m,extr,imax,l,r,nn=n-skip_d;
784
 
 Word8 level=(Word8)lev,f;
 
783
int16_t i,k,m,extr,imax,l,r,nn=n-skip_d;
 
784
 uchar level=(uchar)lev,f;
785
785
for(r=l=0,i=skip_u;i<nn;i++)
786
786
        {
787
787
        f=fun[i];
834
834
return;
835
835
}
836
836
 
837
 
static Int16 correct_two_zones(Int16 *kk,Int16 *mm,Int16 i,Int16 imax,Int16 extr_pos,
838
 
         Int16 lim[])
 
837
static int16_t correct_two_zones(int16_t *kk,int16_t *mm,int16_t i,int16_t imax,int16_t extr_pos,
 
838
         int16_t lim[])
839
839
{
840
 
Int16 k=*kk, m=*mm;
 
840
int16_t k=*kk, m=*mm;
841
841
 
842
842
if( k==m )
843
843
        return(1);
870
870
return( k==m );
871
871
}
872
872
 
873
 
static Int16 index_arr(Int16 v,Int16 limit[],Int16 n)
 
873
static int16_t index_arr(int16_t v,int16_t limit[],int16_t n)
874
874
{
875
 
Int16 i;
 
875
int16_t i;
876
876
for(i=1; i<n && v>=limit[i]; i++);
877
877
return( i-1 );
878
878
}
879
879
 
880
 
static void find_peak_new (Int16 *ind1, Int16 *ind2, Word8 fun[], Int16 nn,
881
 
  Int16 level, Int16 sr, Int16 *extr_pos, Word8 *extr_fun) // MK NEW
 
880
static void find_peak_new (int16_t *ind1, int16_t *ind2, uchar fun[], int16_t nn,
 
881
  int16_t level, int16_t sr, int16_t *extr_pos, uchar *extr_fun) // MK NEW
882
882
{                                                       // 14.01.1993
883
 
Int16 i=*ind1, extr;
884
 
Word8  f=*extr_fun;
885
 
///Int16  w_of_max = right0 [i] - left0 [i];  // MK 19.01.1993
886
 
///Word8 f_i, w_i;
 
883
int16_t i=*ind1, extr;
 
884
uchar  f=*extr_fun;
 
885
///int16_t  w_of_max = right0 [i] - left0 [i];  // MK 19.01.1993
 
886
///uchar f_i, w_i;
887
887
 
888
888
        extr=*ind2=i++ ;
889
889
 
918
918
//      return;
919
919
}
920
920
 
921
 
static Int16 typ_nose_1(Word8 left[],Int16 n,Int16 lim,Int16 lev)
 
921
static int16_t typ_nose_1(uchar left[],int16_t n,int16_t lim,int16_t lev)
922
922
{                                         /* normal nose (inc+jumps) : */
923
 
Int16  i ,jumps, ret   ;                        /*        ��             */
924
 
for(jumps=i=0;i<n && left[i]>=left[i+1]; i++) /*       ���             */
925
 
        if( left[i]!=left[i+1] )              /*     �����             */
926
 
                jumps ++;                     /*    ������             */
927
 
ret = ( i>=lim && jumps>3 );                  /*        ��             */
 
923
int16_t  i ,jumps, ret   ;                        /*        °°             */
 
924
for(jumps=i=0;i<n && left[i]>=left[i+1]; i++) /*       °°°             */
 
925
        if( left[i]!=left[i+1] )              /*     °°°°°             */
 
926
                jumps ++;                     /*    °°°°°°             */
 
927
ret = ( i>=lim && jumps>3 );                  /*        °°             */
928
928
 
929
929
if( ret )
930
930
        {  /* inc nose */
931
 
        for(jumps=0; i<n && left[i]<lev; i++)  /* +  ������            */
932
 
                if( left[i]!=left[i+1] )       /*      ����            */
933
 
                        jumps ++;              /*        ��            */
 
931
        for(jumps=0; i<n && left[i]<lev; i++)  /* +  °°°°°°            */
 
932
                if( left[i]!=left[i+1] )       /*      °°°°            */
 
933
                        jumps ++;              /*        °°            */
934
934
        if( jumps>2 && i*5<n )
935
935
                ret = 0;
936
936
        }
937
937
return( ret );
938
938
}
939
939
 
940
 
static Bool16 find_first_ne(Word8 fun[],Int16 n,Int16 direct,Int16 level)
 
940
static Bool16 find_first_ne(uchar fun[],int16_t n,int16_t direct,int16_t level)
941
941
{
942
 
Int16 i,ind;
943
 
Word8 lev=(Word8)level;
 
942
int16_t i,ind;
 
943
uchar lev=(uchar)level;
944
944
for(ind=i=0;i<n;i++,ind+=direct)
945
945
        if( fun[ind]!=lev )
946
946
                return(TRUE);
947
947
return(FALSE);
948
948
}
949
949
 
950
 
static void find_conc_new (Int16 *ind1, Int16 *ind2, Word8 fun[], Int16 nn,
951
 
  Int16 level, Int16 sl, Int16 *extr_pos, Word8 *extr_fun) // MK NEW
 
950
static void find_conc_new (int16_t *ind1, int16_t *ind2, uchar fun[], int16_t nn,
 
951
  int16_t level, int16_t sl, int16_t *extr_pos, uchar *extr_fun) // MK NEW
952
952
{                                                       // 14.01.1992
953
 
Int16 i=*ind1, extr;
954
 
Word8  f=*extr_fun;
 
953
int16_t i=*ind1, extr;
 
954
uchar  f=*extr_fun;
955
955
        extr=*ind2=i++;
956
956
 
957
957
        //MK: NO END && NEXT==TEK   && NEXT.NEXT==TEK  GO TO NEXT