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

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/dif/src/diffr.c

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk
  • Date: 2010-09-14 15:53:54 UTC
  • mto: (5.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20100914155354-i3uu2woc5aucphax
Tags: upstream-1.0.0+dfsg
Import upstream version 1.0.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
#include "difdefs.h"
63
63
#include "dif.h"
64
64
#include "minmax.h"
65
 
extern  Word8 broken_flag;
66
 
  Word8 rec5_flag=1,font_type=0,omni=1;
67
 
Int16  NumVertInterval(Word8 *RASTER,Int16 D_X, Int16 dy, Int16 i);
68
 
Int16  VertSum(Word8 *rastr,Int16 D_X, Int16 dy, Int16 i);
69
 
Int16  SumBits(Word8 *rastr,Int16 D_X);
70
 
Int16  NumHorizInterval(Word8 *,Int16);
71
 
Int16  FOOT(Word8 *raster,Int16 DX,Word8 dx,Word8 Ly,
72
 
    Word8 sign_filter);
73
 
Int16 FOOT3( Word8 *RASTER, Int16 Wx, Word8 START, Word8 NWIDTH, Word8 NLENGTH, Int16 SHIFT);
74
 
Int16 EndBlackInterval(Word8 *RASTER, Int16 NWIDTH);
75
 
Int16 FOOT3_2( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NLENGTH);
76
 
Int16 FOOT_HEI( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NLENGTH);
77
 
 
78
 
Int16 MinMaxLeft( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NHEIGHT,
79
 
                Int16 *Pmin, Int16 *Pmax);
80
 
Int16 MinMaxRight( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NHEIGHT,
81
 
                Int16 *Pmin, Int16 *Pmax);
82
 
Int16 DiskrRight(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 L);
83
 
Int16 Num2Interval(Word8 *r,Int16 D_X,Int16 dx,Int16 dy);
84
 
Int16 broken_M(Word8 * r,Int16 D_X,Int16 dy,Int16 left_lim,Int16 ll);
85
 
Int16  FOOT_A(Word8 *raster,Int16 DX,Word8 dx,Word8 Ly);
86
 
Int16 fill_center_zone(Word8 *raster,Int16 D_X,Int16 dy,
87
 
      Int16 beg, Int16 end, Int16 II);
88
 
Int16 up_down_hist_M(Word8 *rastr,Int16 D_X, Int16 Dx,Int16 dy);
89
 
Int16 small_density(Word8 *RAST,Int16 n,Int16 D_X,Int16 bw);
90
 
Int16  LeftDistance(Word8 *RASTER,Int16 dx);
91
 
Int16  RightDistance(Word8 *RASTER,Int16 dx);
92
 
Int16  SumIntervalBits(Word8 *RASTER,Int16 bx,Int16 ex);
93
 
Int16  CenterVertInterval(Word8 *,Int16 ,Int16 ,Int16, Int16 *,Int16 *);
94
 
void init_diskrim(Word8* raster,Int16 height ,Int16 width);
95
 
Int16 DiskrLeftBig(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy, Int16 L);
96
 
Int16 DiskrRightBig(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 L);
97
 
 
98
 
static void DiskrIN(Word8 *RASTR,Int16 D_X,Int16 dy, Int16 wb,Int16 dx);
99
 
static Int16 DiskrHorizIN(Word8 *RASTR,Int16 D_X,Int16 dy);
100
 
Int16 no_serific(Word8 *RASTR,Int16 dy,Int16 dx,Int16 wb);
 
65
extern  uchar broken_flag;
 
66
  uchar rec5_flag=1,font_type=0,omni=1;
 
67
int16_t  NumVertInterval(uchar *RASTER,int16_t D_X, int16_t dy, int16_t i);
 
68
int16_t  VertSum(uchar *rastr,int16_t D_X, int16_t dy, int16_t i);
 
69
int16_t  SumBits(uchar *rastr,int16_t D_X);
 
70
int16_t  NumHorizInterval(uchar *,int16_t);
 
71
int16_t  FOOT(uchar *raster,int16_t DX,uchar dx,uchar Ly,
 
72
    uchar sign_filter);
 
73
int16_t FOOT3( uchar *RASTER, int16_t Wx, uchar START, uchar NWIDTH, uchar NLENGTH, int16_t SHIFT);
 
74
int16_t EndBlackInterval(uchar *RASTER, int16_t NWIDTH);
 
75
int16_t FOOT3_2( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NLENGTH);
 
76
int16_t FOOT_HEI( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NLENGTH);
 
77
 
 
78
int16_t MinMaxLeft( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NHEIGHT,
 
79
                int16_t *Pmin, int16_t *Pmax);
 
80
int16_t MinMaxRight( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NHEIGHT,
 
81
                int16_t *Pmin, int16_t *Pmax);
 
82
int16_t DiskrRight(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t L);
 
83
int16_t Num2Interval(uchar *r,int16_t D_X,int16_t dx,int16_t dy);
 
84
int16_t broken_M(uchar * r,int16_t D_X,int16_t dy,int16_t left_lim,int16_t ll);
 
85
int16_t  FOOT_A(uchar *raster,int16_t DX,uchar dx,uchar Ly);
 
86
int16_t fill_center_zone(uchar *raster,int16_t D_X,int16_t dy,
 
87
      int16_t beg, int16_t end, int16_t II);
 
88
int16_t up_down_hist_M(uchar *rastr,int16_t D_X, int16_t Dx,int16_t dy);
 
89
int16_t small_density(uchar *RAST,int16_t n,int16_t D_X,int16_t bw);
 
90
int16_t  LeftDistance(uchar *RASTER,int16_t dx);
 
91
int16_t  RightDistance(uchar *RASTER,int16_t dx);
 
92
int16_t  SumIntervalBits(uchar *RASTER,int16_t bx,int16_t ex);
 
93
int16_t  CenterVertInterval(uchar *,int16_t ,int16_t ,int16_t, int16_t *,int16_t *);
 
94
void init_diskrim(uchar* raster,int16_t height ,int16_t width);
 
95
int16_t DiskrLeftBig(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy, int16_t L);
 
96
int16_t DiskrRightBig(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t L);
 
97
 
 
98
static void DiskrIN(uchar *RASTR,int16_t D_X,int16_t dy, int16_t wb,int16_t dx);
 
99
static int16_t DiskrHorizIN(uchar *RASTR,int16_t D_X,int16_t dy);
 
100
int16_t no_serific(uchar *RASTR,int16_t dy,int16_t dx,int16_t wb);
101
101
 
102
102
#define bytlen(bits)  (REC_GW_WORD8(bits))
103
103
 
104
 
extern Word8 BUFFER[256];        /* ���⨪��쭠�   ��o����              */
105
 
extern Word8 LOCAL[50];          /* ���न����     ���             */
106
 
extern Word8 LOCAL_W[50];        /* �ਭ�         ���             */
107
 
extern Word8 end1,beg2;          /* ����� 1 � ��砫� 2-�� ��� ���  */
 
104
extern uchar BUFFER[256];        /* ���⨪��쭠�   ��o����              */
 
105
extern uchar LOCAL[50];          /* ���न����     ���             */
 
106
extern uchar LOCAL_W[50];        /* �ਭ�         ���             */
 
107
extern uchar end1,beg2;          /* ����� 1 � ��砫� 2-�� ��� ���  */
108
108
extern broken_ii;               /* 䫠� ���� �����                        */
109
 
extern Int16 dnri_hook; // bottom right hook in small russian italic II,III
110
 
extern Int16 uple_hook; // bottom left  hook in small russian italic II,III
111
 
extern Int16 up_jack  ; // upper jack
 
109
extern int16_t dnri_hook; // bottom right hook in small russian italic II,III
 
110
extern int16_t uple_hook; // bottom left  hook in small russian italic II,III
 
111
extern int16_t up_jack  ; // upper jack
112
112
 
113
 
static Int16 upper_skip_lines,lower_skip_lines;
114
 
static Int16 diskr_f2,diskr_tsh,diskr_ii,
 
113
static int16_t upper_skip_lines,lower_skip_lines;
 
114
static int16_t diskr_f2,diskr_tsh,diskr_ii,
115
115
    diskr_sh,diskr_g,diskr_tsh,diskr_ju,diskr_m,diskr_ii,diskr_p,diskr_N,
116
116
    diskr_c, diskr_o, diskr_e,diskr_b,diskr_3,
117
117
    IN_N_Bonus,IN_equ,IN_P_Bonus,
118
118
    IN_I_Bonus,IN_IN_Monus,IN_dis,diskr_i,diskr_n,IN_N,IN_I,IN_M,IN_pics,
119
119
    mii;
120
120
 
121
 
 Int16 left_dist[4], right_dist[4], num_foot, c_or_e,d_c,d_e,
 
121
 int16_t left_dist[4], right_dist[4], num_foot, c_or_e,d_c,d_e,
122
122
    right_max,left_max,left_line,right_line,
123
123
    left_dist_big[4], right_dist_big[4],lower_long_line;
124
 
Int16 av_tl, av_bl,av_br, rotate;
 
124
int16_t av_tl, av_bl,av_br, rotate;
125
125
/* g-�, sh-�, b-B, k-K, ju-�, f2-���, tsh-�, ii-�, o-O, c-C, e-E,
126
126
   h-�, ja-�, z-�, ee-�, d-�, ce-�  */
127
 
Int16 fill_center,up_down_serif,up_down_serif_B,IN_horiz_dis,broken_M_pen;
 
127
int16_t fill_center,up_down_serif,up_down_serif_B,IN_horiz_dis,broken_M_pen;
128
128
 
129
 
static Int16 DiskrSymSh( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NLENGTH);
130
 
static Int16 DiskrSh(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly);
131
 
static Int16 DiskrLeft(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy, Int16 L);
132
 
static Int16 DiskrSh0(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 dx0);
133
 
static Int16 DiskrJ0(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly,Int16 lim);
134
 
static Int16 DiskrJ(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy);
135
 
static Int16 DiskrTsh(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 Dx);
136
 
static Int16 average_br_angle(Word8 *RASTER, Int16 D_X, Int16 dx, Int16 dy,Int16 t);
137
 
static Int16 average_angle(Word8 *RASTER, Int16 D_X, Int16 dx, Int16 dy,
138
 
       Int16  (*Distance)(Word8 *, Int16), Int16 t);
139
 
static Int16 DiskrJu(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly);
140
 
static Int16 DiskrimM1(Word8 *RAST,Int16 D_X,Int16 dx,Int16 dy);
141
 
static Int16 DiskrimM(Word8 *RAST,Int16 D_X,Int16 dx,Int16 dy);
142
 
static Int16 whiteMeanBitRight(Word8 *RAST,Int16 D_X,Int16 dx,Int16 meanBit);
143
 
static Int16 whiteMeanBitLeft(Word8 *RAST,Int16 D_X,Int16 meanBit);
144
 
static Int16 up_down_zones(Word8 *raster, Int16 D_X, Int16 dx, Int16 dx0,
145
 
      Int16 start1, Int16 stop1,   Int16 start2, Int16 stop2);
146
 
static Int16 DiskrVertCE(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 X,
147
 
                        Word8 let, Word8 inc);
148
 
static Int16 AngleBottomRight(Word8 *raster,Int16 D_X,Int16 hei);
149
 
static Int16 AngleTopRight(Word8 *raster,Int16 D_X,Int16 hei);
150
 
static Int16 BonusAnglesCurve(Word8 *raster,Int16 D_X,Int16 dy);
151
 
static Bool32 DiskrJuCut(Int16 nfoot, Int16 dx);
 
129
static int16_t DiskrSymSh( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NLENGTH);
 
130
static int16_t DiskrSh(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly);
 
131
static int16_t DiskrLeft(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy, int16_t L);
 
132
static int16_t DiskrSh0(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t dx0);
 
133
static int16_t DiskrJ0(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly,int16_t lim);
 
134
static int16_t DiskrJ(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy);
 
135
static int16_t DiskrTsh(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t Dx);
 
136
static int16_t average_br_angle(uchar *RASTER, int16_t D_X, int16_t dx, int16_t dy,int16_t t);
 
137
static int16_t average_angle(uchar *RASTER, int16_t D_X, int16_t dx, int16_t dy,
 
138
       int16_t  (*Distance)(uchar *, int16_t), int16_t t);
 
139
static int16_t DiskrJu(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly);
 
140
static int16_t DiskrimM1(uchar *RAST,int16_t D_X,int16_t dx,int16_t dy);
 
141
static int16_t DiskrimM(uchar *RAST,int16_t D_X,int16_t dx,int16_t dy);
 
142
static int16_t whiteMeanBitRight(uchar *RAST,int16_t D_X,int16_t dx,int16_t meanBit);
 
143
static int16_t whiteMeanBitLeft(uchar *RAST,int16_t D_X,int16_t meanBit);
 
144
static int16_t up_down_zones(uchar *raster, int16_t D_X, int16_t dx, int16_t dx0,
 
145
      int16_t start1, int16_t stop1,   int16_t start2, int16_t stop2);
 
146
static int16_t DiskrVertCE(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t X,
 
147
                        uchar let, uchar inc);
 
148
static int16_t AngleBottomRight(uchar *raster,int16_t D_X,int16_t hei);
 
149
static int16_t AngleTopRight(uchar *raster,int16_t D_X,int16_t hei);
 
150
static int16_t BonusAnglesCurve(uchar *raster,int16_t D_X,int16_t dy);
 
151
static Bool32 DiskrJuCut(int16_t nfoot, int16_t dx);
152
152
 
153
153
/*  clear diskrimination flags */
154
 
void init_diskrim(Word8* raster,Int16 height ,Int16 width)
 
154
void init_diskrim(uchar* raster,int16_t height ,int16_t width)
155
155
{
156
 
Int16 i, D_X=bytlen(width);
157
 
Word8* r;
 
156
int16_t i, D_X=bytlen(width);
 
157
uchar* r;
158
158
 
159
159
rotate=0;
160
160
diskr_f2=diskr_ii=
187
187
return;
188
188
}
189
189
 
190
 
Bool32 LeftHole(Word8 *rastr, Int16 D_X, Int16 Dx, Int16 Hy)
 
190
Bool32 LeftHole(uchar *rastr, int16_t D_X, int16_t Dx, int16_t Hy)
191
191
{
192
192
int i,n,t, mi, ma;
193
193
 
234
234
/*   RETURN :   0 - good letter                            */
235
235
/*             >0 - decreasing code                        */
236
236
 
237
 
Int16 Diskrim(Word8 let,Word8* raster,
238
 
      Int16 D_X,Int16 dx,Int16 dy,Word8 cg_flag, Int16 inc)
 
237
int16_t Diskrim(uchar let,uchar* raster,
 
238
      int16_t D_X,int16_t dx,int16_t dy,uchar cg_flag, int16_t inc)
239
239
{
240
 
Int16 P=0,F=0,Dx,Hy,bw, n, r;
241
 
Word8 *rastr,*rastr0;
242
 
Int16 d_l, d_r;
243
 
Int16 X=0, Y=0;
 
240
int16_t P=0,F=0,Dx,Hy,bw, n, r;
 
241
uchar *rastr,*rastr0;
 
242
int16_t d_l, d_r;
 
243
int16_t X=0, Y=0;
244
244
#define  step_diskr 20
245
245
 
246
246
rotate= (inc>180) ;
269
269
switch( let ){
270
270
// russian small & capital E, Ze, 3
271
271
case '3' :
272
 
case (Word8)'�' :  case (Word8)'�' :
273
 
case (Word8)'�' :  case (Word8)'�' :
 
272
case (uchar)'�' :  case (uchar)'�' :
 
273
case (uchar)'�' :  case (uchar)'�' :
274
274
    if( diskr_3<0 )
275
275
       {
276
276
       if( LeftHole(rastr, D_X, Dx, Hy) )
283
283
       else P = diskr_3;
284
284
    break;
285
285
// russian small & capital B
286
 
case (Word8)'�' :      case (Word8)'�' :
 
286
case (uchar)'�' :      case (uchar)'�' :
287
287
    if( diskr_b<0 )
288
288
       {
289
289
       if( !DiskrRight(rastr0, D_X, Dx, dy,1) )
299
299
       else P = diskr_b;
300
300
    break;
301
301
// russian e
302
 
case (Word8)'�' :
 
302
case (uchar)'�' :
303
303
    if( diskr_e<0 )
304
304
       {
305
 
       if( (n=DiskrVertCE(rastr0, D_X, dx, dy, X,(Word8)'�',(Word8)inc))>2  )
 
305
       if( (n=DiskrVertCE(rastr0, D_X, dx, dy, X,(uchar)'�',(uchar)inc))>2  )
306
306
        P+=(n-2)*step_diskr;
307
307
       diskr_e = P;
308
308
       }
310
310
    break;
311
311
// russian o,O
312
312
//  case '0' :
313
 
  case (Word8)'�' :  case (Word8)'�' :
 
313
  case (uchar)'�' :  case (uchar)'�' :
314
314
    if( diskr_o<0 )
315
315
       {
316
316
       if( DiskrRight(rastr0, D_X, Dx, dy, 2) )
320
320
       else  P = diskr_o;
321
321
    break;
322
322
// russian c,C
323
 
  case (Word8)'�' :  case (Word8)'�' :
 
323
  case (uchar)'�' :  case (uchar)'�' :
324
324
    if( diskr_c<0 )
325
325
       {
326
326
       if( !DiskrRight(rastr0, D_X, Dx, dy, 2) )
327
327
        P = step_diskr;
328
 
        if( (n=DiskrVertCE(rastr0, D_X, dx, dy, X,(Word8)'�',(Word8)inc))!=0 )
 
328
        if( (n=DiskrVertCE(rastr0, D_X, dx, dy, X,(uchar)'�',(uchar)inc))!=0 )
329
329
          P+=n*step_diskr;
330
330
       diskr_c = P;
331
331
       }
332
332
       else  P = diskr_c;
333
333
    break;
334
334
// capital N
335
 
  case (Word8)'N' :
 
335
  case (uchar)'N' :
336
336
                if( diskr_N<0 )
337
337
                {
338
 
        Word8 rasterN[4096];
 
338
        uchar rasterN[4096];
339
339
        int i,ii,iii;
340
340
 
341
341
        for(iii=D_X*(dy-1),ii=i=0;i<dy;i++,ii+=D_X,iii-=D_X)
342
342
            memcpy(rasterN+iii,raster+ii,D_X);
343
343
        rastr0= rasterN + Y*D_X+(X>>3);
344
344
        rastr = rastr0 + D_X*(dy>>2);
345
 
        F = FOOT(rastr, D_X,(Word8)Dx, (Word8)Hy,1);
 
345
        F = FOOT(rastr, D_X,(uchar)Dx, (uchar)Hy,1);
346
346
                if( F!=2 || MIN(LOCAL_W[0],LOCAL_W[1])>3 && beg2-end1<3 )
347
347
                        {
348
348
                        if( dy>13 )
349
 
                                F=FOOT(rastr0+2*D_X, D_X,(Word8)Dx, (Word8)(dy-4),0);
 
349
                                F=FOOT(rastr0+2*D_X, D_X,(uchar)Dx, (uchar)(dy-4),0);
350
350
                        else
351
 
                                F=FOOT(rastr0, D_X,(Word8)Dx, (Word8)dy,0);
 
351
                                F=FOOT(rastr0, D_X,(uchar)Dx, (uchar)dy,0);
352
352
                        }
353
353
                if( F!=2 )
354
354
                        {
387
387
                break;
388
388
 
389
389
// capital & small I/I
390
 
  case (Word8)'�' :  case (Word8)'�' :
 
390
  case (uchar)'�' :  case (uchar)'�' :
391
391
                if( diskr_i<0 )
392
392
                {
393
 
                F = FOOT(rastr, D_X,(Word8)Dx, (Word8)Hy,1);
 
393
                F = FOOT(rastr, D_X,(uchar)Dx, (uchar)Hy,1);
394
394
        if( F==2 && LOCAL[1]*2<=Dx )
395
395
            {
396
396
            diskr_i = P=120;
399
399
                if( F!=2 || MIN(LOCAL_W[0],LOCAL_W[1])>3 && beg2-end1<3 )
400
400
                        {
401
401
                        if( dy>13 )
402
 
                                F=FOOT(rastr0+2*D_X, D_X,(Word8)Dx, (Word8)(dy-4),0);
 
402
                                F=FOOT(rastr0+2*D_X, D_X,(uchar)Dx, (uchar)(dy-4),0);
403
403
                        else
404
 
                                F=FOOT(rastr0, D_X,(Word8)Dx, (Word8)dy,0);
 
404
                                F=FOOT(rastr0, D_X,(uchar)Dx, (uchar)dy,0);
405
405
                        }
406
406
                if( F!=2 )
407
407
                        {
416
416
                   {
417
417
                           /*
418
418
       if( rotate && dnri_hook )
419
 
        fill_center_zone(rastr+D_X*(Hy>>2),(Int16)D_X,(Int16)(Hy-(Hy>>2)),(Int16)end1,(Int16)beg2,0);
 
419
        fill_center_zone(rastr+D_X*(Hy>>2),(int16_t)D_X,(int16_t)(Hy-(Hy>>2)),(int16_t)end1,(int16_t)beg2,0);
420
420
      else
421
421
        fill_center_zone(rastr,D_X,Hy,end1,beg2,0);
422
422
                */
442
442
                   /*
443
443
      if( IN_I>=9 )
444
444
        { // �祭� ����ਧ��⠫쭠� ��४������
445
 
        if( (F=up_down_hist_M(rastr0+D_X, (Int16)D_X,(Int16)Dx, (Int16)(dy-2)))>0 )
 
445
        if( (F=up_down_hist_M(rastr0+D_X, (int16_t)D_X,(int16_t)Dx, (int16_t)(dy-2)))>0 )
446
446
          P += F*step_diskr>>2;
447
447
        if( LOCAL[1]>(Dx>>1) &&
448
 
        broken_M(rastr0+2*D_X, D_X,(Int16)(dy-4),(Int16)(LOCAL[0]-LOCAL_W[0]/2),
449
 
          (Int16)(LOCAL[1]-LOCAL_W[1]/2)) )
 
448
        broken_M(rastr0+2*D_X, D_X,(int16_t)(dy-4),(int16_t)(LOCAL[0]-LOCAL_W[0]/2),
 
449
          (int16_t)(LOCAL[1]-LOCAL_W[1]/2)) )
450
450
          P += 4*step_diskr;
451
451
        }
452
452
                   */
456
456
        P >>= 1;
457
457
      if(     IN_I_Bonus && broken_flag && (broken_ii ||
458
458
                        !IN_IN_Monus &&
459
 
                        Num2Interval(rastr0+2*D_X, (Int16)D_X,(Int16)Dx, (Int16)(dy-4))) )
 
459
                        Num2Interval(rastr0+2*D_X, (int16_t)D_X,(int16_t)Dx, (int16_t)(dy-4))) )
460
460
                        P =(IN_I_Bonus==2)?-254:-250;
461
461
 
462
462
                diskr_i = P;
464
464
                else P=diskr_i;
465
465
                break;
466
466
// capital & small H
467
 
  case (Word8)'�' :  case (Word8)'�' :
 
467
  case (uchar)'�' :  case (uchar)'�' :
468
468
                if( diskr_n<0 )
469
469
                {
470
 
                F =FOOT(rastr, D_X,(Word8)Dx, (Word8)Hy,1);
 
470
                F =FOOT(rastr, D_X,(uchar)Dx, (uchar)Hy,1);
471
471
                if( F!=2 || MIN(LOCAL_W[0],LOCAL_W[1])>3 && beg2-end1<3 )
472
472
                        {
473
473
                        if( dy>13 )
474
 
                                F=FOOT(rastr0+2*D_X, D_X,(Word8)Dx,(Word8)(dy-4),0);
 
474
                                F=FOOT(rastr0+2*D_X, D_X,(uchar)Dx,(uchar)(dy-4),0);
475
475
                        else
476
 
                                F=FOOT(rastr0, D_X,(Word8)Dx, (Word8)dy,0);
 
476
                                F=FOOT(rastr0, D_X,(uchar)Dx, (uchar)dy,0);
477
477
                        }
478
478
                if( F!=2 )
479
479
                        P = 6*step_diskr;
481
481
                   {
482
482
                        /*
483
483
      if( rotate && dnri_hook )
484
 
        fill_center_zone(rastr+D_X*(Hy>>2),(Int16)D_X,(Int16)(Hy-(Hy>>2)),(Int16)end1,(Int16)beg2,0);
 
484
        fill_center_zone(rastr+D_X*(Hy>>2),(int16_t)D_X,(int16_t)(Hy-(Hy>>2)),(int16_t)end1,(int16_t)beg2,0);
485
485
      else
486
486
        fill_center_zone(rastr,D_X,Hy,end1,beg2,0);
487
487
                */
506
506
                   if( IN_N>3 )
507
507
                        P += MIN(IN_N * step_diskr,160)/2;
508
508
                   /*
509
 
                   if( DiskrRight(rastr0, (Int16)D_X, (Int16)Dx, (Int16)dy,(Int16)(dy>22?3:2)) )
 
509
                   if( DiskrRight(rastr0, (int16_t)D_X, (int16_t)Dx, (int16_t)dy,(int16_t)(dy>22?3:2)) )
510
510
                        P += 3*step_diskr;
511
511
                   if( omni )
512
512
                        {
519
519
 
520
520
    if( IN_N_Bonus && broken_flag && (broken_ii ||
521
521
                        !IN_IN_Monus &&
522
 
                        Num2Interval(rastr0+2*D_X, (Int16)D_X,(Int16)Dx, (Int16)(dy-4))) )
 
522
                        Num2Interval(rastr0+2*D_X, (int16_t)D_X,(int16_t)Dx, (int16_t)(dy-4))) )
523
523
                        P =(IN_N_Bonus==2)?-254:-250;
524
524
 
525
525
                diskr_n = P;
527
527
                else P=diskr_n;
528
528
                break;
529
529
// capital & small II
530
 
  case (Word8)'�' :  case (Word8)'�' :
 
530
  case (uchar)'�' :  case (uchar)'�' :
531
531
    if( diskr_p )
532
532
      {
533
533
      if( dy>13 )
534
 
        F=FOOT(rastr0+2*D_X, D_X,(Word8)Dx, (Word8)(dy-4),0);
 
534
        F=FOOT(rastr0+2*D_X, D_X,(uchar)Dx, (uchar)(dy-4),0);
535
535
      else
536
 
        F=FOOT(rastr0, D_X,(Word8)Dx, (Word8)dy,0);
 
536
        F=FOOT(rastr0, D_X,(uchar)Dx, (uchar)dy,0);
537
537
      if( F!=2 )
538
538
        P = 6*step_diskr;
539
539
      else
540
540
        { // F==2
541
541
        if( rotate && (dnri_hook/*||dy<22&&up_jack>1*/) )
542
 
          fill_center_zone(rastr+D_X*(Hy>>2),D_X,(Int16)(Hy-(Hy>>2)),end1,beg2,1);
 
542
          fill_center_zone(rastr+D_X*(Hy>>2),D_X,(int16_t)(Hy-(Hy>>2)),end1,beg2,1);
543
543
        else
544
544
          //fill_center_zone(rastr,D_X,Hy,end1,beg2,0);
545
 
          fill_center_zone(rastr+D_X*(Hy>>2),D_X,(Int16)(Hy-(Hy>>2)),end1,beg2,1);
 
545
          fill_center_zone(rastr+D_X*(Hy>>2),D_X,(int16_t)(Hy-(Hy>>2)),end1,beg2,1);
546
546
        {
547
 
        Int16 f_c=fill_center;
 
547
        int16_t f_c=fill_center;
548
548
        DiskrIN(rastr0,D_X,dy,bw,dx);
549
549
        if( !(rotate && (dnri_hook/*||dy<22&&up_jack>1*/)) )
550
550
          f_c = fill_center;
553
553
        }
554
554
      }
555
555
 
556
 
      if( (n=up_down_zones(rastr0,D_X,Dx,dx,0,(Int16)(dy>>2),Hy,dy))!=0 )
 
556
      if( (n=up_down_zones(rastr0,D_X,Dx,dx,0,(int16_t)(dy>>2),Hy,dy))!=0 )
557
557
        {
558
558
        if( omni )
559
559
        {
571
571
 
572
572
      if(   IN_P_Bonus && broken_flag && (broken_ii ||
573
573
        !IN_IN_Monus &&
574
 
        Num2Interval(rastr0+2*D_X, D_X,Dx, (Int16)(dy-4))) )
 
574
        Num2Interval(rastr0+2*D_X, D_X,Dx, (int16_t)(dy-4))) )
575
575
          P =(IN_P_Bonus==2)?-254:-250;
576
576
 
577
577
      diskr_p = P;
579
579
    else P = diskr_p;
580
580
    break;
581
581
// capital & small III
582
 
  case (Word8)'�' :  case (Word8)'�' :
 
582
  case (uchar)'�' :  case (uchar)'�' :
583
583
    if( diskr_sh<0 )
584
584
       {
585
 
       FOOT(rastr, D_X,(Word8)Dx, (Word8)Hy,0);
 
585
       FOOT(rastr, D_X,(uchar)Dx, (uchar)Hy,0);
586
586
       if( rotate ) // OLEG : ERECTION conditions : 09-20-95
587
587
        {
588
588
/*
594
594
        }
595
595
      else
596
596
        {
597
 
        if( (F=FOOT3(rastr, D_X, 0, (Word8)Dx, (Word8)Hy,2))!=3 )
 
597
        if( (F=FOOT3(rastr, D_X, 0, (uchar)Dx, (uchar)Hy,2))!=3 )
598
598
          P  = 10*step_diskr;
599
599
        else
600
 
          P += (step_diskr>>1)*DiskrSymSh(rastr, D_X, (Word8)Dx, (Word8)Hy);
 
600
          P += (step_diskr>>1)*DiskrSymSh(rastr, D_X, (uchar)Dx, (uchar)Hy);
601
601
        }
602
602
       if( inc<=0 && !broken_flag && DiskrSh0(rastr0, D_X, Dx, dy, dx)==0 )
603
603
        P +=step_diskr;
604
 
       F = FOOT(rastr, D_X,(Word8)Dx, (Word8)Hy,0);
 
604
       F = FOOT(rastr, D_X,(uchar)Dx, (uchar)Hy,0);
605
605
       // OLEG : ERECTION conditions : 09-20-95 08:34pm
606
606
       if( inc>0 && dnri_hook )
607
607
        {
608
 
        if( F>1 && DiskrSh(rastr, D_X, (Int16)(LOCAL[2]+LOCAL_W[2]/2), Hy) )
 
608
        if( F>1 && DiskrSh(rastr, D_X, (int16_t)(LOCAL[2]+LOCAL_W[2]/2), Hy) )
609
609
          P += step_diskr;
610
610
        }
611
611
       else
619
619
        P += step_diskr/2;
620
620
       if( DiskrRight(rastr0, D_X, Dx, dy,2) )
621
621
        P += step_diskr/2;
622
 
       if( FOOT3_2(rastr0,D_X,(Word8)Dx,(Word8)dy) )
 
622
       if( FOOT3_2(rastr0,D_X,(uchar)Dx,(uchar)dy) )
623
623
        P += step_diskr*3;
624
624
       diskr_sh = P;
625
625
       P=MAX(P,0);
627
627
       else  P = diskr_sh;
628
628
    break;
629
629
// capital & small >I<
630
 
    case (Word8)'�' :  case (Word8)'�' :
 
630
    case (uchar)'�' :  case (uchar)'�' :
631
631
    if( diskr_g<0 )
632
632
       {
633
633
       if( !DiskrLeftBig(rastr0, D_X, Dx, dy,2) )
634
634
        P+=3*step_diskr;
635
635
       if( !DiskrRightBig(rastr0, D_X, Dx, dy,2) )
636
636
        P+=3*step_diskr;
637
 
       F = FOOT(rastr, D_X,(Word8)Dx, (Word8)Hy,0);
638
 
       if( F!=3 && (n=DiskrJ0(rastr, D_X, Dx, Hy,(Int16)(dy<18?4:5)))!=0 )
 
637
       F = FOOT(rastr, D_X,(uchar)Dx, (uchar)Hy,0);
 
638
       if( F!=3 && (n=DiskrJ0(rastr, D_X, Dx, Hy,(int16_t)(dy<18?4:5)))!=0 )
639
639
        { /* middle tail have'nt 3-interval lines */
640
640
        if( !DiskrJ(rastr0, D_X, Dx, dy) )
641
641
          P+=2*n*step_diskr;
642
642
        }
643
 
       if( F!=3 && (n=DiskrJ0(rastr0, D_X, Dx, Hy,(Int16)(dy<18?2:3)))!=0 )
 
643
       if( F!=3 && (n=DiskrJ0(rastr0, D_X, Dx, Hy,(int16_t)(dy<18?2:3)))!=0 )
644
644
        { /* upper tail have'nt 3-interval lines  */
645
645
        if( !DiskrJ(rastr0, D_X, Dx, dy) )
646
646
          P+=2*n*step_diskr;
650
650
       else P = diskr_g;
651
651
    break;
652
652
// capital & small III,
653
 
    case (Word8)'�' :  case (Word8)'�' :
 
653
    case (uchar)'�' :  case (uchar)'�' :
654
654
    if( diskr_tsh<0 )
655
655
       {
656
 
       F= ((Word8)let==(Word8)'�' )?4:2;
657
 
       if( (F=FOOT(rastr0+F*D_X, D_X,(Word8)Dx,(Word8)Hy,0))!=3 )
 
656
       F= ((uchar)let==(uchar)'�' )?4:2;
 
657
       if( (F=FOOT(rastr0+F*D_X, D_X,(uchar)Dx,(uchar)Hy,0))!=3 )
658
658
        P = 10*step_diskr;
659
659
       else
660
660
        {
661
 
        P += (step_diskr>>1)*DiskrSymSh(rastr, D_X, (Word8)Dx, (Word8)Hy);
 
661
        P += (step_diskr>>1)*DiskrSymSh(rastr, D_X, (uchar)Dx, (uchar)Hy);
662
662
        if( DiskrTsh(rastr0+D_X,D_X,dx,dy,Dx)==1 )
663
663
          P += 3*step_diskr ;
664
664
        }
670
670
    else  P = diskr_tsh;
671
671
    break;
672
672
// capiatl & small IO
673
 
    case (Word8)'�' :  case (Word8)'�' :
 
673
    case (uchar)'�' :  case (uchar)'�' :
674
674
                //{
675
 
                //Int32 ret=DIF_GetNoCutPoint(rastr0, (Word8)dx, (Word8)dy);
 
675
                //int32_t ret=DIF_GetNoCutPoint(rastr0, (uchar)dx, (uchar)dy);
676
676
                //}
677
677
    if( diskr_ju<0 )
678
678
       {
679
 
       r=FOOT_HEI( rastr0, D_X, (Word8)dx, (Word8)dy);
 
679
       r=FOOT_HEI( rastr0, D_X, (uchar)dx, (uchar)dy);
680
680
       if( DiskrJuCut(r,dx) && r>1)
681
681
            P += 3*step_diskr;
682
682
       if( DiskrLeft(rastr0, D_X, Dx, dy,2) )
690
690
       else P = diskr_ju;
691
691
    break;
692
692
// capital & small M
693
 
    case (Word8)'�' :  case (Word8)'�' :
 
693
    case (uchar)'�' :  case (uchar)'�' :
694
694
      if( diskr_m<0 )
695
695
      {
696
696
      if( mii<-100 ){
705
705
             P+= 5*step_diskr;
706
706
 
707
707
    if( dy>13 )
708
 
      F=FOOT(rastr0+2*D_X, D_X,(Word8)Dx, (Word8)(dy-4),0);
 
708
      F=FOOT(rastr0+2*D_X, D_X,(uchar)Dx, (uchar)(dy-4),0);
709
709
    else
710
 
      F=FOOT(rastr0, D_X, (Word8)Dx, (Word8)dy,0);
 
710
      F=FOOT(rastr0, D_X, (uchar)Dx, (uchar)dy,0);
711
711
 
712
712
                   if( F==2 )
713
713
      {
722
722
    else  P = diskr_m;
723
723
    break;
724
724
// capital & small bl
725
 
    case (Word8)'�' :  case (Word8)'�' :
 
725
    case (uchar)'�' :  case (uchar)'�' :
726
726
    if( diskr_ii<0 )
727
727
      {
728
728
      if( mii<-100 )
749
749
 
750
750
 
751
751
 
752
 
Int16 small_density(Word8 *RAST,Int16 n,Int16 D_X,Int16 bw)
 
752
int16_t small_density(uchar *RAST,int16_t n,int16_t D_X,int16_t bw)
753
753
{
754
 
Int16 i,l,w,d;
755
 
Int16 b = bw << 3;
 
754
int16_t i,l,w,d;
 
755
int16_t b = bw << 3;
756
756
 
757
757
if( !omni && font_type==0 )
758
758
        return(1);
767
767
return( l<=(n/3) );
768
768
}
769
769
 
770
 
Int16 no_serific(Word8 *RASTR,Int16 dy,Int16 dx,Int16 wb)
 
770
int16_t no_serific(uchar *RASTR,int16_t dy,int16_t dx,int16_t wb)
771
771
{
772
 
Int16 l0=VertSum(RASTR,wb,dy,0);
773
 
Int16 l1=VertSum(RASTR,wb,dy,1);
774
 
Int16 l2=VertSum(RASTR,wb,dy,2);
775
 
Int16 r0=VertSum(RASTR,wb,dy,(Int16)(dx-1));
776
 
Int16 r1=VertSum(RASTR,wb,dy,(Int16)(dx-2));
777
 
Int16 r2=VertSum(RASTR,wb,dy,(Int16)(dx-3));
 
772
int16_t l0=VertSum(RASTR,wb,dy,0);
 
773
int16_t l1=VertSum(RASTR,wb,dy,1);
 
774
int16_t l2=VertSum(RASTR,wb,dy,2);
 
775
int16_t r0=VertSum(RASTR,wb,dy,(int16_t)(dx-1));
 
776
int16_t r1=VertSum(RASTR,wb,dy,(int16_t)(dx-2));
 
777
int16_t r2=VertSum(RASTR,wb,dy,(int16_t)(dx-3));
778
778
dy -= 2;
779
779
if( l0<dy && l1<=dy && l1>dy-2 && l2>dy )
780
780
        l1=l2;
784
784
return 1;
785
785
}
786
786
 
787
 
Int16 vert_stairs(Int16 arr[], Int16 lim)
 
787
int16_t vert_stairs(int16_t arr[], int16_t lim)
788
788
{
789
 
Int16 i,old,jmp;
 
789
int16_t i,old,jmp;
790
790
for(jmp=0,i=1,old=arr[0];i<lim;i++)
791
791
        {
792
792
        if( arr[i]==-1 )
805
805
/*  �����頥�   �業�� �����⠭�� �।�� ���ࢠ��� ��ફ����� ��       */
806
806
/*                                                                         */
807
807
/***************************************************************************/
808
 
static void DiskrIN(Word8 *RASTR,Int16 D_X,Int16 dy,Int16 bw,Int16 dx)
 
808
static void DiskrIN(uchar *RASTR,int16_t D_X,int16_t dy,int16_t bw,int16_t dx)
809
809
/***************************************************************************/
810
810
/****     *RASTR     㪠��⥫�   ��  ���ᨢ                         ********/
811
811
/****      dy        k�����⢮  ��ப                              ********/
812
812
/****      D_X       ������⢮  ���⮢  �  ��ப�                  ********/
813
813
/***************************************************************************/
814
 
{  Word8  n[256],hist[256];
815
 
   Int16   ua[256],da[256];
816
 
   Int16  i,n2=dy-2*(dy>>2),n4,mean,fine;
817
 
   Int16  incr,decr,old,neue,equ;
818
 
   Int16  l=beg2-end1-1,l_real,t,jump,rmin,rmax;
819
 
   Int16  ol=1,or=1;  /* ����� ᫥�� � �ࠢ� */
820
 
   Word8 *RAST ,*R;
 
814
{  uchar  n[256],hist[256];
 
815
   int16_t   ua[256],da[256];
 
816
   int16_t  i,n2=dy-2*(dy>>2),n4,mean,fine;
 
817
   int16_t  incr,decr,old,neue,equ;
 
818
   int16_t  l=beg2-end1-1,l_real,t,jump,rmin,rmax;
 
819
   int16_t  ol=1,or=1;  /* ����� ᫥�� � �ࠢ� */
 
820
   uchar *RAST ,*R;
821
821
 
822
822
 
823
823
n4 = MAX(dy/4,(LOCAL_W[0]+LOCAL_W[1])/4);
856
856
        }
857
857
if( l>3 )
858
858
{
859
 
Int16 up_space=-1, down_space=-1;
860
 
Int16 up_fill=0,down_fill=0,d;
 
859
int16_t up_space=-1, down_space=-1;
 
860
int16_t up_fill=0,down_fill=0,d;
861
861
for(R=RAST,i=n4;i<=dy-2;i++,R+=D_X)
862
862
        {
863
 
        d=SumIntervalBits(R,(Int16)(end1+ol),(Int16)(beg2-or+1))/3;
864
 
        hist[i]=(Word8)d;
 
863
        d=SumIntervalBits(R,(int16_t)(end1+ol),(int16_t)(beg2-or+1))/3;
 
864
        hist[i]=(uchar)d;
865
865
        if( d==l && !up_fill )
866
866
                up_fill=i;
867
867
        if( d==l && i<n4+n2 )
888
888
            {
889
889
            if( NumHorizInterval(RASTR+D_X*(i+1),bw)==1 )
890
890
        {
891
 
        Int16 j,d;
 
891
        int16_t j,d;
892
892
        up_space = (neue==l ? 0 : 1);
893
893
 
894
894
        for(j=i+1;j<dy-2 && hist[j]>=l-1;j++);
939
939
memset(ua,0xFF,dy<<1);
940
940
memset(da,0xFF,dy<<1);
941
941
i = end1+ol-1;
942
 
n[i] =(Word8) CenterVertInterval( RAST, D_X, n2, i,&ua[i],&da[i] );
 
942
n[i] =(uchar) CenterVertInterval( RAST, D_X, n2, i,&ua[i],&da[i] );
943
943
                                /* ����᭮� ���� �����            */
944
944
for(mean=l_real=0,i=end1+ol;i<=beg2-or;i++)
945
945
        {       /* ⠡��� ���⮢ �।�� ���⨪����� ���ࢠ���     */
946
 
        n[i] =(Word8)CenterVertInterval( RAST, D_X, n2, i,&ua[i],&da[i] );
 
946
        n[i] =(uchar)CenterVertInterval( RAST, D_X, n2, i,&ua[i],&da[i] );
947
947
        mean += n[i];
948
948
        if( n[i] )              /* mean   - �㬬�   ����⮢         */
949
949
                l_real++;       /* l_real - �᫮ ���㫥��� ����⮢    */
950
950
        }
951
 
n[i] = (Word8)CenterVertInterval( RAST, D_X, n2, i,&ua[i],&da[i]);
 
951
n[i] = (uchar)CenterVertInterval( RAST, D_X, n2, i,&ua[i],&da[i]);
952
952
                                /* ����᭮� �����                         */
953
953
if( l!=l_real && (l_real==2 || (n[end1]|n[end1+1]) && (n[beg2]|n[beg2-1])) )
954
954
        {               /* ������⢨� ��४������                   */
972
972
 
973
973
if( no_serific(RASTR,dy,dx,bw) )
974
974
        {       /* ����� ������ � ���ࢠ� ���� [dy/4,dy-dy/4] */
975
 
  Int16 nn4,nn2,h;
 
975
  int16_t nn4,nn2,h;
976
976
        nn4 = MAX(dy>>2,(LOCAL_W[0]+LOCAL_W[1])>>1);
977
977
  if( nn4>dy/3 ) nn4=dy/4;
978
978
  nn2 = dy - (nn4<<1);
1022
1022
         }
1023
1023
if( l_real<=1 )
1024
1024
{
1025
 
Int16 dy1=n2/*dy>>1*/,nn,mm,mm1,minup,mindown,zaz;
1026
 
Word8 *rrrr,*rrrr1;
 
1025
int16_t dy1=n2/*dy>>1*/,nn,mm,mm1,minup,mindown,zaz;
 
1026
uchar *rrrr,*rrrr1;
1027
1027
zaz = beg2 - end1;
1028
1028
for(    minup=mindown=zaz, rrrr=RASTR, rrrr1=RASTR+(dy-1)*D_X, i=0;
1029
1029
        i<3;    i++, rrrr+=D_X, rrrr1-=D_X)
1063
1063
        }
1064
1064
}
1065
1065
{
1066
 
Int16 z=beg2-end1+1;
 
1066
int16_t z=beg2-end1+1;
1067
1067
if( z>4 && l_real*2>z )
1068
1068
        IN_IN_Monus=1;  /* � ��४������ ࠧ�� � �����쪨� ! */
1069
1069
if(     l_real>4        ||      l-l_real<=3 && l>5 ||
1095
1095
if( l_real!=l && !(l_real==l-1 && (n[end1]==0||n[beg2]==0) ) )
1096
1096
if( !fill_center && l_real<=4 || l_real<=3 )
1097
1097
        {
1098
 
  Int16 an[2],en[2],ll,dy1=n2,san[2],sen[2],z;
 
1098
  int16_t an[2],en[2],ll,dy1=n2,san[2],sen[2],z;
1099
1099
        /* ���� ���饩 �� '�' �� �।��� ����� */
1100
1100
        an[0]=n[end1];
1101
1101
        an[1]=n[end1+1];
1110
1110
                        if( abs(an[i]-dy1)>2 )
1111
1111
                                an[i]=-1;
1112
1112
                        else
1113
 
                                n[end1+i]=(Word8)dy1,ll++;
 
1113
                                n[end1+i]=(uchar)dy1,ll++;
1114
1114
                        }
1115
1115
                if( en[i]>0 )
1116
1116
                        {
1117
1117
                        if( abs(en[i]-dy1)>2 )
1118
1118
                                en[i]=-1;
1119
1119
                        else
1120
 
                                n[beg2-i]=(Word8)dy1,ll++;
 
1120
                                n[beg2-i]=(uchar)dy1,ll++;
1121
1121
                        }
1122
1122
                }
1123
1123
        if( IN_I_Bonus==2 && ll==1 )
1127
1127
                for(i=0;i<2;i++)
1128
1128
                        {
1129
1129
                        if( an[i]>0 )
1130
 
                                n[end1+i]=(Word8)dy1;
 
1130
                                n[end1+i]=(uchar)dy1;
1131
1131
                        if( en[i]>0 )
1132
 
                                n[beg2-i]=(Word8)dy1;
 
1132
                                n[beg2-i]=(uchar)dy1;
1133
1133
                        }
1134
1134
                mean =  dy1;
1135
1135
                fill_center=1;
1140
1140
                {
1141
1141
                for(i=0;i<2;i++)
1142
1142
                        {
1143
 
                        n[beg2-i]=(Word8)sen[i];
1144
 
                        n[end1+i]=(Word8)san[i];
 
1143
                        n[beg2-i]=(uchar)sen[i];
 
1144
                        n[end1+i]=(uchar)san[i];
1145
1145
                        }
1146
1146
        /* ���� ���饩 �� '�' �� ࠧ�� ��஭� �� �।��� ����� */
1147
1147
                an[0]=n[end1];
1150
1150
                en[1]=n[beg2];
1151
1151
                for(ll=i=0;i<2;i++)
1152
1152
                        {
1153
 
                        z=VertSum(RAST, D_X, n2, (Int16)(end1+i));
 
1153
                        z=VertSum(RAST, D_X, n2, (int16_t)(end1+i));
1154
1154
                        if( an[i]>0 && an[i]<dy1-2 && z<n4 )
1155
1155
                                ll++;
1156
 
                        z=VertSum(RAST, D_X, n2, (Int16)(beg2-i));
 
1156
                        z=VertSum(RAST, D_X, n2, (int16_t)(beg2-i));
1157
1157
                        if( en[i]>0 && en[i]>dy1+2 && z<n4)
1158
1158
                                ll++;
1159
1159
                        }
1173
1173
{
1174
1174
if( fill_center && l_real>l-3 && l>2 )
1175
1175
{
1176
 
Int16 lim = (beg2-or-end1+ol)>>1;
 
1176
int16_t lim = (beg2-or-end1+ol)>>1;
1177
1177
for(t=0,i=end1+ol;i<=lim;i++)
1178
1178
        if( n[i]>((n2-2)<<1) )
1179
1179
                t++;
1223
1223
        fine+=2;        /* 2 ᪠窠 � 3-� �⮫��� */
1224
1224
 
1225
1225
if( omni ){
1226
 
Int16 fin=fine,inc=incr,dec=decr;
 
1226
int16_t fin=fine,inc=incr,dec=decr;
1227
1227
 
1228
1228
neue = n[end1];
1229
1229
if( ol && neue && neue<n[end1+1] )
1291
1291
                                /* ������⢠ ����� 3              */
1292
1292
        if( equ>1 && fine<6 )
1293
1293
                {
1294
 
    Int16 fineold=fine;
 
1294
    int16_t fineold=fine;
1295
1295
                t = n4 + n2 - (t>>1);
1296
1296
                for( RAST=RASTR+D_X*(t-2),i=t-2;i<=t+2;i++,RAST+=D_X)
1297
 
                        if( SumIntervalBits(RAST,end1,(Int16)(beg2+1))==
 
1297
                        if( SumIntervalBits(RAST,end1,(int16_t)(beg2+1))==
1298
1298
                                (beg2-end1+1)*3 )
1299
1299
                                {               /* ���� ��४������ */
1300
1300
                                fine=0;
1402
1402
                        }
1403
1403
if( omni )
1404
1404
        {       /* '�' ��⠥��� � '�' */
1405
 
  Int16 i,le,ri,nnn=(beg2+end1+ol-or)/2;
 
1405
  int16_t i,le,ri,nnn=(beg2+end1+ol-or)/2;
1406
1406
        if( fine>15 && decr>3 || fine>20 && decr>2 ||
1407
1407
            fine>10 && incr<1 && decr>3 ) //RUS_ENG_LANG
1408
1408
                IN_I=1;
1434
1434
        }
1435
1435
 
1436
1436
{
1437
 
Int16 up_skip=vert_stairs(&ua[end1],(Int16)(beg2-end1+1));
1438
 
Int16 down_skip=vert_stairs(&da[end1],(Int16)(beg2-end1+1));
 
1437
int16_t up_skip=vert_stairs(&ua[end1],(int16_t)(beg2-end1+1));
 
1438
int16_t down_skip=vert_stairs(&da[end1],(int16_t)(beg2-end1+1));
1439
1439
 
1440
1440
if( IN_I<=3 )
1441
1441
if( up_skip>3 && down_skip>3 ||
1453
1453
}                       /*              DiskrIN                 */
1454
1454
 
1455
1455
/***************************************************************************/
1456
 
Int16 DiskrHorizIN(Word8 *RASTR,Int16 D_X,Int16 dy)
 
1456
int16_t DiskrHorizIN(uchar *RASTR,int16_t D_X,int16_t dy)
1457
1457
/***************************************************************************/
1458
1458
/****     *RASTR     㪠��⥫�   ��  ���ᨢ                         ********/
1459
1459
/****      dy        k�����⢮  ��ப                              ********/
1460
1460
/****      D_X       ������⢮  ���⮢  �  ��ப�                  ********/
1461
1461
/***************************************************************************/
1462
 
{  Word8 n[256];
1463
 
   Int16  i,j,n2=dy-2*(dy>>2),n4=dy>>2,imax,nmax,kmax;
1464
 
   Int16 l = beg2 - end1 ,h;
1465
 
   Word8 *RAST = RASTR+D_X*n4;
 
1462
{  uchar n[256];
 
1463
   int16_t  i,j,n2=dy-2*(dy>>2),n4=dy>>2,imax,nmax,kmax;
 
1464
   int16_t l = beg2 - end1 ,h;
 
1465
   uchar *RAST = RASTR+D_X*n4;
1466
1466
 
1467
1467
 
1468
1468
if( IN_horiz_dis>=0 )
1500
1500
return (IN_horiz_dis= (h&&l) ) ;
1501
1501
}                       /*              DiskrHorizIN            */
1502
1502
 
1503
 
Int16 fill_center_zone(Word8 *raster,Int16 D_X,Int16 dy,
1504
 
      Int16 beg, Int16 end, Int16 II)
 
1503
int16_t fill_center_zone(uchar *raster,int16_t D_X,int16_t dy,
 
1504
      int16_t beg, int16_t end, int16_t II)
1505
1505
{
1506
 
Int16 i,num,l,ny,d=((end-beg)>>1),p, white, w;
1507
 
Word8 *r=raster;
 
1506
int16_t i,num,l,ny,d=((end-beg)>>1),p, white, w;
 
1507
uchar *r=raster;
1508
1508
 
1509
1509
#ifdef INTERSEPTOR
1510
1510
end--;beg++;
1520
1520
 
1521
1521
for(ny=num=i=0;i<dy;i++,r+=D_X)
1522
1522
        {
1523
 
        l = SumIntervalBits(r,beg,(Int16)(end+p))/3;
 
1523
        l = SumIntervalBits(r,beg,(int16_t)(end+p))/3;
1524
1524
        if( i==0 && l>=d )
1525
1525
                continue;
1526
1526
    w = end+p-beg-l;
1561
1561
return( fill_center );
1562
1562
}
1563
1563
 
1564
 
Int16 up_down_hist_M(Word8 *rastr,Int16 D_X, Int16 Dx,Int16 dy)
 
1564
int16_t up_down_hist_M(uchar *rastr,int16_t D_X, int16_t Dx,int16_t dy)
1565
1565
{
1566
 
Int16 i,j,d,h=dy>>1,s,t,n;
1567
 
Word8 *r;
 
1566
int16_t i,j,d,h=dy>>1,s,t,n;
 
1567
uchar *r;
1568
1568
 
1569
1569
Dx =  bytlen(Dx);
1570
1570
for(s=j=0,i=0,r=rastr+i*D_X;i<h;j++,i++,r+=D_X)
1592
1592
return(4);
1593
1593
}
1594
1594
 
1595
 
Int16 broken_M(Word8 * r,Int16 D_X,Int16 dy,Int16 left_lim,Int16 ll)
 
1595
int16_t broken_M(uchar * r,int16_t D_X,int16_t dy,int16_t left_lim,int16_t ll)
1596
1596
{
1597
 
Int16 i,old,neue,dest,sign,fc,maxd,incr;
1598
 
Word8 *rr;
 
1597
int16_t i,old,neue,dest,sign,fc,maxd,incr;
 
1598
uchar *rr;
1599
1599
if( broken_M_pen>=0 )
1600
1600
        return broken_M_pen;
1601
1601
old=RightDistance(r,D_X);
1638
1638
}
1639
1639
 
1640
1640
 
1641
 
Int16 Num2Interval(Word8 *r,Int16 D_X,Int16 dx,Int16 dy)
 
1641
int16_t Num2Interval(uchar *r,int16_t D_X,int16_t dx,int16_t dy)
1642
1642
{
1643
 
Int16 i,n2,p,d;
 
1643
int16_t i,n2,p,d;
1644
1644
d = bytlen(dx);
1645
1645
for(i=1;i<3;i++)
1646
1646
if(     (p=NumHorizInterval(r-D_X*i,d))==1 &&
1655
1655
return ( n2==dy );
1656
1656
}
1657
1657
/* DiskrRight : check left hole */
1658
 
Int16 DiskrRight(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 L)
 
1658
int16_t DiskrRight(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t L)
1659
1659
{
1660
 
Int16 sum,p,x,dl,Ly,i,p_old,curr_sum,h;
1661
 
Int16 minr,maxr,ddy;
1662
 
Word8 *RASTER=RASTR+D_X*(dy>>2),*R;
 
1660
int16_t sum,p,x,dl,Ly,i,p_old,curr_sum,h;
 
1661
int16_t minr,maxr,ddy;
 
1662
uchar *RASTER=RASTR+D_X*(dy>>2),*R;
1663
1663
if( right_dist[L]>=0 )
1664
1664
        return( right_dist[L] );
1665
1665
 
1669
1669
 
1670
1670
dl=(((dx+7)>>3)<<3);
1671
1671
ddy = dy>30 ? (dy>>3):(dy>>2);
1672
 
MinMaxRight(RASTER,D_X,(Word8)dx,(Word8)Ly,&minr,&maxr);
 
1672
MinMaxRight(RASTER,D_X,(uchar)dx,(uchar)Ly,&minr,&maxr);
1673
1673
x = maxr - minr;
1674
1674
if( maxr-((dx&7)?(8-(dx&7)):0)>(dx>>1) )
1675
1675
        {
1682
1682
        {
1683
1683
        right_line=0;
1684
1684
        if( dy>17 )
1685
 
        while( VertSum(R,D_X,h,(Int16)(dl-minr))<ddy && minr<maxr)minr++;
 
1685
        while( VertSum(R,D_X,h,(int16_t)(dl-minr))<ddy && minr<maxr)minr++;
1686
1686
        for(p_old=-1,sum=curr_sum=0,i=minr ; i<=maxr ; i++ )
1687
1687
                {
1688
 
                p = NumVertInterval(R, D_X, h, (Int16)(dl-i));
 
1688
                p = NumVertInterval(R, D_X, h, (int16_t)(dl-i));
1689
1689
                if( p>=2 )
1690
1690
                        {          /* ��begin 2-intervals�series of columns */
1691
1691
                        if( p_old<2 )
1713
1713
}
1714
1714
 
1715
1715
 
1716
 
static Int16 DiskrSymSh( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NLENGTH)
 
1716
static int16_t DiskrSymSh( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NLENGTH)
1717
1717
{
1718
 
  Int16 i,old,l,k,d;
1719
 
  Word8 c,w,minw=255,maxw=0;
 
1718
  int16_t i,old,l,k,d;
 
1719
  uchar c,w,minw=255,maxw=0;
1720
1720
 
1721
1721
  FOOT_A(RASTER,Wx,NWIDTH,NLENGTH);   /* projection to horiz axes */
1722
1722
 
1757
1757
  return(i);
1758
1758
}
1759
1759
 
1760
 
static Int16 DiskrSh(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly)
 
1760
static int16_t DiskrSh(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly)
1761
1761
{
1762
 
Word8 *RASTER=RASTR;
1763
 
Int16 i,num,n2,p,ddx;
 
1762
uchar *RASTER=RASTR;
 
1763
int16_t i,num,n2,p,ddx;
1764
1764
ddx = bytlen(dx);
1765
1765
for(n2=num=i=0;i<Ly; i++, RASTER+=D_X )
1766
1766
  {
1772
1772
 
1773
1773
if( n2 )
1774
1774
{ /* 2-interval lines are exist */
1775
 
Int16 b=(LOCAL[0]+LOCAL[1])/2,dd=(LOCAL[1]-LOCAL[0])+(LOCAL_W[1]+LOCAL_W[0])/2;
 
1775
int16_t b=(LOCAL[0]+LOCAL[1])/2,dd=(LOCAL[1]-LOCAL[0])+(LOCAL_W[1]+LOCAL_W[0])/2;
1776
1776
i = Ly<<1;
1777
1777
i = Ly/3-(Ly>>2);
1778
1778
Ly -= i;
1787
1787
}
1788
1788
 
1789
1789
/* for letters III */
1790
 
static Int16 DiskrSh0(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 dx0)
 
1790
static int16_t DiskrSh0(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t dx0)
1791
1791
{
1792
 
Word8 *RASTER=RASTR+D_X*(dy-(dy>>2));
1793
 
Int16 i,num,l=dx0-(dx0>>2);
 
1792
uchar *RASTER=RASTR+D_X*(dy-(dy>>2));
 
1793
int16_t i,num,l=dx0-(dx0>>2);
1794
1794
if( lower_long_line<0 )
1795
1795
{
1796
1796
dx = bytlen(dx);
1803
1803
}
1804
1804
 
1805
1805
/*  DiskrLeft : check left hole */
1806
 
Int16 DiskrLeft(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy, Int16 L)
 
1806
int16_t DiskrLeft(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy, int16_t L)
1807
1807
{
1808
 
Int16 sum,p,x,i,Ly,p_old,curr_sum,h;
1809
 
Int16 minr,maxr;
1810
 
Word8 *RASTER=RASTR+D_X*(dy>>2),*R;
 
1808
int16_t sum,p,x,i,Ly,p_old,curr_sum,h;
 
1809
int16_t minr,maxr;
 
1810
uchar *RASTER=RASTR+D_X*(dy>>2),*R;
1811
1811
if( left_dist[L]>=0 )
1812
1812
  return( left_dist[L] );
1813
1813
Ly=dy-2*(dy>>2);
1814
1814
h=Ly;
1815
1815
R=RASTER;
1816
1816
 
1817
 
MinMaxLeft(RASTER,D_X,(Word8)dx,(Word8)Ly,&minr,&maxr);
 
1817
MinMaxLeft(RASTER,D_X,(uchar)dx,(uchar)Ly,&minr,&maxr);
1818
1818
if( minr && maxr )
1819
1819
  {
1820
1820
  minr--; maxr--;
1861
1861
}
1862
1862
 
1863
1863
/*  DiskrLeftBig : check big left hole� */
1864
 
Int16 DiskrLeftBig(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy, Int16 L)
 
1864
int16_t DiskrLeftBig(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy, int16_t L)
1865
1865
{
1866
 
Int16 sum,p,x,i,Ly,p_old,curr_sum,h;
1867
 
Int16 minr,maxr;
1868
 
Word8 *RASTER=RASTR+D_X,*R;
 
1866
int16_t sum,p,x,i,Ly,p_old,curr_sum,h;
 
1867
int16_t minr,maxr;
 
1868
uchar *RASTER=RASTR+D_X,*R;
1869
1869
if( left_dist_big[L]>=0 )
1870
1870
  return( left_dist_big[L] );
1871
1871
 
1873
1873
h =  dy ;
1874
1874
R =  RASTR;
1875
1875
 
1876
 
MinMaxLeft(RASTER,D_X,(Word8)dx,(Word8)Ly,&minr,&maxr);
 
1876
MinMaxLeft(RASTER,D_X,(uchar)dx,(uchar)Ly,&minr,&maxr);
1877
1877
if( minr && maxr )
1878
1878
  {
1879
1879
  minr--; maxr--;
1911
1911
}
1912
1912
 
1913
1913
/*  DiskrRightBig : check big right hole */
1914
 
Int16 DiskrRightBig(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 L)
 
1914
int16_t DiskrRightBig(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t L)
1915
1915
{
1916
 
Int16 sum,p,x,dl,Ly,i,p_old,curr_sum,h;
1917
 
Int16 minr,maxr;
1918
 
Word8 *RASTER=RASTR+D_X,*R;
 
1916
int16_t sum,p,x,dl,Ly,i,p_old,curr_sum,h;
 
1917
int16_t minr,maxr;
 
1918
uchar *RASTER=RASTR+D_X,*R;
1919
1919
if( right_dist_big[L]<0 )
1920
1920
{
1921
1921
Ly=dy-2;
1923
1923
R =  RASTR;
1924
1924
 
1925
1925
dl=(((dx+7)>>3)<<3);
1926
 
MinMaxRight(RASTER,D_X,(Word8)dx,(Word8)Ly,&minr,&maxr);
 
1926
MinMaxRight(RASTER,D_X,(uchar)dx,(uchar)Ly,&minr,&maxr);
1927
1927
x = maxr - minr;
1928
1928
right_dist_big[L] = ( x>=L );
1929
1929
if( right_dist_big[L] )       /* big hole */
1930
1930
  {
1931
 
  if( dy<13 || VertSum(RASTR, D_X, dy, (Int16)(dl-minr))<dy-2)
 
1931
  if( dy<13 || VertSum(RASTR, D_X, dy, (int16_t)(dl-minr))<dy-2)
1932
1932
  {
1933
1933
  if( dy>17 )
1934
 
  while( VertSum(R,D_X,h,(Int16)(dl-minr))<(dy>>2) && minr<maxr)minr++;
 
1934
  while( VertSum(R,D_X,h,(int16_t)(dl-minr))<(dy>>2) && minr<maxr)minr++;
1935
1935
  for(p_old=-1,sum=curr_sum=0,i=minr ; i<=maxr ; i++ )
1936
1936
    {
1937
 
    p = NumVertInterval(R, D_X, h, (Int16)(dl-i));
 
1937
    p = NumVertInterval(R, D_X, h, (int16_t)(dl-i));
1938
1938
    if( p>=2 )
1939
1939
      {          /* begin 2-intervals�series of columns */
1940
1940
      if( p_old<2 )
1966
1966
}
1967
1967
 
1968
1968
/* for letters >|< */
1969
 
static Int16 DiskrJ0(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly,Int16 lim)
 
1969
static int16_t DiskrJ0(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly,int16_t lim)
1970
1970
{
1971
 
Word8 *RASTER=RASTR;
1972
 
Int16 i,three,n,all,ret,one;
 
1971
uchar *RASTER=RASTR;
 
1972
int16_t i,three,n,all,ret,one;
1973
1973
 
1974
1974
dx = bytlen(dx);
1975
1975
for(one=all=three=i=0;i<Ly; i++, RASTER+=D_X )
1999
1999
return( ret );
2000
2000
}
2001
2001
 
2002
 
static Int16 DiskrJ(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy)
 
2002
static int16_t DiskrJ(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy)
2003
2003
{
2004
 
Int16 i,t,tu,td,Ly=dy>>2,ly=dy-2*Ly,p,l=dy>>1;
 
2004
int16_t i,t,tu,td,Ly=dy>>2,ly=dy-2*Ly,p,l=dy>>1;
2005
2005
dx = bytlen(dx);
2006
2006
for(tu=i=0;i<Ly; i++, RASTR+=D_X )
2007
2007
  tu += ( NumHorizInterval(RASTR,dx)==3 );
2026
2026
//***************************************************************************
2027
2027
//*   return       1 if stick glued to rusian D, otherwise 0                *
2028
2028
//***************************************************************************
2029
 
static Int16 DiskrTsh(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 Dx)
2030
 
{  Word8  j,n4=dy>>2,bool_foot=1;
2031
 
   Word8  bit0,bit1,bit2;
2032
 
   Int16            i,fine=0;
2033
 
   Word8  *RAST;
 
2029
static int16_t DiskrTsh(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t Dx)
 
2030
{  uchar  j,n4=dy>>2,bool_foot=1;
 
2031
   uchar  bit0,bit1,bit2;
 
2032
   int16_t            i,fine=0;
 
2033
   uchar  *RAST;
2034
2034
 
2035
2035
//****************   check existance two hooks  ******************
2036
2036
 
2037
2037
 
2038
2038
   for (RAST=RASTR+(dy-3)*D_X,i=dy-3;;i--,RAST-=D_X){
2039
 
      j=SumIntervalBits( RAST,(Int16)0,(Int16)dx )/3 ;
 
2039
      j=SumIntervalBits( RAST,(int16_t)0,(int16_t)dx )/3 ;
2040
2040
      if(  (j > 5*D_X) || (i<2*n4) ) break;
2041
 
      j=(Word8)NumHorizInterval( RAST, D_X );
 
2041
      j=(uchar)NumHorizInterval( RAST, D_X );
2042
2042
      if( j > 1 )  fine+=20;
2043
2043
   }
2044
2044
   if( fine < 30 ){     return ( 0 );   }
2053
2053
 
2054
2054
fine=0;
2055
2055
   for (RAST=RASTR,i=0;i<n4;i++,RAST+=D_X){
2056
 
      j=SumIntervalBits(RAST,(Int16)bit0,(Int16)bit1)/3;
 
2056
      j=SumIntervalBits(RAST,(int16_t)bit0,(int16_t)bit1)/3;
2057
2057
      if( j >  3*(bit1-bit0)/5 )    fine+=20;
2058
2058
      if( j == (bit1-bit0) )        goto end;
2059
2059
   }
2061
2061
 
2062
2062
//******************  make histogramm   ********************************
2063
2063
 
2064
 
   FOOT_A(RASTR, D_X, (Word8)Dx, (Word8)n4); bool_foot=0;
 
2064
   FOOT_A(RASTR, D_X, (uchar)Dx, (uchar)n4); bool_foot=0;
2065
2065
 
2066
2066
   for(i=bit0+1;i<bit1+1;i++){
2067
2067
      if(BUFFER[i]==0)  goto   bbb;//* breaking
2072
2072
 
2073
2073
bbb:fine=0;
2074
2074
   for (RAST=RASTR,i=0;i<n4;i++,RAST+=D_X){
2075
 
      j=SumIntervalBits(RAST,(Int16)bit1,(Int16)bit2)/3;
 
2075
      j=SumIntervalBits(RAST,(int16_t)bit1,(int16_t)bit2)/3;
2076
2076
      if( j >  3*(bit2-bit1)/5 )     fine+=20;
2077
2077
      if( j == (bit2-bit1) )             {  return(1); }
2078
2078
   }
2080
2080
 
2081
2081
//******************  make histogramm  ********************************
2082
2082
 
2083
 
   if( bool_foot ) FOOT_A(RASTR, D_X, (Word8)Dx, (Word8)n4);
 
2083
   if( bool_foot ) FOOT_A(RASTR, D_X, (uchar)Dx, (uchar)n4);
2084
2084
   for(i=bit1+1;i<bit2+1;i++){
2085
2085
      if(BUFFER[i]==0)  goto   end; // breaking
2086
2086
   }
2091
2091
}  // DiskrTsh
2092
2092
 
2093
2093
 
2094
 
static Int16 average_br_angle(Word8 *RASTER, Int16 D_X, Int16 dx, Int16 dy,
2095
 
        Int16 t)
 
2094
static int16_t average_br_angle(uchar *RASTER, int16_t D_X, int16_t dx, int16_t dy,
 
2095
        int16_t t)
2096
2096
{
2097
2097
if( av_br<0 )
2098
2098
  av_br=average_angle(RASTER+D_X*(dy-(dy>>2)),
2099
 
    D_X,dx,(Int16)(dy>>2),RightDistance,t);
 
2099
    D_X,dx,(int16_t)(dy>>2),RightDistance,t);
2100
2100
return(av_br);
2101
2101
}
2102
2102
 
2103
 
static Int16 average_angle(Word8 *RASTER, Int16 D_X, Int16 dx, Int16 dy,
2104
 
       Int16  (*Distance)(Word8 *, Int16), Int16 t)
 
2103
static int16_t average_angle(uchar *RASTER, int16_t D_X, int16_t dx, int16_t dy,
 
2104
       int16_t  (*Distance)(uchar *, int16_t), int16_t t)
2105
2105
{
2106
 
Int16 i=0,n,p,H;
 
2106
int16_t i=0,n,p,H;
2107
2107
if( t==0 )
2108
2108
{       /* cut long lines for finding corners */
2109
 
while( SumBits(RASTER,(Int16)(bytlen(dx)))>(dx>>1) && i<dy )
 
2109
while( SumBits(RASTER,(int16_t)(bytlen(dx)))>(dx>>1) && i<dy )
2110
2110
  {
2111
2111
  i++;
2112
2112
  RASTER+=D_X;  /* black strings */
2113
2113
  }
2114
2114
}
2115
2115
for(H=n=0;i<dy; i++,RASTER+=D_X)
2116
 
  if( (p=Distance(RASTER,(Int16)(bytlen(dx))))>=0 )
 
2116
  if( (p=Distance(RASTER,(int16_t)(bytlen(dx))))>=0 )
2117
2117
    {
2118
2118
    H++;
2119
2119
    n+=p; /* nonzero string */
2121
2121
return(H?n/H:-1);
2122
2122
}
2123
2123
 
2124
 
static Int16 DiskrJu(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly)
 
2124
static int16_t DiskrJu(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly)
2125
2125
{
2126
 
Word8 *RASTER=RASTR;
2127
 
Int16 i,ret,r,s2,s3,n;
 
2126
uchar *RASTER=RASTR;
 
2127
int16_t i,ret,r,s2,s3,n;
2128
2128
dx = bytlen(dx);
2129
2129
 
2130
2130
for(n=s2=s3=i=0;i<Ly; i++, RASTER+=D_X,n++ )
2142
2142
return  (ret) ;
2143
2143
}
2144
2144
 
2145
 
static Int16 DiskrimM1(Word8 *RAST,Int16 D_X,Int16 dx,Int16 dy)
 
2145
static int16_t DiskrimM1(uchar *RAST,int16_t D_X,int16_t dx,int16_t dy)
2146
2146
{
2147
 
   Int16    n2,n4=dy>>2,meanBit=dx>>1; /* Oleg & Vova 09.03.94 */
2148
 
   Int16    i,j,k,up=0,down=0,cUp=0,cDown=0;
2149
 
   Int16    prev=0,byte=0;
2150
 
   Word8   *r;
 
2147
   int16_t    n2,n4=dy>>2,meanBit=dx>>1; /* Oleg & Vova 09.03.94 */
 
2148
   int16_t    i,j,k,up=0,down=0,cUp=0,cDown=0;
 
2149
   int16_t    prev=0,byte=0;
 
2150
   uchar   *r;
2151
2151
 
2152
2152
/*  calculate  mean  of  hole  */
2153
2153
   for(r=RAST+D_X,i=0;i<n4;i++,r+=D_X){
2217
2217
   return(0);
2218
2218
}  /* DiskrM1 */
2219
2219
 
2220
 
static Int16 DiskrimM(Word8 *RAST,Int16 D_X,Int16 dx,Int16 dy)
 
2220
static int16_t DiskrimM(uchar *RAST,int16_t D_X,int16_t dx,int16_t dy)
2221
2221
{
2222
 
   Int16    n2,n4=dy>>2,meanBit=dx>>1; /* Oleg & Vova 09.03.94 */
2223
 
   Int16    i,j,k,up=0,down=0,cUp=0,cDown=0;
2224
 
   Int16    prev=0,byte=0;
2225
 
   Word8   *r;
 
2222
   int16_t    n2,n4=dy>>2,meanBit=dx>>1; /* Oleg & Vova 09.03.94 */
 
2223
   int16_t    i,j,k,up=0,down=0,cUp=0,cDown=0;
 
2224
   int16_t    prev=0,byte=0;
 
2225
   uchar   *r;
2226
2226
 
2227
2227
/*  calculate  mean  of  hole  */
2228
2228
   for(r=RAST+D_X,i=0;i<n4;i++,r+=D_X){
2294
2294
}  /* DiskrM */
2295
2295
 
2296
2296
 
2297
 
static Int16 whiteMeanBitLeft(Word8 *RAST,Int16 D_X,Int16 meanBit)
 
2297
static int16_t whiteMeanBitLeft(uchar *RAST,int16_t D_X,int16_t meanBit)
2298
2298
{
2299
 
   Int16    meanByte, byte;
2300
 
   Int16    i,counter=0;
 
2299
   int16_t    meanByte, byte;
 
2300
   int16_t    i,counter=0;
2301
2301
 
2302
2302
   for(i=meanBit;i>=0;i--){
2303
2303
      meanByte = i>>3;
2332
2332
   return( counter );
2333
2333
}  /* whiteMeanBitLeft */
2334
2334
 
2335
 
static Int16 whiteMeanBitRight(Word8 *RAST,Int16 D_X,Int16 dx,Int16 meanBit)
 
2335
static int16_t whiteMeanBitRight(uchar *RAST,int16_t D_X,int16_t dx,int16_t meanBit)
2336
2336
{
2337
 
   Int16    meanByte, byte;
2338
 
   Int16    i,counter=0;
 
2337
   int16_t    meanByte, byte;
 
2338
   int16_t    i,counter=0;
2339
2339
 
2340
2340
   for(i=meanBit+1;i<dx;i++){
2341
2341
      meanByte = i>>3;
2371
2371
}  /* whiteMeanBitRight */
2372
2372
 
2373
2373
// check gluing roof and down zone for russian capital & small II
2374
 
Int16 up_down_zones(Word8 *raster, Int16 D_X, Int16 dx, Int16 dx0,
2375
 
      Int16 start1, Int16 stop1,
2376
 
      Int16 start2, Int16 stop2)
 
2374
int16_t up_down_zones(uchar *raster, int16_t D_X, int16_t dx, int16_t dx0,
 
2375
      int16_t start1, int16_t stop1,
 
2376
      int16_t start2, int16_t stop2)
2377
2377
{
2378
 
Int16 i,num1,num2,l=dx0-(dx0>>3);
2379
 
Word8 *r=raster;
 
2378
int16_t i,num1,num2,l=dx0-(dx0>>3);
 
2379
uchar *r=raster;
2380
2380
if( up_down_serif>=0 )
2381
2381
  return( up_down_serif );
2382
2382
 
2403
2403
}
2404
2404
 
2405
2405
/* for letters 'C','c','e' */
2406
 
static Int16 DiskrVertCE(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 X,
2407
 
                        Word8 let, Word8 inc)
 
2406
static int16_t DiskrVertCE(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t X,
 
2407
                        uchar let, uchar inc)
2408
2408
{
2409
 
Word8 *RASTER=RASTR;
2410
 
Int16 i,p,n,s3,d=dx>>2,wid=bytlen(dx);
2411
 
Int16 ody=dy>>2;
2412
 
  Word8 *r=RASTR+ody*D_X;
2413
 
  Int16 t1,t2,t3,num1,num2,num3,minnum,n2;
2414
 
  Int16 l = dy -(ody<<1),num,z=dx-(dx>>3);
2415
 
  Int16 nn[7];
 
2409
uchar *RASTER=RASTR;
 
2410
int16_t i,p,n,s3,d=dx>>2,wid=bytlen(dx);
 
2411
int16_t ody=dy>>2;
 
2412
  uchar *r=RASTR+ody*D_X;
 
2413
  int16_t t1,t2,t3,num1,num2,num3,minnum,n2;
 
2414
  int16_t l = dy -(ody<<1),num,z=dx-(dx>>3);
 
2415
  int16_t nn[7];
2416
2416
 
2417
2417
if( c_or_e<0 )
2418
2418
  {
2447
2447
    d_e = 0;
2448
2448
    d_c = num;
2449
2449
    if( num3 ) d_c += (minnum==1?4:3);
2450
 
    return( (let==(Word8)'�')?d_e:d_c );
 
2450
    return( (let==(uchar)'�')?d_e:d_c );
2451
2451
    }
2452
2452
if( num==0 && num1==0  && num2==0 && dy<24 )
2453
2453
{       /* ��� ���� ����⨢ ���� �ࠢ��� ண� */
2490
2490
  c_or_e = 1;     /* ��� ����� ������� ��ப       */
2491
2491
  d_e = 0;
2492
2492
  d_c = 1+t2-t1;
2493
 
  if( (let==(Word8)'�') )
 
2493
  if( (let==(uchar)'�') )
2494
2494
  return( d_e );
2495
2495
  }
2496
2496
}
2500
2500
  X &= 7;
2501
2501
  for(n=s3=0,i=d;i<dx; i++)
2502
2502
    {
2503
 
    p = NumVertInterval(RASTER, D_X, dy, (Int16)(i+X));
 
2503
    p = NumVertInterval(RASTER, D_X, dy, (int16_t)(i+X));
2504
2504
    s3 += ( p==3 );
2505
2505
    if( p==3 || p==2 )n++;
2506
2506
    }
2516
2516
    d_e = 4;
2517
2517
  d_c = MAX(d_c,(s3>n)?s3-n+1:0);
2518
2518
  }
2519
 
return( (let==(Word8)'�')?d_e:d_c );
 
2519
return( (let==(uchar)'�')?d_e:d_c );
2520
2520
}
2521
2521
 
2522
2522
 
2523
 
Int16 AngleBottomRight(Word8 *raster,Int16 D_X,Int16 hei)
 
2523
int16_t AngleBottomRight(uchar *raster,int16_t D_X,int16_t hei)
2524
2524
{
2525
2525
int i,old,neue,inc;
2526
 
Word8 *r;
 
2526
uchar *r;
2527
2527
 
2528
2528
raster += D_X * (hei-2);
2529
2529
hei >>= 2;
2539
2539
return inc;
2540
2540
}
2541
2541
 
2542
 
Int16 AngleTopRight(Word8 *raster,Int16 D_X,Int16 hei)
 
2542
int16_t AngleTopRight(uchar *raster,int16_t D_X,int16_t hei)
2543
2543
{
2544
2544
int i,old,neue,inc;
2545
 
Word8 *r;
 
2545
uchar *r;
2546
2546
 
2547
2547
raster += D_X;
2548
2548
hei >>= 2;
2558
2558
return inc;
2559
2559
}
2560
2560
 
2561
 
Int16 BonusAnglesCurve(Word8 *raster,Int16 D_X,Int16 hei)
 
2561
int16_t BonusAnglesCurve(uchar *raster,int16_t D_X,int16_t hei)
2562
2562
{
2563
2563
int pen=0,inc;
2564
2564
 
2571
2571
return pen;
2572
2572
}
2573
2573
 
2574
 
Bool32 DiskrJuCut(Int16 nfoot, Int16 dx)
 
2574
Bool32 DiskrJuCut(int16_t nfoot, int16_t dx)
2575
2575
{
2576
2576
int i,l,d;
2577
2577
l = dx*3/4;
2582
2582
return FALSE;
2583
2583
}
2584
2584
 
2585
 
DIF_FUNC(Int16) DIF_GetNoCutPoint(Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NLENGTH)
 
2585
DIF_FUNC(int16_t) DIF_GetNoCutPoint(uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NLENGTH)
2586
2586
{
2587
 
Int16 f=FOOT_HEI( RASTER, Wx, NWIDTH, NLENGTH);
 
2587
int16_t f=FOOT_HEI( RASTER, Wx, NWIDTH, NLENGTH);
2588
2588
if( f!=2 || f==2 && (LOCAL[0]-(LOCAL_W[0]+1)/2)>(LOCAL_W[0]+1)/2 )
2589
2589
        return 0;
2590
2590
return LOCAL[1]+(LOCAL_W[1]+1)/2;