Ticket #190: tiff.diff

File tiff.diff, 1.9 KB (added by ami_stuff, 15 years ago)
  • libavcodec/tiff.c

    diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
    index f371dc6..c7aee32 100644
    a b static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin  
    173173        switch(s->compr){
    174174        case TIFF_RAW:
    175175            if (!s->fill_order) {
    176                 memcpy(dst, src, width);
     176                if (s->bpp == 2) {
     177                    int i;
     178                    for(i = 0; i < width; i++) {
     179                        dst[i*4+0] = src[i] >> 6;
     180                        dst[i*4+1] = src[i] >> 4 & 0x3;
     181                        dst[i*4+2] = src[i] >> 2 & 0x3;
     182                        dst[i*4+3] = src[i] & 0x3;
     183                    }
     184                } else if (s->bpp == 4) {
     185                    int i;
     186                    for(i = 0; i < width; i++) {
     187                        dst[i*2+0] = src[i] >> 4;
     188                        dst[i*2+1] = src[i] & 0xF;
     189                    }
     190                } else
     191                    memcpy(dst, src, width);
     192                }
    177193            } else {
    178194                int i;
    179195                for (i = 0; i < width; i++)
    static int init_image(TiffContext *s)  
    227243    case 11:
    228244        s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
    229245        break;
     246    case 21:
     247    case 41:
    230248    case 81:
    231249        s->avctx->pix_fmt = PIX_FMT_PAL8;
    232250        break;
    static int init_image(TiffContext *s)  
    248266               s->bpp, s->bppcount);
    249267        return AVERROR_INVALIDDATA;
    250268    }
     269    if (s->bpp == 2 && s->compr != TIFF_RAW || s->bpp == 4 && s->compr != TIFF_RAW) {
     270        av_log(s->avctx, AV_LOG_ERROR, "2/4bpp with compression is not supported\n");
     271        return AVERROR_INVALIDDATA;
     272    }
    251273    if (s->width != s->avctx->width || s->height != s->avctx->height) {
    252274        if ((ret = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0)
    253275            return ret;