X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Ftiffenc.c;h=3b2b82991b945b2bbd8443350832b7c4addb2c19;hb=3ab770001817e0f52114a9876819f07fcd8ed93a;hp=a141a475b7924bef416c375e00ea14ca8aa04bce;hpb=ec6402b7c595c3ceed6d1b8c1b75c6aa8336e052;p=ffmpeg diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c index a141a475b79..3b2b82991b9 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; @@ -217,6 +221,7 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf, uint8_t *yuv_line = NULL; int shift_h, shift_v; + s->avctx = avctx; s->buf_start = buf; s->buf = &ptr; s->buf_size = buf_size; @@ -226,7 +231,11 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf, p->key_frame = 1; avctx->coded_frame= &s->picture; - s->compr = TIFF_PACKBITS; +#if FF_API_TIFFENC_COMPLEVEL + if (avctx->compression_level != FF_COMPRESSION_DEFAULT) + av_log(avctx, AV_LOG_WARNING, "Using compression_level to set compression " + "algorithm is deprecated. Please use the compression_algo private " + "option instead.\n"); if (avctx->compression_level == 0) { s->compr = TIFF_RAW; } else if(avctx->compression_level == 2) { @@ -236,6 +245,7 @@ static int encode_frame(AVCodecContext * avctx, unsigned char *buf, s->compr = TIFF_DEFLATE; #endif } +#endif s->width = avctx->width; s->height = avctx->height; @@ -443,6 +453,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, @@ -457,4 +487,5 @@ AVCodec ff_tiff_encoder = { PIX_FMT_YUV411P, PIX_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("TIFF image"), + .priv_class = &tiffenc_class, };