Commit 9ab3a116 authored by kostya's avatar kostya

Use table for determining type sizes

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@7009 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 29f5d037
...@@ -62,6 +62,11 @@ enum TiffTypes{ ...@@ -62,6 +62,11 @@ enum TiffTypes{
TIFF_LONGLONG TIFF_LONGLONG
}; };
/** sizes of various TIFF field types */
static const int type_sizes[6] = {
0, 1, 100, 2, 4, 8
};
typedef struct TiffContext { typedef struct TiffContext {
AVCodecContext *avctx; AVCodecContext *avctx;
AVFrame picture; AVFrame picture;
...@@ -208,6 +213,8 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t ...@@ -208,6 +213,8 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
value = -1; value = -1;
buf = start + off; buf = start + off;
} }
}else if(type_sizes[type] * count <= 4){
buf -= 4;
}else{ }else{
buf = start + off; buf = start + off;
} }
...@@ -397,11 +404,11 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t ...@@ -397,11 +404,11 @@ static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t
return -1; return -1;
} }
pal = s->picture.data[1]; pal = s->picture.data[1];
off = (type == TIFF_SHORT) ? 2 : 1; off = type_sizes[type];
rp = buf; rp = buf;
gp = buf + count / 3 * off; gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2; 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++){ for(i = 0; i < count / 3; i++){
j = (tget(&rp, type, s->le) >> off) << 16; j = (tget(&rp, type, s->le) >> off) << 16;
j |= (tget(&gp, type, s->le) >> off) << 8; j |= (tget(&gp, type, s->le) >> off) << 8;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment