Check combined depth and number of components in TIFF decoder, thus eliminating

additional checks for each depth (like 48-bit gray vs. 48-bit RGB)

Originally committed as revision 19076 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Kostya Shishkov 2009-06-02 15:31:51 +00:00
parent 68e7f4828d
commit 9706d1c766

View File

@ -243,31 +243,28 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
s->bpp = -1; s->bpp = -1;
} }
} }
switch(s->bpp){ if(count > 4){
case 1: av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
return -1;
}
switch(s->bpp*10 + count){
case 11:
s->avctx->pix_fmt = PIX_FMT_MONOBLACK; s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
break; break;
case 8: case 81:
s->avctx->pix_fmt = PIX_FMT_PAL8; s->avctx->pix_fmt = PIX_FMT_PAL8;
break; break;
case 24: case 243:
s->avctx->pix_fmt = PIX_FMT_RGB24; s->avctx->pix_fmt = PIX_FMT_RGB24;
break; break;
case 16: case 161:
if(count == 1){ s->avctx->pix_fmt = PIX_FMT_GRAY16BE;
s->avctx->pix_fmt = PIX_FMT_GRAY16BE;
}else{
av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%i)\n", s->bpp);
return -1;
}
break; break;
case 32: case 324:
if(count == 4){ s->avctx->pix_fmt = PIX_FMT_RGBA;
s->avctx->pix_fmt = PIX_FMT_RGBA; break;
}else{ case 483:
av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count); s->avctx->pix_fmt = s->le ? PIX_FMT_RGB48LE : PIX_FMT_RGB48BE;
return -1;
}
break; break;
default: default:
av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count); av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);