[FFmpeg-devel] [PATCH]Support cmyk in tiff
Carl Eugen Hoyos
cehoyos at ag.or.at
Sun May 4 22:00:24 CEST 2014
Hi!
Attached patch fixes ticket #3459 for me, based on a05635ee.
Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 1caad84..5371c9a 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -830,11 +830,11 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
case TIFF_PHOTOMETRIC_BLACK_IS_ZERO:
case TIFF_PHOTOMETRIC_RGB:
case TIFF_PHOTOMETRIC_PALETTE:
+ case TIFF_PHOTOMETRIC_SEPARATED:
case TIFF_PHOTOMETRIC_YCBCR:
s->photometric = value;
break;
case TIFF_PHOTOMETRIC_ALPHA_MASK:
- case TIFF_PHOTOMETRIC_SEPARATED:
case TIFF_PHOTOMETRIC_CIE_LAB:
case TIFF_PHOTOMETRIC_ICC_LAB:
case TIFF_PHOTOMETRIC_ITU_LAB:
@@ -1209,6 +1209,23 @@ static int decode_frame(AVCodecContext *avctx,
dst += stride;
}
}
+ if (s->photometric == TIFF_PHOTOMETRIC_SEPARATED &&
+ s->avctx->pix_fmt == AV_PIX_FMT_RGBA) {
+ dst = p->data[plane];
+ for (i = 0; i < s->height; i++) {
+ for (j = 0; j < s->width; j++) {
+ int k = 255 - dst[4 * j + 3];
+ int r = (255 - dst[4 * j ]) * k;
+ int g = (255 - dst[4 * j + 1]) * k;
+ int b = (255 - dst[4 * j + 2]) * k;
+ dst[4 * j ] = r * 257 >> 16;
+ dst[4 * j + 1] = g * 257 >> 16;
+ dst[4 * j + 2] = b * 257 >> 16;
+ dst[4 * j + 3] = 255;
+ }
+ dst += p->linesize[plane];
+ }
+ }
}
if (s->planar && s->bppcount > 2) {
More information about the ffmpeg-devel
mailing list