aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2007-10-09 15:33:19 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2007-10-09 15:33:19 +0000
commit9ba718e4819da325c9d324c23a9a6210fde114c5 (patch)
treedbede3ec5cf483942cf0eb816bbbc25e25711dc6
parentf6e3c4603de9b62d38b6c8310e6c20766b7b6afb (diff)
downloadffmpeg-9ba718e4819da325c9d324c23a9a6210fde114c5.tar.gz
Allow to override zlib compression level in PNG encoder via avctx->compression_level
Originally committed as revision 10699 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/pngenc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 22365e9da3..0dd5d37a1a 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -144,6 +144,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
AVFrame * const p= (AVFrame*)&s->picture;
int bit_depth, color_type, y, len, row_size, ret, is_progressive;
int bits_per_pixel, pass_row_size;
+ int compression_level;
uint8_t *ptr;
uint8_t *crow_buf = NULL;
uint8_t *tmp_buf = NULL;
@@ -187,7 +188,10 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
s->zstream.zalloc = ff_png_zalloc;
s->zstream.zfree = ff_png_zfree;
s->zstream.opaque = NULL;
- ret = deflateInit2(&s->zstream, Z_DEFAULT_COMPRESSION,
+ compression_level = avctx->compression_level == FF_COMPRESSION_DEFAULT ?
+ Z_DEFAULT_COMPRESSION :
+ av_clip(avctx->compression_level, 0, 9);
+ ret = deflateInit2(&s->zstream, compression_level,
Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY);
if (ret != Z_OK)
return -1;