# HG changeset patch # User reimar # Date 1191943999 0 # Node ID af7e6436d8bd3b7af99d12833d54a17391ae982e # Parent f896159a1a9e82521650c540111db05a062534c4 Allow to override zlib compression level in PNG encoder via avctx->compression_level diff -r f896159a1a9e -r af7e6436d8bd pngenc.c --- a/pngenc.c Tue Oct 09 15:09:51 2007 +0000 +++ b/pngenc.c Tue Oct 09 15:33:19 2007 +0000 @@ -144,6 +144,7 @@ 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 @@ 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;