Пример #1
0
static int decode_one_bit(struct VARICODE_DEC *s, char *single_ascii, short varicode_in, int long_code)
{
    int            found=0, i;
    unsigned short byte1, byte2;

    //printf("decode_one_bit : state: %d varicode_in: %d packed: 0x%x n_zeros: %d\n",
    //       s->state, varicode_in, s->packed, s->n_zeros);

    if (s->state == 0) {
        if (!varicode_in)
            return 0;
        else
            s->state = 1;
    }

    if (s->state == 1) {
        if (varicode_in) {
            s->packed |= (0x8000 >> s->v_len);
            s->n_zeros = 0;
        }
        else {
            s->n_zeros++;
        }
        s->v_len++;
        found = 0;

        /* end of character code */

        if (s->n_zeros == 2) {
            if (s->v_len) {
                /* run thru table but note with bit errors we might not actually find a match */

                byte1 = s->packed >> 8;
                //printf("looking for byte1 : 0x%x ... ", byte1);
                byte2 = s->packed & 0xff;

                for(i=0; i<128; i++) {
                    if ((byte1 == varicode_table1[2*i]) && (byte2 == varicode_table1[2*i+1])) {
                        found = 1;
                        *single_ascii = i;
                    }
                }
            }
            varicode_decode_init(s, s->code_num);
        }
Пример #2
0
VariCodePipeDecoder::VariCodePipeDecoder(QObject *parent) : QIODevice(parent)
{
    varicode_decode_init(&varicode_dec_states,1);
    decodedbytes.reserve(1000);
    sbits.reserve(1000);
}