# HG changeset patch # User lorenm # Date 1180028402 0 # Node ID 1aec7fab94c47cbae36ea63aa6a15cfa35664bc0 # Parent 0d503c12092bcd25a65c051b52f7844a1c037816 use sparse huffman tables. 1.5% faster huffyuv decoding. diff -r 0d503c12092b -r 1aec7fab94c4 huffyuv.c --- a/huffyuv.c Thu May 24 17:38:56 2007 +0000 +++ b/huffyuv.c Thu May 24 17:40:02 2007 +0000 @@ -71,7 +71,6 @@ uint8_t len[3][256]; uint32_t bits[3][256]; VLC vlc[6]; //Y,U,V,YY,YU,YV - uint16_t pix2_map[3][1<bitstream_bpp < 24){ + uint16_t symbols[1<bits[0][y] << len1) + s->bits[p][u]; - s->pix2_map[p][i] = (y<<8) + u; - i++; + symbols[i] = (y<<8) + u; + if(symbols[i] != 0xffff) // reserved to mean "invalid" + i++; } } } } free_vlc(&s->vlc[3+p]); - init_vlc(&s->vlc[3+p], VLC_BITS, i, len, 1, 1, bits, 2, 2, 0); + init_vlc_sparse(&s->vlc[3+p], VLC_BITS, i, len, 1, 1, bits, 2, 2, symbols, 2, 2, 0); } } } @@ -690,11 +690,10 @@ /* TODO instead of restarting the read when the code isn't in the first level * of the joint table, jump into the 2nd level of the individual table. */ #define READ_2PIX(dst0, dst1, plane1){\ - int code = get_vlc2(&s->gb, s->vlc[3+plane1].table, VLC_BITS, 1);\ - if(code >= 0){\ - int x = s->pix2_map[plane1][code];\ - dst0 = x>>8;\ - dst1 = x;\ + uint16_t code = get_vlc2(&s->gb, s->vlc[3+plane1].table, VLC_BITS, 1);\ + if(code != 0xffff){\ + dst0 = code>>8;\ + dst1 = code;\ }else{\ dst0 = get_vlc2(&s->gb, s->vlc[0].table, VLC_BITS, 3);\ dst1 = get_vlc2(&s->gb, s->vlc[plane1].table, VLC_BITS, 3);\