Annotation of 43BSDReno/contrib/isode-beta/others/quipu/photo/code_word.c, revision 1.1

1.1     ! root        1: /* code_word.c - define code words for one dimensional encoding */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/others/quipu/photo/RCS/code_word.c,v 7.0 89/11/23 22:01:34 mrose Rel $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/others/quipu/photo/RCS/code_word.c,v 7.0 89/11/23 22:01:34 mrose Rel $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       code_word.c,v $
        !            12:  * Revision 7.0  89/11/23  22:01:34  mrose
        !            13:  * Release 6.0
        !            14:  * 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  *                               NOTICE
        !            19:  *
        !            20:  *    Acquisition, use, and distribution of this module and related
        !            21:  *    materials are subject to the restrictions of a license agreement.
        !            22:  *    Consult the Preface in the User's Manual for the full terms of
        !            23:  *    this agreement.
        !            24:  *
        !            25:  */
        !            26: 
        !            27: 
        !            28: 
        !            29: #include <stdio.h>
        !            30: #include "quipu/photo.h"
        !            31: 
        !            32: extern int PIC_LINESIZE;
        !            33: 
        !            34: /* The following are declarations of the code words that are used with one
        !            35: /* dimensional encoding.   The first number in each pair give the length
        !            36: /* of the string, the second gives the string in hex, starting at the 13th bit
        !            37: /* position.
        !            38: /* The declarations are made this way so that the arays are made at compile
        !            39: /* time as opposed to run time.
        !            40: */
        !            41: 
        !            42: 
        !            43: /* White terminal run lengths */
        !            44: 
        !            45: static code_word wt_term [] = {
        !            46:                { 8 , 0x6a0  },         /* 0 : 00110101      */
        !            47:                { 6 , 0x380  },         /* 1 : 000111        */
        !            48:                { 4 , 0xe00  },         /* 2 : 0111          */
        !            49:                { 4 , 0x1000 },         /* 3 : 1000          */
        !            50:                { 4 , 0x1600 },         /* 4 : 1011          */
        !            51:                { 4 , 0x1800 },         /* 5 : 1100          */
        !            52:                { 4 , 0x1c00 },         /* 6 : 1110          */
        !            53:                { 4 , 0x1e00 },         /* 7 : 1111          */
        !            54:                { 5 , 0x1300 },         /* 8 : 10011         */
        !            55:                { 5 , 0x1400 },         /* 9 : 10100         */
        !            56:                { 5 , 0x700  },         /* 10: 00111         */
        !            57:                { 5 , 0x800  },         /* 11: 01000         */
        !            58:                { 6 , 0x400  },         /* 12: 001000        */
        !            59:                { 6 , 0x180  },         /* 13: 000011        */
        !            60:                { 6 , 0x1a00 },         /* 14: 110100        */
        !            61:                { 6 , 0x1a80 },         /* 15: 110101        */
        !            62:                { 6 , 0x1500 },         /* 16: 101010        */
        !            63:                { 6 , 0x1580 },         /* 17: 101011        */
        !            64:                { 7 , 0x9c0  },         /* 18: 0100111       */
        !            65:                { 7 , 0x300  },         /* 19: 0001100       */
        !            66:                { 7 , 0x200  },         /* 20: 0001000       */
        !            67:                { 7 , 0x5c0  },         /* 21: 0010111       */
        !            68:                { 7 , 0xc0   },         /* 22: 0000011       */
        !            69:                { 7 , 0x100  },         /* 23: 0000100       */
        !            70:                { 7 , 0xa00  },         /* 24: 0101000       */
        !            71:                { 7 , 0xac0  },         /* 25: 0101011       */
        !            72:                { 7 , 0x4c0  },         /* 26: 0010011       */
        !            73:                { 7 , 0x900  },         /* 27: 0100100       */
        !            74:                { 7 , 0x600  },         /* 28: 0011000       */
        !            75:                { 8 , 0x40   },         /* 29: 00000010      */
        !            76:                { 8 , 0x60   },         /* 30: 00000011      */
        !            77:                { 8 , 0x340  },         /* 31: 00011010      */
        !            78:                { 8 , 0x360  },         /* 32: 00011011      */
        !            79:                { 8 , 0x240  },         /* 33: 00010010      */
        !            80:                { 8 , 0x260  },         /* 34: 00010011      */
        !            81:                { 8 , 0x280  },         /* 35: 00010100      */
        !            82:                { 8 , 0x2a0  },         /* 36: 00010101      */
        !            83:                { 8 , 0x2c0  },         /* 37: 00010110      */
        !            84:                { 8 , 0x2e0  },         /* 38: 00010111      */
        !            85:                { 8 , 0x500  },         /* 39: 00101000      */
        !            86:                { 8 , 0x520  },         /* 40: 00101001      */
        !            87:                { 8 , 0x540  },         /* 41: 00101010      */
        !            88:                { 8 , 0x560  },         /* 42: 00101011      */
        !            89:                { 8 , 0x580  },         /* 43: 00101100      */
        !            90:                { 8 , 0x5a0  },         /* 44: 00101101      */
        !            91:                { 8 , 0x80   },         /* 45: 00000100      */
        !            92:                { 8 , 0xa0   },         /* 46: 00000101      */
        !            93:                { 8 , 0x140  },         /* 47: 00001010      */
        !            94:                { 8 , 0x160  },         /* 48: 00001011      */
        !            95:                { 8 , 0xa40  },         /* 49: 01010010      */
        !            96:                { 8 , 0xa60  },         /* 50: 01010011      */
        !            97:                { 8 , 0xa80  },         /* 51: 01010100      */
        !            98:                { 8 , 0xaa0  },         /* 52: 01010101      */
        !            99:                { 8 , 0x480  },         /* 53: 00100100      */
        !           100:                { 8 , 0x4a0  },         /* 54: 00100101      */
        !           101:                { 8 , 0xb00  },         /* 55: 01011000      */
        !           102:                { 8 , 0xb20  },         /* 56: 01011001      */
        !           103:                { 8 , 0xb40  },         /* 57: 01011010      */
        !           104:                { 8 , 0xb60  },         /* 58: 01011011      */
        !           105:                { 8 , 0x940  },         /* 59: 01001010      */
        !           106:                { 8 , 0x960  },         /* 60: 01001011      */
        !           107:                { 8 , 0x640  },         /* 61: 00110010      */
        !           108:                { 8 , 0x660  },         /* 62: 00110011      */
        !           109:                { 8 , 0x680  },         /* 63: 00110100      */
        !           110:        };
        !           111: 
        !           112: /* Black terminal run lengths */
        !           113: 
        !           114: static code_word bl_term [] = {
        !           115:                { 10, 0x1b8  },         /* 0 : 0000110111    */
        !           116:                { 3 , 0x800  },         /* 1 : 010           */
        !           117:                { 2 , 0x1800 },         /* 2 : 11            */
        !           118:                { 2 , 0x1000 },         /* 3 : 10            */
        !           119:                { 3 , 0xc00  },         /* 4 : 011           */
        !           120:                { 4 , 0x600  },         /* 5 : 0011          */
        !           121:                { 4 , 0x400  },         /* 6 : 0010          */
        !           122:                { 5 , 0x300  },         /* 7 : 00011         */
        !           123:                { 6 , 0x280  },         /* 8 : 000101        */
        !           124:                { 6 , 0x200  },         /* 9 : 000100        */
        !           125:                { 7 , 0x100  },         /* 10: 0000100       */
        !           126:                { 7 , 0x140  },         /* 11: 0000101       */
        !           127:                { 7 , 0x1c0  },         /* 12: 0000111       */
        !           128:                { 8 , 0x80   },         /* 13: 00000100      */
        !           129:                { 8 , 0xe0   },         /* 14: 00000111      */
        !           130:                { 9 , 0x180  },         /* 15: 000011000     */
        !           131:                { 10, 0xb8   },         /* 16: 0000010111    */
        !           132:                { 10, 0xc0   },         /* 17: 0000011000    */
        !           133:                { 10, 0x40   },         /* 18: 0000001000    */
        !           134:                { 11, 0x19c  },         /* 19: 00001100111   */
        !           135:                { 11, 0x1a0  },         /* 20: 00001101000   */
        !           136:                { 11, 0x1b0  },         /* 21: 00001101100   */
        !           137:                { 11, 0xdc   },         /* 22: 00000110111   */
        !           138:                { 11, 0xa0   },         /* 23: 00000101000   */
        !           139:                { 11, 0x5c   },         /* 24: 00000010111   */
        !           140:                { 11, 0x60   },         /* 25: 00000011000   */
        !           141:                { 12, 0x194  },         /* 26: 000011001010  */
        !           142:                { 12, 0x196  },         /* 27: 000011001011  */
        !           143:                { 12, 0x198  },         /* 28: 000011001100  */
        !           144:                { 12, 0x19a  },         /* 29: 000011001101  */
        !           145:                { 12, 0xd0   },         /* 30: 000001101000  */
        !           146:                { 12, 0xd2   },         /* 31: 000001101001  */
        !           147:                { 12, 0xd4   },         /* 32: 000001101010  */
        !           148:                { 12, 0xd6   },         /* 33: 000001101011  */
        !           149:                { 12, 0x1a4  },         /* 34: 000011010010  */
        !           150:                { 12, 0x1a6  },         /* 35: 000011010011  */
        !           151:                { 12, 0x1a8  },         /* 36: 000011010100  */
        !           152:                { 12, 0x1aa  },         /* 37: 000011010101  */
        !           153:                { 12, 0x1ac  },         /* 38: 000011010110  */
        !           154:                { 12, 0x1ae  },         /* 39: 000011010111  */
        !           155:                { 12, 0xd8   },         /* 40: 000001101100  */
        !           156:                { 12, 0xda   },         /* 41: 000001101101  */
        !           157:                { 12, 0x1b4  },         /* 42: 000011011010  */
        !           158:                { 12, 0x1b6  },         /* 43: 000011011011  */
        !           159:                { 12, 0xa8   },         /* 44: 000001010100  */
        !           160:                { 12, 0xaa   },         /* 45: 000001010101  */
        !           161:                { 12, 0xac   },         /* 46: 000001010110  */
        !           162:                { 12, 0xae   },         /* 47: 000001010111  */
        !           163:                { 12, 0xc8   },         /* 48: 000001100100  */
        !           164:                { 12, 0xca   },         /* 49: 000001100101  */
        !           165:                { 12, 0xa4   },         /* 50: 000001010010  */
        !           166:                { 12, 0xa6   },         /* 51: 000001010011  */
        !           167:                { 12, 0x48   },         /* 52: 000000100100  */
        !           168:                { 12, 0x6e   },         /* 53: 000000110111  */
        !           169:                { 12, 0x70   },         /* 54: 000000111000  */
        !           170:                { 12, 0x4e   },         /* 55: 000000100111  */
        !           171:                { 12, 0x50   },         /* 56: 000000101000  */
        !           172:                { 12, 0xb0   },         /* 57: 000001011000  */
        !           173:                { 12, 0xb2   },         /* 58: 000001011001  */
        !           174:                { 12, 0x56   },         /* 59: 000000101011  */
        !           175:                { 12, 0x58   },         /* 60: 000000101100  */
        !           176:                { 12, 0xb4   },         /* 61: 000001011010  */
        !           177:                { 12, 0xcc   },         /* 62: 000001100110  */
        !           178:                { 12, 0xce   },         /* 63: 000001100111  */
        !           179:        };
        !           180: 
        !           181: /* White make up codes */
        !           182: 
        !           183: static code_word wt_make [] = {
        !           184:                { 5 , 0x1b00 },         /* 64  : 11011         */
        !           185:                { 5 , 0x1200 },         /* 128 : 10010         */
        !           186:                { 6 , 0xb80  },         /* 192 : 010111        */
        !           187:                { 7 , 0xdc0  },         /* 256 : 0110111       */
        !           188:                { 8 , 0x6c0  },         /* 320 : 00110110      */
        !           189:                { 8 , 0x6e0  },         /* 384 : 00110111      */
        !           190:                { 8 , 0xc80  },         /* 448 : 01100100      */
        !           191:                { 8 , 0xca0  },         /* 512 : 01100101      */
        !           192:                { 8 , 0xd00  },         /* 576 : 01101000      */
        !           193:                { 8 , 0xce0  },         /* 640 : 01100111      */
        !           194:                { 9 , 0xcc0  },         /* 704 : 011001100     */
        !           195:                { 9 , 0xcd0  },         /* 768 : 011001101     */
        !           196:                { 9 , 0xd20  },         /* 832 : 011010010     */
        !           197:                { 9 , 0xd30  },         /* 896 : 011010011     */
        !           198:                { 9 , 0xd40  },         /* 960 : 011010100     */
        !           199:                { 9 , 0xd50  },         /* 1024: 011010101     */
        !           200:                { 9 , 0xd60  },         /* 1088: 011010110     */
        !           201:                { 9 , 0xd70  },         /* 1152: 011010111     */
        !           202:                { 9 , 0xd80  },         /* 1216: 011011000     */
        !           203:                { 9 , 0xd90  },         /* 1280: 011011001     */
        !           204:                { 9 , 0xda0  },         /* 1344: 011011010     */
        !           205:                { 9 , 0xdb0  },         /* 1408: 011011011     */
        !           206:                { 9 , 0x980  },         /* 1472: 010011000     */
        !           207:                { 9 , 0x990  },         /* 1536: 010011001     */
        !           208:                { 9 , 0x9a0  },         /* 1600: 010011010     */
        !           209:                { 6 , 0xc00  },         /* 1664: 011000        */
        !           210:                { 9 , 0x9b0  },         /* 1728: 010011011     */
        !           211:                { 11, 0x20   },         /* 1792: 00000001000   */
        !           212:                { 11, 0x30   },         /* 1856: 00000001100   */
        !           213:                { 11, 0x34   },         /* 1920: 00000001101   */
        !           214:                { 12, 0x24   },         /* 1984: 000000010010  */
        !           215:                { 12, 0x26   },         /* 2048: 000000010011  */
        !           216:        };
        !           217: 
        !           218: /* Black make up codes */
        !           219: 
        !           220: static code_word bl_make [] = {
        !           221:                { 10, 0x78   },         /* 64  : 0000001111    */
        !           222:                { 12, 0x190  },         /* 128 : 000011001000  */
        !           223:                { 12, 0x192  },         /* 192 : 000011001001  */
        !           224:                { 12, 0xb6   },         /* 256 : 000001011011  */
        !           225:                { 12, 0x66   },         /* 320 : 000000110011  */
        !           226:                { 12, 0x68   },         /* 384 : 000000110100  */
        !           227:                { 12, 0x6a   },         /* 448 : 000000110101  */
        !           228:                { 13, 0x6c   },         /* 512 : 0000001101100 */
        !           229:                { 13, 0x6d   },         /* 576 : 0000001101101 */
        !           230:                { 13, 0x4a   },         /* 640 : 0000001001010 */
        !           231:                { 13, 0x4b   },         /* 704 : 0000001001011 */
        !           232:                { 13, 0x4c   },         /* 768 : 0000001001100 */
        !           233:                { 13, 0x4d   },         /* 832 : 0000001001101 */
        !           234:                { 13, 0x72   },         /* 896 : 0000001110010 */
        !           235:                { 13, 0x73   },         /* 960 : 0000001110011 */
        !           236:                { 13, 0x74   },         /* 1024: 0000001110100 */
        !           237:                { 13, 0x75   },         /* 1088: 0000001110101 */
        !           238:                { 13, 0x76   },         /* 1152: 0000001110110 */
        !           239:                { 13, 0x77   },         /* 1216: 0000001110111 */
        !           240:                { 13, 0x52   },         /* 1280: 0000001010010 */
        !           241:                { 13, 0x53   },         /* 1344: 0000001010011 */
        !           242:                { 13, 0x54   },         /* 1408: 0000001010100 */
        !           243:                { 13, 0x55   },         /* 1472: 0000001010101 */
        !           244:                { 13, 0x5a   },         /* 1536: 0000001011010 */
        !           245:                { 13, 0x5b   },         /* 1600: 0000001011011 */
        !           246:                { 13, 0x64   },         /* 1664: 0000001100100 */
        !           247:                { 13, 0x65   },         /* 1728: 0000001100101 */
        !           248:                { 11, 0x20   },         /* 1792: 00000001000   */
        !           249:                { 11, 0x30   },         /* 1856: 00000001100   */
        !           250:                { 11, 0x34   },         /* 1920: 00000001101   */
        !           251:                { 12, 0x24   },         /* 1984: 000000010010  */
        !           252:                { 12, 0x26   },         /* 2048: 000000010011  */
        !           253:        };
        !           254: 
        !           255: 
        !           256: 
        !           257: 
        !           258: /* ROUTINE:     Get_code ()                                             */
        !           259: /*                                                                      */
        !           260: /* SYNOPSIS:    Gets a code word from an array given the run_length     */
        !           261: /*              and the colour (0 = white, 1 = black)                   */
        !           262: 
        !           263: full_code
        !           264: get_code (run, colour)
        !           265: 
        !           266: char    colour;
        !           267: int     run;
        !           268: {
        !           269: 
        !           270: full_code result;
        !           271:    result.make.length = 0;
        !           272:    if (run > PIC_LINESIZE)
        !           273:        (void) fprintf (stderr,"Run too long\n");
        !           274: 
        !           275:    if (colour  ==  WHITE) {
        !           276:       if  (run > 63)
        !           277:         result.make = wt_make [(run/64)-1];
        !           278:       result.term = wt_term [run%64];
        !           279: 
        !           280:    } else {
        !           281:       if  (run > 63)
        !           282:         result.make = bl_make [(run/64)-1];
        !           283:       result.term = bl_term [run%64];
        !           284:    }
        !           285: 
        !           286:    return (result);
        !           287: 
        !           288: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.