diff options
author | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2012-08-31 11:15:07 +0200 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2012-08-31 11:15:07 +0200 |
commit | f3683349aecf3be4c9c875186a812c0cde8ecf41 (patch) | |
tree | 0220db5840f880401a6863c18e8ee3cb0ada66ed /libavcodec/tiffenc.c | |
parent | 5eb532a9303079fb9a88f25708ea2ebda2ee9446 (diff) | |
download | ffmpeg-f3683349aecf3be4c9c875186a812c0cde8ecf41.tar.gz |
Write TIFF Tag ExtraSamples when encoding pix_fmts that contain transparency information.
Diffstat (limited to 'libavcodec/tiffenc.c')
-rw-r--r-- | libavcodec/tiffenc.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index c3d0980595..4f6e734668 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; @@ -264,6 +264,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, switch (avctx->pix_fmt) { case PIX_FMT_RGBA64LE: case PIX_FMT_RGBA: + alpha = 1; case PIX_FMT_RGB48LE: case PIX_FMT_RGB24: s->photometric_interpretation = 2; @@ -271,6 +272,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, 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: case PIX_FMT_MONOBLACK: s->photometric_interpretation = 1; @@ -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}; |