91
91
//cut point - graph node in dynamic matching
92
92
typedef struct tagCutPoint
96
BYTE h; //cut begin from raster bottom
97
BYTE var; //cut point type
98
BYTE n; //number of components
99
BYTE flg; //for any purpose
94
uint16_t x; //position
95
uchar dh; //cut lehgth
96
uchar h; //cut begin from raster bottom
97
uchar var; //cut point type
98
uchar n; //number of components
99
uchar flg; //for any purpose
102
102
typedef struct tagGraphNode
104
WORD prev; //previous node in this path
104
uint16_t prev; //previous node in this path
105
105
Weight weight; //accrued weight to current node
106
DWORD monitors; //rates of monitoring letters
106
uint32_t monitors; //rates of monitoring letters
107
107
// SVERS vers; //versions for segment from prev to current
110
110
typedef struct tagStrRaster //���� ��ப�
114
LONG top; //��ப� ������ ���孥�� 㣫�
115
LONG left; //�⮫��� -""-
116
BYTE pict[LINE_WIDTH*LINE_HEIGHT/8]; //����
114
int32_t top; //��ப� ������ ���孥�� 㣫�
115
int32_t left; //�⮫��� -""-
116
uchar pict[LINE_WIDTH*LINE_HEIGHT/8]; //����
119
119
typedef struct tagCutAdd
126
126
SVERS vers; //��� ���ᨨ
129
129
static void set_param (MatchWordPar *param);
130
static BOOL make_cell_string(CSTR_rast wb, CSTR_rast we);
130
static Bool make_cell_string(CSTR_rast wb, CSTR_rast we);
131
131
static void calc_bl();
132
static void make_alphabet(BYTE *word);
133
static INT compose_inc(cell *wb, cell *we);
134
static BOOL make_str_raster(cell *wb, cell *we, StrRaster *raster);
132
static void make_alphabet(uchar *word);
133
static int16_t compose_inc(cell *wb, cell *we);
134
static Bool make_str_raster(cell *wb, cell *we, StrRaster *raster);
135
135
static void comptorast(c_comp *cp1, StrRaster *raster);
136
static void inttorast( StrRaster *r, LONG h, LONG end, LONG lth);
137
static BOOL calc_cut_points(cell *wb, cell *we, INT rastlc, INT rastdr);
138
static void fict_sect(CutPoint *sec, CutAdd *sec_add, GraphNode *node, INT x, INT px);
139
static void close_ds(CutPoint *sec, CutAdd *sec_add, GraphNode *node, INT x, INT px);
140
static void cor_sect(cell *C, CutPoint *cut, INT left, INT down);
141
static INT get_points (cell *C, CutPoint *listn, INT nmax );
136
static void inttorast( StrRaster *r, int32_t h, int32_t end, int32_t lth);
137
static Bool calc_cut_points(cell *wb, cell *we, int16_t rastlc, int16_t rastdr);
138
static void fict_sect(CutPoint *sec, CutAdd *sec_add, GraphNode *node, int16_t x, int16_t px);
139
static void close_ds(CutPoint *sec, CutAdd *sec_add, GraphNode *node, int16_t x, int16_t px);
140
static void cor_sect(cell *C, CutPoint *cut, int16_t left, int16_t down);
141
static int16_t get_points (cell *C, CutPoint *listn, int16_t nmax );
142
142
static void save_alpha_vers(cell *C, SVERS *svers);
143
static INT cut_by_alpha(INT n, version vers[]);
144
static Weight match(BYTE *word);
145
static BOOL test_set(LONG prev, LONG h0, BYTE nlet, LONG tol, BOOL rerecog, LONG *imax, LONG *pmax);
146
static LONG inc(CutPoint **cutp, LONG i, LONG ie, LONG set);
147
static LONG dec(CutPoint **cutp, LONG i, LONG ie, LONG set);
148
static LONG add_sect(LONG il, LONG ir, BYTE nlet, BOOL rerecog, BYTE *p);
149
static version *find_in_vers(SVERS *svers, BYTE let);
150
static BOOL equal(BYTE let1, BYTE let2);
151
static LONG select_cells(LONG il, LONG ir, BYTE cut_fl, cell **cells);
143
static int16_t cut_by_alpha(int16_t n, version vers[]);
144
static Weight match(uchar *word);
145
static Bool test_set(int32_t prev, int32_t h0, uchar nlet, int32_t tol, Bool rerecog, int32_t *imax, int32_t *pmax);
146
static int32_t inc(CutPoint **cutp, int32_t i, int32_t ie, int32_t set);
147
static int32_t dec(CutPoint **cutp, int32_t i, int32_t ie, int32_t set);
148
static int32_t add_sect(int32_t il, int32_t ir, uchar nlet, Bool rerecog, uchar *p);
149
static version *find_in_vers(SVERS *svers, uchar let);
150
static Bool equal(uchar let1, uchar let2);
151
static int32_t select_cells(int32_t il, int32_t ir, uchar cut_fl, cell **cells);
152
152
static void set_bad_vers(SVERS *c);
153
static Weight add_weight(Weight *wp, BYTE ro, BYTE nlet);
154
static void add_monitors(LONG il, LONG ir, BYTE nlet, BYTE pb);
153
static Weight add_weight(Weight *wp, uchar ro, uchar nlet);
154
static void add_monitors(int32_t il, int32_t ir, uchar nlet, uchar pb);
156
156
static void mw_show_rast();
157
static void show_layer(BYTE let, LONG prev, LONG imax);
157
static void show_layer(uchar let, int32_t prev, int32_t imax);
160
160
StrRaster str_raster;
161
161
#define MAX_CUT_POINT LINE_WIDTH/8
162
162
static CutPoint cut_list[MAX_CUT_POINT];
163
163
static GraphNode layer1[MAX_CUT_POINT],layer2[MAX_CUT_POINT],*cur_layer=layer1,*prev_layer=layer2;
165
static BYTE *templ,alpha[256]={0};
165
static uchar *templ,alpha[256]={0};
166
static int16_t com_inc;
167
167
struct dp_vers_struct vers_pool; //��� ���ᨩ dp
168
168
#define vers_list (vers_pool.node)
169
static LONG min_cut_width=0; //�� �ਭ� > min_cut_width ����� १���
169
static int32_t min_cut_width=0; //�� �ਭ� > min_cut_width ����� १���
171
171
static MatchWordPar *param;
185
{(BYTE)'�',r_cu_d,r_cu_g,0}, // r_cu_d 0xf0 cursiv d tail up
185
{(uchar)'�',r_cu_d,r_cu_g,0}, // r_cu_d 0xf0 cursiv d tail up
186
186
// r_cu_g 0xf1 cursiv d tail down
187
{(BYTE)'�',r_cu_m,0}, // r_cu_m 0xf5 cursiv t
188
{(BYTE)'�',(BYTE)'�',r_cu_u,0}, // r_cu_u 0xf7 cursiv ee
189
{(BYTE)'�',r_cu_z,0}, // r_cu_z 0xf8 cursiv g
190
{(BYTE)'�',r_cu_a,0}, // r_cu_a 0xfd a
191
{(BYTE)'�',r_e_2dot,0}, // r_e_2dot 0xC0 russian e .. = 192
192
{(BYTE)'�',r_EE_2dot,0}, // r_EE_2dot 0xC8 russian E .. = 200
193
{(BYTE)'�',(BYTE)'�',0}
187
{(uchar)'�',r_cu_m,0}, // r_cu_m 0xf5 cursiv t
188
{(uchar)'�',(uchar)'�',r_cu_u,0}, // r_cu_u 0xf7 cursiv ee
189
{(uchar)'�',r_cu_z,0}, // r_cu_z 0xf8 cursiv g
190
{(uchar)'�',r_cu_a,0}, // r_cu_a 0xfd a
191
{(uchar)'�',r_e_2dot,0}, // r_e_2dot 0xC0 russian e .. = 192
192
{(uchar)'�',r_EE_2dot,0}, // r_EE_2dot 0xC8 russian E .. = 200
193
{(uchar)'�',(uchar)'�',0}
499
499
static void comptorast(c_comp *cp1, StrRaster *str_raster)
501
LONG Lc1=cp1->nl; // number of lines in component
501
int32_t Lc1=cp1->nl; // number of lines in component
506
lp1=(lnhead *) ( (CHAR *)cp1 + cp1->lines + 2); // beginning of first line
506
lp1=(lnhead *) ( (char *)cp1 + cp1->lines + 2); // beginning of first line
507
507
for (lc1=0; lc1 < Lc1; lc1++)
509
509
h1=lp1->row+cp1->upper-str_raster->top;
510
510
int1=(interval *)(lp1+1); // ptr to current interval
511
for (y1=0; y1 < (LONG)lp1->h; y1++, int1++, h1++)
512
inttorast(str_raster,h1,(LONG)(int1->e+cp1->left-str_raster->left),int1->l);
513
lp1=(lnhead *) ((CHAR *)lp1+lp1->lth); // next line
511
for (y1=0; y1 < (int32_t)lp1->h; y1++, int1++, h1++)
512
inttorast(str_raster,h1,(int32_t)(int1->e+cp1->left-str_raster->left),int1->l);
513
lp1=(lnhead *) ((char *)lp1+lp1->lth); // next line
517
static void inttorast( StrRaster *r, LONG h, LONG end, LONG lth)
517
static void inttorast( StrRaster *r, int32_t h, int32_t end, int32_t lth)
519
LONG j,je,me,ib,jb,mb,head=(r->w+7)/8*h;
520
BYTE *str_raster=r->pict;
519
int32_t j,je,me,ib,jb,mb,head=(r->w+7)/8*h;
520
uchar *str_raster=r->pict;
523
523
mb = 0xff >> (ib & 7);
946
static LONG inc(CutPoint **cutp, LONG i, LONG ie, LONG set)
946
static int32_t inc(CutPoint **cutp, int32_t i, int32_t ie, int32_t set)
948
948
if (i>=ie) return -128;
952
CHAR var=(*cutp)->var & 0x7F;
952
char var=(*cutp)->var & 0x7F;
953
953
if (i==ie || in_set(var,set)) return i;
959
static LONG dec(CutPoint **cutp, LONG i, LONG ie, LONG set)
959
static int32_t dec(CutPoint **cutp, int32_t i, int32_t ie, int32_t set)
961
961
if (i<=ie) return -128;
965
CHAR var=(*cutp)->var & 0x7F;
965
char var=(*cutp)->var & 0x7F;
966
966
if (i==ie || in_set(var,set)) return i;
972
static LONG add_sect(LONG il, LONG ir, BYTE nlet, BOOL rerecog, BYTE *p)
972
static int32_t add_sect(int32_t il, int32_t ir, uchar nlet, Bool rerecog, uchar *p)
974
BYTE let=templ[nlet];
974
uchar let=templ[nlet];
976
976
void *kit; //㪠��⥫� �⥪� kit
977
977
cell *cells[MAX_CUTS];
979
979
CutPoint *cutl=cut_list+il,*cutr=cut_list+ir;
980
LONG xl=cutl->x,xr=cutr->x;
983
BYTE cut_fl = (( cutl->dh != 0 ) ? c_cg_cutl : 0) +
980
int32_t xl=cutl->x,xr=cutr->x;
983
uchar cut_fl = (( cutl->dh != 0 ) ? c_cg_cutl : 0) +
984
984
(( cutr->dh != 0 ) ? c_cg_cutr : 0);
986
986
SVERS vers; //���ᨨ ᥣ���� (i1,i0)
987
int16_t width; //��� �ਭ�
989
989
#define ROI_LEN 4
990
INT ro,roi[ROI_LEN]; //ro � ��� ��⠢���騥
990
int16_t ro,roi[ROI_LEN]; //ro � ��� ��⠢���騥
991
991
Weight wp=prev_layer[il].weight,wc=cur_layer[ir].weight,wt;
993
993
seg_vers *cur_vers;
995
995
if (xr-xl-1 < wmin)