changeset 5804:af7e6436d8bd libavcodec

Allow to override zlib compression level in PNG encoder via avctx->compression_level
author reimar
date Tue, 09 Oct 2007 15:33:19 +0000
parents f896159a1a9e
children 12b1717f80a3
files pngenc.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;