[Libav-user] Using libav LZW compression methods.

Luka Petrinsak lukapetrinsakx at gmail.com
Mon Apr 4 12:16:40 CEST 2016


Why does output buffer needs to be bigger than input buffer, wouldn't that
result in bigger buffer after compression has been done?

(ff_lzw_encode)

if(insize * 3 > (s->bufsize - s->output_bytes) * 2){

        return -1;

    }



Why are first 256 indexes in hash table filled with LZW_PREFIX_EMPTY
hash_prefix value and others are filled with LZW_PREFIX_FREE (which marks
the tables as free/clear)?

(clearTable)

for (i = 0; i < 256; i++) {

        h = hash(0, i);

        s->tab[h].code = i;

        s->tab[h].suffix = i;

        s->tab[h].hash_prefix = LZW_PREFIX_EMPTY;

    }



What is writeCode actually doing? Since i can't figure out what is put_bits
function used for. Also, im guessing av_assert2 macro is used for error
reporting depending on the condition passed through it.

static inline void writeCode(LZWEncodeState * s, int c)

{

    av_assert2(0 <= c && c < 1 << s->bits);

    s->put_bits(&s->pb, s->bits, c);

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160404/fa7f26de/attachment.html>


More information about the Libav-user mailing list