diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index d486b3fd4b..7b71481a74 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 @@ -43,6 +46,7 @@ static const uint8_t type_sizes2[6] = { }; typedef struct TiffEncoderContext { + AVClass *class; ///< for private options AVCodecContext *avctx; AVFrame picture; @@ -227,7 +231,6 @@ 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) { @@ -444,6 +447,26 @@ fail: return ret; } +#define OFFSET(x) offsetof(TiffEncoderContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "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, +}; + AVCodec ff_tiff_encoder = { .name = "tiff", .type = AVMEDIA_TYPE_VIDEO, @@ -458,4 +481,5 @@ AVCodec ff_tiff_encoder = { PIX_FMT_YUV411P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("TIFF image"), + .priv_class = &tiffenc_class, };