Mercurial > libavcodec.hg
comparison pngenc.c @ 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 | a8c48a070cff |
children | 2d7afa1bc573 |
comparison
equal
deleted
inserted
replaced
5803:f896159a1a9e | 5804:af7e6436d8bd |
---|---|
142 PNGEncContext *s = avctx->priv_data; | 142 PNGEncContext *s = avctx->priv_data; |
143 AVFrame *pict = data; | 143 AVFrame *pict = data; |
144 AVFrame * const p= (AVFrame*)&s->picture; | 144 AVFrame * const p= (AVFrame*)&s->picture; |
145 int bit_depth, color_type, y, len, row_size, ret, is_progressive; | 145 int bit_depth, color_type, y, len, row_size, ret, is_progressive; |
146 int bits_per_pixel, pass_row_size; | 146 int bits_per_pixel, pass_row_size; |
147 int compression_level; | |
147 uint8_t *ptr; | 148 uint8_t *ptr; |
148 uint8_t *crow_buf = NULL; | 149 uint8_t *crow_buf = NULL; |
149 uint8_t *tmp_buf = NULL; | 150 uint8_t *tmp_buf = NULL; |
150 | 151 |
151 *p = *pict; | 152 *p = *pict; |
185 row_size = (avctx->width * bits_per_pixel + 7) >> 3; | 186 row_size = (avctx->width * bits_per_pixel + 7) >> 3; |
186 | 187 |
187 s->zstream.zalloc = ff_png_zalloc; | 188 s->zstream.zalloc = ff_png_zalloc; |
188 s->zstream.zfree = ff_png_zfree; | 189 s->zstream.zfree = ff_png_zfree; |
189 s->zstream.opaque = NULL; | 190 s->zstream.opaque = NULL; |
190 ret = deflateInit2(&s->zstream, Z_DEFAULT_COMPRESSION, | 191 compression_level = avctx->compression_level == FF_COMPRESSION_DEFAULT ? |
192 Z_DEFAULT_COMPRESSION : | |
193 av_clip(avctx->compression_level, 0, 9); | |
194 ret = deflateInit2(&s->zstream, compression_level, | |
191 Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY); | 195 Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY); |
192 if (ret != Z_OK) | 196 if (ret != Z_OK) |
193 return -1; | 197 return -1; |
194 crow_buf = av_malloc(row_size + 1); | 198 crow_buf = av_malloc(row_size + 1); |
195 if (!crow_buf) | 199 if (!crow_buf) |