Commit 3779973a authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'f86f39cb'

* commit 'f86f39cb':
  tiff: support decoding GBRP and GBRAP formats

Conflicts:
	libavcodec/tiff.c

See: 379ad978Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 27513846 f86f39cb
...@@ -1257,77 +1257,77 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -1257,77 +1257,77 @@ static int decode_frame(AVCodecContext *avctx,
planes = s->planar ? s->bppcount : 1; planes = s->planar ? s->bppcount : 1;
for (plane = 0; plane < planes; plane++) { for (plane = 0; plane < planes; plane++) {
stride = p->linesize[plane]; stride = p->linesize[plane];
dst = p->data[plane]; dst = p->data[plane];
for (i = 0; i < s->height; i += s->rps) { for (i = 0; i < s->height; i += s->rps) {
if (s->stripsizesoff) if (s->stripsizesoff)
ssize = ff_tget(&stripsizes, s->sstype, le); ssize = ff_tget(&stripsizes, s->sstype, le);
else else
ssize = s->stripsize; ssize = s->stripsize;
if (s->strippos) if (s->strippos)
soff = ff_tget(&stripdata, s->sot, le); soff = ff_tget(&stripdata, s->sot, le);
else else
soff = s->stripoff; soff = s->stripoff;
if (soff > avpkt->size || ssize > avpkt->size - soff) { if (soff > avpkt->size || ssize > avpkt->size - soff) {
av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n"); av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if ((ret = tiff_unpack_strip(s, p, dst, stride, avpkt->data + soff, ssize, i, if ((ret = tiff_unpack_strip(s, p, dst, stride, avpkt->data + soff, ssize, i,
FFMIN(s->rps, s->height - i))) < 0) { FFMIN(s->rps, s->height - i))) < 0) {
if (avctx->err_recognition & AV_EF_EXPLODE) if (avctx->err_recognition & AV_EF_EXPLODE)
return ret; return ret;
break; break;
} }
dst += s->rps * stride; dst += s->rps * stride;
}
if (s->predictor == 2) {
if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
av_log(s->avctx, AV_LOG_ERROR, "predictor == 2 with YUV is unsupported");
return AVERROR_PATCHWELCOME;
} }
dst = p->data[plane]; if (s->predictor == 2) {
soff = s->bpp >> 3; if (s->photometric == TIFF_PHOTOMETRIC_YCBCR) {
if (s->planar) av_log(s->avctx, AV_LOG_ERROR, "predictor == 2 with YUV is unsupported");
soff = FFMAX(soff / s->bppcount, 1); return AVERROR_PATCHWELCOME;
ssize = s->width * soff;
if (s->avctx->pix_fmt == AV_PIX_FMT_RGB48LE ||
s->avctx->pix_fmt == AV_PIX_FMT_RGBA64LE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16LE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16LE) {
for (i = 0; i < s->height; i++) {
for (j = soff; j < ssize; j += 2)
AV_WL16(dst + j, AV_RL16(dst + j) + AV_RL16(dst + j - soff));
dst += stride;
} }
} else if (s->avctx->pix_fmt == AV_PIX_FMT_RGB48BE || dst = p->data[plane];
s->avctx->pix_fmt == AV_PIX_FMT_RGBA64BE || soff = s->bpp >> 3;
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16BE || if (s->planar)
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16BE) { soff = FFMAX(soff / s->bppcount, 1);
for (i = 0; i < s->height; i++) { ssize = s->width * soff;
for (j = soff; j < ssize; j += 2) if (s->avctx->pix_fmt == AV_PIX_FMT_RGB48LE ||
AV_WB16(dst + j, AV_RB16(dst + j) + AV_RB16(dst + j - soff)); s->avctx->pix_fmt == AV_PIX_FMT_RGBA64LE ||
dst += stride; s->avctx->pix_fmt == AV_PIX_FMT_GBRP16LE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16LE) {
for (i = 0; i < s->height; i++) {
for (j = soff; j < ssize; j += 2)
AV_WL16(dst + j, AV_RL16(dst + j) + AV_RL16(dst + j - soff));
dst += stride;
}
} else if (s->avctx->pix_fmt == AV_PIX_FMT_RGB48BE ||
s->avctx->pix_fmt == AV_PIX_FMT_RGBA64BE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRP16BE ||
s->avctx->pix_fmt == AV_PIX_FMT_GBRAP16BE) {
for (i = 0; i < s->height; i++) {
for (j = soff; j < ssize; j += 2)
AV_WB16(dst + j, AV_RB16(dst + j) + AV_RB16(dst + j - soff));
dst += stride;
}
} else {
for (i = 0; i < s->height; i++) {
for (j = soff; j < ssize; j++)
dst[j] += dst[j - soff];
dst += stride;
}
} }
} else { }
if (s->photometric == TIFF_PHOTOMETRIC_WHITE_IS_ZERO) {
dst = p->data[plane];
for (i = 0; i < s->height; i++) { for (i = 0; i < s->height; i++) {
for (j = soff; j < ssize; j++) for (j = 0; j < stride; j++)
dst[j] += dst[j - soff]; dst[j] = (s->avctx->pix_fmt == AV_PIX_FMT_PAL8 ? (1<<s->bpp) - 1 : 255) - dst[j];
dst += stride; dst += stride;
} }
} }
} }
if (s->photometric == TIFF_PHOTOMETRIC_WHITE_IS_ZERO) {
dst = p->data[plane];
for (i = 0; i < s->height; i++) {
for (j = 0; j < p->linesize[plane]; j++)
dst[j] = (s->avctx->pix_fmt == AV_PIX_FMT_PAL8 ? (1<<s->bpp) - 1 : 255) - dst[j];
dst += stride;
}
}
}
if (s->planar && s->bppcount > 2) { if (s->planar && s->bppcount > 2) {
FFSWAP(uint8_t*, p->data[0], p->data[2]); FFSWAP(uint8_t*, p->data[0], p->data[2]);
FFSWAP(int, p->linesize[0], p->linesize[2]); FFSWAP(int, p->linesize[0], p->linesize[2]);
......
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