X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Ftiffenc.c;h=85976f41c02048cd012fc701eb0aaf6dbb211d9f;hb=e37f161e66e042d6c2c7470c4d9881df9427fc4a;hp=b9a1e20fa5ef4a9b4bea40edc2b676e8862887da;hpb=c1c836d9eb4f790146eb2aca24260982587f00ed;p=ffmpeg diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index b9a1e20fa5e..85976f41c02 100644 --- a/libavcodec/tiffenc.c +++ b/libavcodec/tiffenc.c @@ -25,6 +25,9 @@ * @author Bartlomiej Wolowiec */ +#include "libavutil/log.h" +#include "libavutil/opt.h" + #include "avcodec.h" #if CONFIG_ZLIB #include @@ -44,7 +47,7 @@ static const uint8_t type_sizes2[6] = { }; typedef struct TiffEncoderContext { - AVClass *avclass; + AVClass *class; ///< for private options AVCodecContext *avctx; AVFrame picture; @@ -230,23 +233,20 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf, p->key_frame = 1; avctx->coded_frame= &s->picture; - s->compr = TIFF_PACKBITS; - if (avctx->compression_level == 0) { - s->compr = TIFF_RAW; - } else if(avctx->compression_level == 2) { - s->compr = TIFF_LZW; -#if CONFIG_ZLIB - } else if ((avctx->compression_level >= 3)) { - s->compr = TIFF_DEFLATE; -#endif - } - s->width = avctx->width; s->height = avctx->height; s->subsampling[0] = 1; s->subsampling[1] = 1; switch (avctx->pix_fmt) { + case PIX_FMT_RGBA64LE: + s->bpp = 64; + s->photometric_interpretation = 2; + bpp_tab[0] = 16; + bpp_tab[1] = 16; + bpp_tab[2] = 16; + bpp_tab[3] = 16; + break; case PIX_FMT_RGB48LE: s->bpp = 48; s->photometric_interpretation = 2; @@ -255,6 +255,10 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf, bpp_tab[2] = 16; bpp_tab[3] = 16; break; + case PIX_FMT_RGBA: + s->bpp = 32; + s->photometric_interpretation = 2; + break; case PIX_FMT_RGB24: s->bpp = 24; s->photometric_interpretation = 2; @@ -453,11 +457,26 @@ fail: return ret; } -static const AVOption options[]={ -{"dpi", "set the image resolution (in dpi)", offsetof(TiffEncoderContext, dpi), AV_OPT_TYPE_INT, {.dbl = 72}, 1, 0x10000, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_ENCODING_PARAM}, -{NULL} +#define OFFSET(x) offsetof(TiffEncoderContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + {"dpi", "set the image resolution (in dpi)", OFFSET(dpi), AV_OPT_TYPE_INT, {.dbl = 72}, 1, 0x10000, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_ENCODING_PARAM}, + { "compression_algo", NULL, OFFSET(compr), AV_OPT_TYPE_INT, {TIFF_PACKBITS}, TIFF_RAW, TIFF_DEFLATE, VE, "compression_algo" }, + { "packbits", NULL, 0, AV_OPT_TYPE_CONST, {TIFF_PACKBITS}, 0, 0, VE, "compression_algo" }, + { "raw", NULL, 0, AV_OPT_TYPE_CONST, {TIFF_RAW}, 0, 0, VE, "compression_algo" }, + { "lzw", NULL, 0, AV_OPT_TYPE_CONST, {TIFF_LZW}, 0, 0, VE, "compression_algo" }, +#if CONFIG_ZLIB + { "deflate", NULL, 0, AV_OPT_TYPE_CONST, {TIFF_DEFLATE}, 0, 0, VE, "compression_algo" }, +#endif + { NULL }, +}; + +static const AVClass tiffenc_class = { + .class_name = "TIFF encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, }; -static const AVClass class = { "tiff", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; AVCodec ff_tiff_encoder = { .name = "tiff", @@ -471,7 +490,7 @@ AVCodec ff_tiff_encoder = { PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P, PIX_FMT_YUV410P, PIX_FMT_YUV411P, PIX_FMT_RGB48LE, - PIX_FMT_NONE}, + PIX_FMT_RGBA, PIX_FMT_RGBA64LE, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("TIFF image"), - .priv_class= &class, + .priv_class = &tiffenc_class, };