summaryrefslogtreecommitdiff
path: root/libavcodec/tiff.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-01-15 06:00:25 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-01-15 06:11:32 +0100
commit3779973a9b8e473718cbd8490f277e589b27a9f6 (patch)
tree38ebef0b56b2d912da32e6f8f64f1828bdf31df5 /libavcodec/tiff.c
parent27513846f66bfaf4dd38b819b71c4786075ee5d1 (diff)
parentf86f39cb9b1fcd063d5e4812132a75c06cc7acd2 (diff)
Merge commit 'f86f39cb9b1fcd063d5e4812132a75c06cc7acd2'
* commit 'f86f39cb9b1fcd063d5e4812132a75c06cc7acd2': tiff: support decoding GBRP and GBRAP formats Conflicts: libavcodec/tiff.c See: 379ad9788b80e05c0379adc49b26704dfd27d564 Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tiff.c')
-rw-r--r--libavcodec/tiff.c124
1 files changed, 62 insertions, 62 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index ee16d7805d..8047f384ef 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1257,77 +1257,77 @@ static int decode_frame(AVCodecContext *avctx,
planes = s->planar ? s->bppcount : 1;
for (plane = 0; plane < planes; plane++) {
stride = p->linesize[plane];
- dst = p->data[plane];
- for (i = 0; i < s->height; i += s->rps) {
- if (s->stripsizesoff)
- ssize = ff_tget(&stripsizes, s->sstype, le);
- else
- ssize = s->stripsize;
-
- if (s->strippos)
- soff = ff_tget(&stripdata, s->sot, le);
- else
- soff = s->stripoff;
-
- if (soff > avpkt->size || ssize > avpkt->size - soff) {
- av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n");
- return AVERROR_INVALIDDATA;
- }
- if ((ret = tiff_unpack_strip(s, p, dst, stride, avpkt->data + soff, ssize, i,
- FFMIN(s->rps, s->height - i))) < 0) {
- if (avctx->err_recognition & AV_EF_EXPLODE)
- return ret;
- break;
- }
- 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];
+ for (i = 0; i < s->height; i += s->rps) {
+ if (s->stripsizesoff)
+ ssize = ff_tget(&stripsizes, s->sstype, le);
+ else
+ ssize = s->stripsize;
+
+ if (s->strippos)
+ soff = ff_tget(&stripdata, s->sot, le);
+ else
+ soff = s->stripoff;
+
+ if (soff > avpkt->size || ssize > avpkt->size - soff) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if ((ret = tiff_unpack_strip(s, p, dst, stride, avpkt->data + soff, ssize, i,
+ FFMIN(s->rps, s->height - i))) < 0) {
+ if (avctx->err_recognition & AV_EF_EXPLODE)
+ return ret;
+ break;
+ }
+ dst += s->rps * stride;
}
- dst = p->data[plane];
- soff = s->bpp >> 3;
- if (s->planar)
- soff = FFMAX(soff / s->bppcount, 1);
- 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;
+ 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;
}
- } 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;
+ dst = p->data[plane];
+ soff = s->bpp >> 3;
+ if (s->planar)
+ soff = FFMAX(soff / s->bppcount, 1);
+ 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 ||
+ 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 (j = soff; j < ssize; j++)
- dst[j] += dst[j - soff];
+ for (j = 0; j < stride; j++)
+ dst[j] = (s->avctx->pix_fmt == AV_PIX_FMT_PAL8 ? (1<<s->bpp) - 1 : 255) - dst[j];
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) {
FFSWAP(uint8_t*, p->data[0], p->data[2]);
FFSWAP(int, p->linesize[0], p->linesize[2]);