~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/faxg3/run_tbl.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* #ident "@(#)run_tbl.c        3.1 95/08/30 Copyright (c) 1994 Gert Doering" */
2
 
 
3
 
/* run_tbl.c
4
 
 *
5
 
 * this file is part of the mgetty+sendfax distribution
6
 
 *
7
 
 * compute a set of arrays that will speed up finding the run length
8
 
 * of black or white bits in a byte enourmously
9
 
 * (I do not include the array as it is larger than the source and
10
 
 * computation is fast enough - 0.005 secs on my machine...)
11
 
 */
12
 
 
13
 
static unsigned char tab[9] = { 0x00,
14
 
                        0x01, 0x03, 0x07, 0x0f,
15
 
                        0x1f, 0x3f, 0x7f, 0xff };
16
 
 
17
 
char w_rtab[8][256];
18
 
char b_rtab[8][256];
19
 
 
20
 
void make_run_tables ( void )
21
 
{
22
 
int i, j, k, m;         /* byte = kkkjjjmm, "j" starts at bit "i" */
23
 
int mask;               /* black mask (all ones), start bit i, j bits wide */
24
 
 
25
 
    for ( i=0; i<8; i++ )               /* for (all starting bits) */
26
 
    {
27
 
        for ( j=i+1; j>=0; j-- )        /* for (all possible run lengths) */
28
 
        {
29
 
            mask = tab[j] << ((i-j)+1);
30
 
 
31
 
            if ( i == 7 )               /* no fill bits to the left */
32
 
            {
33
 
                if ( j == i+1 )         /* no fill bits to the right */
34
 
                {
35
 
                    w_rtab[i][0   ] = j;
36
 
                    b_rtab[i][mask] = j;
37
 
                }
38
 
                else                    /* fill bits to the right */
39
 
                for ( m = ( 1 << (i-j) ) -1 ; m >= 0; m-- )
40
 
                {
41
 
                    w_rtab[i][0   + (1<<(i-j)) + m ] = j;
42
 
                    b_rtab[i][mask+ 0          + m ] = j;
43
 
                }
44
 
            }
45
 
            else                        /* i != 7 -> fill higher bits */
46
 
            for ( k = (0x80>>i) -1; k>= 0; k-- )
47
 
            {
48
 
                if ( j == i+1 )         /* no noise to the right */
49
 
                {
50
 
                    w_rtab[i][ (k << (i+1)) + 0    ] = j;
51
 
                    b_rtab[i][ (k << (i+1)) + mask ] = j;
52
 
                }
53
 
                else                    /* fill bits to left + right */
54
 
                for ( m = ( 1 << (i-j) ) -1; m >= 0; m-- )
55
 
                {
56
 
                    w_rtab[i][ (k << (i+1)) + 0    + (1<<(i-j)) + m ] = j;
57
 
                    b_rtab[i][ (k << (i+1)) + mask +     0      + m ] = j;
58
 
                }
59
 
            }           /* end for (k) [noise left of top bit] */
60
 
        }               /* end for (j) [span] */
61
 
    }                   /* end for (i) [top bit] */
62
 
}