2
2
Copyright (c) 1993-2008, Cognitive Technologies
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
8
* ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
���� ����������� �� ��������� �����, ���� ������ ������� � �����������
11
* ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
������ ����������, ������������ ��� ���������������, ������ �����������
13
��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
����������� ����� �� ��������.
15
* �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
���� ������������ � �������� �������� ��������� �/��� �����������
17
���������, ���������� �� ���� ��, ��� ���������������� �����������
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
������������� ������, ��������� � �������������� ��� ���������� ����������
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
5
Разрешается повторное распространение и использование как в виде исходного кода,
6
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
8
* При повторном распространении исходного кода должны оставаться указанное
9
выше уведомление об авторском праве, этот список условий и последующий
11
* При повторном распространении двоичного кода в документации и/или в
12
других материалах, поставляемых при распространении, должны сохраняться
13
указанная выше информация об авторском праве, этот список условий и
14
последующий отказ от гарантий.
15
* Ни название Cognitive Technologies, ни имена ее сотрудников не могут
16
быть использованы в качестве средства поддержки и/или продвижения
17
продуктов, основанных на этом ПО, без предварительного письменного
20
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
21
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
22
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
23
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
24
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
25
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
26
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
27
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
28
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
29
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
30
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
31
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
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:
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,
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,
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,
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,
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
///////////////////////////////////////////////////////////////////////////
136
static Word8 tab_1[]=
136
static uchar tab_1[]=
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
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,
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,
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)
164
164
memset(s, 0 , sizeof(STICK_SIGNUMS));
165
165
rm = opt + (wide<<1) - 2; /* right mode */
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) */
659
659
if(res->mount[i]>t)
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
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)
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);
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
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)
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];
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];
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 ;
760
static Int16 compress4(Int16 v)
760
static int16_t compress4(int16_t v)
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
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 ); /* °° */
931
for(jumps=0; i<n && left[i]<lev; i++) /* + ������ */
932
if( left[i]!=left[i+1] ) /* ���� */
931
for(jumps=0; i<n && left[i]<lev; i++) /* + °°°°°° */
932
if( left[i]!=left[i+1] ) /* °°°° */
934
934
if( jumps>2 && i*5<n )
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)
943
Word8 lev=(Word8)level;
943
uchar lev=(uchar)level;
944
944
for(ind=i=0;i<n;i++,ind+=direct)
945
945
if( fun[ind]!=lev )
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
953
int16_t i=*ind1, extr;
957
957
//MK: NO END && NEXT==TEK && NEXT.NEXT==TEK GO TO NEXT