Mercurial > libavcodec.hg
changeset 9784:2142607ddc2e libavcodec
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)
author | kostya |
---|---|
date | Tue, 02 Jun 2009 15:31:51 +0000 |
parents | 21f3bbb20e42 |
children | 48572d70c95f |
files | tiff.c |
diffstat | 1 files changed, 15 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/tiff.c Sun May 31 19:51:21 2009 +0000 +++ b/tiff.c Tue Jun 02 15:31:51 2009 +0000 @@ -243,31 +243,28 @@ s->bpp = -1; } } - switch(s->bpp){ - case 1: + if(count > 4){ + 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; break; - case 8: + case 81: s->avctx->pix_fmt = PIX_FMT_PAL8; break; - case 24: + case 243: s->avctx->pix_fmt = PIX_FMT_RGB24; break; - case 16: - if(count == 1){ - 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; - } + case 161: + s->avctx->pix_fmt = PIX_FMT_GRAY16BE; break; - case 32: - if(count == 4){ - s->avctx->pix_fmt = PIX_FMT_RGBA; - }else{ - av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count); - return -1; - } + case 324: + s->avctx->pix_fmt = PIX_FMT_RGBA; + break; + case 483: + s->avctx->pix_fmt = s->le ? PIX_FMT_RGB48LE : PIX_FMT_RGB48BE; break; default: av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);