70
69
#include "compat_defs.h"
71
70
#include "minmax.h"
72
int16_t gbCol1,gbCol2;
75
74
typedef struct tagRecogStat
77
INT nbig,ndust,weight;
76
int16_t nbig,ndust,weight;
84
static int16_t bl_lim=3;
87
static INT dirt_frag(cell **B, cell **E, cell *first, cell *last, BOOL stop_first);
88
static void bl_cut(cell *B, cell *E, INT cut);
89
static BOOL find_clust(BYTE let);
90
static BOOL clip_cell(INT j, cell *c, INT b1, INT b2, INT b3, INT b4, INT st_inc);
91
static void save_frag(cell *B, cell *E, RecogStat *rs, cell **sv_frag, INT *st_inc);
86
static int16_t dirt_frag(cell **B, cell **E, cell *first, cell *last, Bool stop_first);
87
static void bl_cut(cell *B, cell *E, int16_t cut);
88
static Bool find_clust(uchar let);
89
static Bool clip_cell(int16_t j, cell *c, int16_t b1, int16_t b2, int16_t b3, int16_t b4, int16_t st_inc);
90
static void save_frag(cell *B, cell *E, RecogStat *rs, cell **sv_frag, int16_t *st_inc);
92
91
static void replace_frag(cell *B, cell *E, RecogStat *rs, cell *sv_frag);
93
static INT create_cells(cell *whither, raster *r, cell *celist[], INT st_inc);
92
static int16_t create_cells(cell *whither, raster *r, cell *celist[], int16_t st_inc);
94
93
static cell *hide(cell *c, cell **clink);
95
94
static void restore(cell *clink, cell *wherever);
96
95
static void del_hided(cell *clink);
97
static BOOL capital(BYTE let);
96
static Bool capital(uchar let);
99
98
void base_lines_cut()
101
100
cell *BI,*EI,*B0=cell_f()->nextl,*E0=cell_l();
103
102
get_b_lines(NULL,&bl);
104
103
fb1=bl.n1>0 && bl.n1<255;
105
104
fb2=bl.n2>0 && bl.n2<255;
145
LONG testDirt(CSTR_rast *beg, CSTR_rast *end)
144
int32_t testDirt(CSTR_rast *beg, CSTR_rast *end)
147
146
CSTR_rast rst=*beg,first=rst,last=CSTR_GetNext(*end);
148
147
CSTR_rast capb=0,cape=0;
149
INT dirtup=0,dirtdown=0,ncap=0;
148
int16_t dirtup=0,dirtdown=0,ncap=0;
151
150
get_b_lines(NULL,&bl);
152
151
fb1=bl.n1>0 && bl.n1<255;
170
169
if (uni.Alt[0].Prob<trs2)
172
BYTE let=uni.Alt[0].Code[0],letpos = let_linpos[let];
173
INT bot=attr.row+attr.h;
174
BOOL d2=attr.row<bl.b2-bl_lim,d3=bot>bl.b3+bl_lim;
171
uchar let=uni.Alt[0].Code[0],letpos = let_linpos[let];
172
int16_t bot=attr.row+attr.h;
173
Bool d2=attr.row<bl.b2-bl_lim,d3=bot>bl.b3+bl_lim;
176
175
if (uni.lnAltCnt==0)
227
static INT dirt_frag(cell **B, cell **E, cell *first, cell *last, BOOL stop_first)
226
static int16_t dirt_frag(cell **B, cell **E, cell *first, cell *last, Bool stop_first)
229
228
cell *c=*B,*end=*E;
230
229
cell *capb=NULL,*cape=NULL;
231
INT dirtup=0,dirtdown=0,ncap=0;
230
int16_t dirtup=0,dirtdown=0,ncap=0;
234
233
glsnap('o',c,"Cut by bases; input r_col for begin and end");
246
245
if (c->vers[0].prob<trs2)
248
BYTE let=c->vers[0].let;
249
BYTE letpos = let_linpos[let];
251
BOOL d2 = (fb2) ? c->row<bl.b2-bl_lim : TRUE;
252
BOOL d3 = (fb3) ? bot>bl.b3+bl_lim : TRUE;
247
uchar let=c->vers[0].let;
248
uchar letpos = let_linpos[let];
249
int16_t bot=c->row+c->h;
250
Bool d2 = (fb2) ? c->row<bl.b2-bl_lim : TRUE;
251
Bool d3 = (fb3) ? bot>bl.b3+bl_lim : TRUE;
254
253
if ((c->pr_vers.prob>=220 ||
255
254
strchr("���",c->pr_vers.let) &&
379
static void bl_cut(cell *B, cell *E, INT cut)
378
static void bl_cut(cell *B, cell *E, int16_t cut)
381
380
cell *f=B,*LC=B->prev,*RC=E->next;
383
382
cell *sv_frag=NULL;
384
INT st_inc; //�।��� ������
383
int16_t st_inc; //�।��� ������
387
386
//save current state
388
387
save_frag(B,E,&rs,&sv_frag,&st_inc);
402
INT b1 = (fb1 && cut>0) ? bl.b1-c->row : 0;
403
INT b2 = (fb2 && cut>0) ? bl.b2-c->row : 0;
404
INT b3 = (fb3 && cut<0) ? bl.b3-c->row : 0;
405
INT b4 = (fb4 && cut<0) ? bl.b4-c->row : 0;
401
int16_t b1 = (fb1 && cut>0) ? bl.b1-c->row : 0;
402
int16_t b2 = (fb2 && cut>0) ? bl.b2-c->row : 0;
403
int16_t b3 = (fb3 && cut<0) ? bl.b3-c->row : 0;
404
int16_t b4 = (fb4 && cut<0) ? bl.b4-c->row : 0;
407
406
if (let_or_bad(c))
429
428
del_hided(sv_frag);
432
static BOOL clip_cell(INT j, cell *c, INT b1, INT b2, INT b3, INT b4, INT st_inc)
431
static Bool clip_cell(int16_t j, cell *c, int16_t b1, int16_t b2, int16_t b3, int16_t b4, int16_t st_inc)
434
433
//��१��� �� c ��, �� ��室�� �� b1,b4 (����� �� c->row); b2,b3 - �������⥫�� ࠧ१�,
437
INT crow=c->row; //b1,b2,b3,b4 refer to crow
436
int16_t crow=c->row; //b1,b2,b3,b4 refer to crow
440
439
// for (j=0; j<2 && c; j++)
460
459
raster r; //������� ����
461
460
cell *celist[MAX_SECT+1];
462
INT wbyte=(c->w+7)>>3,i,nall,size=((c->w+7)>>3)*c->h;
461
int16_t wbyte=(c->w+7)>>3,i,nall,size=((c->w+7)>>3)*c->h;
465
464
if (size>sizeof(r.pict))
467
memcpy(&(r.pict),(BYTE*)save_raster(c),size);
466
memcpy(&(r.pict),(uchar*)save_raster(c),size);
468
467
r.w=c->w; r.h=c->h; r.top=c->r_row; r.left=c->r_col;
499
498
full_recog(t,NULL,trs2,trs2);
500
if (!let(t)) repair &= clip_cell((INT)(j+1),t,0,(INT)(crow+b2-t->row),(INT)(crow+b3-t->row),0,st_inc);
499
if (!let(t)) repair &= clip_cell((int16_t)(j+1),t,0,(int16_t)(crow+b2-t->row),(int16_t)(crow+b3-t->row),0,st_inc);
505
504
return repair && nbig != 0;
508
return clip_cell((INT)(j+1),c,0,(INT)(crow+b2-c->row),(INT)(crow+b3-c->row),0,st_inc);
507
return clip_cell((int16_t)(j+1),c,0,(int16_t)(crow+b2-c->row),(int16_t)(crow+b3-c->row),0,st_inc);
510
509
return let(c) != 0;
513
static INT create_cells(cell *whither, raster *r, cell *celist[], INT st_inc)
512
static int16_t create_cells(cell *whither, raster *r, cell *celist[], int16_t st_inc)
516
MN *mn=c_locomp(r->pict,(INT)((r->w+7)>>3),r->h,r->top,r->left);
515
MN *mn=c_locomp(r->pict,(int16_t)((r->w+7)>>3),r->h,r->top,r->left);
517
516
for (i=0; i<MAX_SECT && mn; i++,mn=mn->mnnext)
519
518
cell *c=create_my_cell(mn,whither,0,0);
527
static void save_frag(cell *B, cell *E, RecogStat *rs, cell **sv_frag, INT *st_inc)
526
static void save_frag(cell *B, cell *E, RecogStat *rs, cell **sv_frag, int16_t *st_inc)
529
528
cell *celist[MAX_SECT];
532
531
B->complist=NULL;
533
532
rs->weight=256; rs->nbig=rs->ndust=0;
553
552
static void replace_frag(cell *B, cell *E, RecogStat *rs, cell *sv_frag)
556
INT weight=256,nbig=0,ndust=0;
555
int16_t weight=256,nbig=0,ndust=0;
557
556
// B_LINES bs=bl;