[FFmpeg-devel] [PATCH]Write TIFFTAG_EXTRASAMPLES for pix_fmts containing transparency
Carl Eugen Hoyos
cehoyos at ag.or.at
Wed Aug 29 15:43:11 CEST 2012
Hi!
The tiff specification requires the TIFFTAG_EXTRASAMPLES tag to be written if
SamplesPerPixel is larger than what PhotometricInterpretation would indicate.
Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 883d6fb..dc4c704 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -248,7 +248,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
uint32_t res[2] = { s->dpi, 1 }; // image resolution (72/1)
uint16_t bpp_tab[4];
int ret = -1;
- int is_yuv = 0;
+ int is_yuv = 0, alpha = 0;
int shift_h, shift_v;
*p = *pict;
@@ -265,12 +265,14 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
case PIX_FMT_RGBA64LE:
case PIX_FMT_RGB48LE:
case PIX_FMT_RGBA:
+ alpha = 1;
case PIX_FMT_RGB24:
s->photometric_interpretation = 2;
break;
case PIX_FMT_GRAY8:
avctx->bits_per_coded_sample = 0x28;
case PIX_FMT_GRAY8A:
+ alpha = avctx->pix_fmt == PIX_FMT_GRAY8A;
case PIX_FMT_GRAY16LE:
s->photometric_interpretation = 1;
break;
@@ -451,6 +453,8 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
}
add_entry(s, TIFF_PAL, TIFF_SHORT, 256 * 3, pal);
}
+ if (alpha)
+ add_entry1(s,TIFF_EXTRASAMPLES, TIFF_SHORT, 2);
if (is_yuv){
/** according to CCIR Recommendation 601.1 */
uint32_t refbw[12] = {15, 1, 235, 1, 128, 1, 240, 1, 128, 1, 240, 1};
More information about the ffmpeg-devel
mailing list