[FFmpeg-cvslog] r10699 - trunk/libavcodec/pngenc.c

reimar subversion
Tue Oct 9 17:33:19 CEST 2007


Author: reimar
Date: Tue Oct  9 17:33:19 2007
New Revision: 10699

Log:
Allow to override zlib compression level in PNG encoder via avctx->compression_level


Modified:
   trunk/libavcodec/pngenc.c

Modified: trunk/libavcodec/pngenc.c
==============================================================================
--- trunk/libavcodec/pngenc.c	(original)
+++ trunk/libavcodec/pngenc.c	Tue Oct  9 17:33:19 2007
@@ -144,6 +144,7 @@ static int encode_frame(AVCodecContext *
     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 *
     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;




More information about the ffmpeg-cvslog mailing list