# HG changeset patch # User kostya # Date 1163417686 0 # Node ID 405f8395eedc0624584f6fc28a9e6379f39a8413 # Parent 3c98b0938897661dc447e407f95e18e8354e1d6a Use table for determining type sizes diff -r 3c98b0938897 -r 405f8395eedc tiff.c --- a/tiff.c Mon Nov 13 11:30:26 2006 +0000 +++ b/tiff.c Mon Nov 13 11:34:46 2006 +0000 @@ -62,6 +62,11 @@ TIFF_LONGLONG }; +/** sizes of various TIFF field types */ +static const int type_sizes[6] = { + 0, 1, 100, 2, 4, 8 +}; + typedef struct TiffContext { AVCodecContext *avctx; AVFrame picture; @@ -208,6 +213,8 @@ value = -1; buf = start + off; } + }else if(type_sizes[type] * count <= 4){ + buf -= 4; }else{ buf = start + off; } @@ -397,11 +404,11 @@ return -1; } pal = s->picture.data[1]; - off = (type == TIFF_SHORT) ? 2 : 1; + off = type_sizes[type]; rp = buf; gp = buf + count / 3 * off; bp = buf + count / 3 * off * 2; - off = (type == TIFF_SHORT) ? 8 : 0; + off = (type_sizes[type] - 1) << 3; for(i = 0; i < count / 3; i++){ j = (tget(&rp, type, s->le) >> off) << 16; j |= (tget(&gp, type, s->le) >> off) << 8;