X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Ftiffenc.c;h=4f6e7346689abd88fd716eb3a66f0bcda385e2bb;hb=f3683349aecf3be4c9c875186a812c0cde8ecf41;hp=fa13c7273eb94f8462e5f9398148f0f6ee2c21dc;hpb=9c6e23f5d2f9fa58d54adf35b4cde4e351fb7d64;p=ffmpeg diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index fa13c7273eb..4f6e7346689 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -30,12 +30,12 @@ #include "libavutil/opt.h" #include "avcodec.h" -#include "internal.h" +#include "config.h" #if CONFIG_ZLIB #include #endif -#include "libavutil/opt.h" #include "bytestream.h" +#include "internal.h" #include "tiff.h" #include "rle.h" #include "lzw.h" @@ -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; @@ -263,23 +263,25 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt, switch (avctx->pix_fmt) { case PIX_FMT_RGBA64LE: - case PIX_FMT_RGB48LE: case PIX_FMT_RGBA: + alpha = 1; + case PIX_FMT_RGB48LE: 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: + case PIX_FMT_MONOBLACK: s->photometric_interpretation = 1; break; case PIX_FMT_PAL8: s->photometric_interpretation = 3; break; - case PIX_FMT_MONOBLACK: case PIX_FMT_MONOWHITE: - s->photometric_interpretation = avctx->pix_fmt == PIX_FMT_MONOBLACK; + s->photometric_interpretation = 0; break; case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: @@ -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}; @@ -510,7 +514,7 @@ static const AVClass tiffenc_class = { AVCodec ff_tiff_encoder = { .name = "tiff", .type = AVMEDIA_TYPE_VIDEO, - .id = CODEC_ID_TIFF, + .id = AV_CODEC_ID_TIFF, .priv_data_size = sizeof(TiffEncoderContext), .init = encode_init, .encode2 = encode_frame,