PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs323] get/put less than 8 bits?
Date: Wednesday, 11 Nov 2020, 07:03:03


    > Message Posted By: Unknown
    >
    > I am trying to follow Richard's suggestion of writing 5 bits for MAXBITS
    > and 1 bit for PRUNING, but I am getting the following output when trying
    > to get the 6 bits that I put:
    >
    > encode:
    > putBits(5, 12);
    > putBits(1, 0);
    >
    > decode:
    > long maxbits = getBits(5);
    > long pruning = getBits(1);
    > printf("%ld %ld\n", maxbits, pruning);
    >
    > % ./encode > out.txt
    > % ./decode < out.txt
    > -1 -1
    >
    > Is there a fix for this?

Possible fixes:

1. Write 8 bits for each (the wasted 10 bits of padding
   will not make any difference).

2. Assuming that you are running at Stage 3, have encode
   call flushBits() before exiting.  (If not, I will have
   to see the rest of your code to diagnose the problem.)

--Stan-
PREV INDEX NEXT