This allows setting the compression level used by zlib.
Showing the changes to libavcodec (1 of 5 files). Show all
Unified · Split
| @@ -67,6 +67,7 @@ typedef struct FlashSVContext { · 66 unmodified lines | ||
| 67 | 67 | unsigned packet_size; |
| 68 | 68 | int64_t last_key_frame; |
| 69 | 69 | uint8_t tmpblock[3 * 256 * 256]; |
| 70 | + int compression_level; | |
| 70 | 71 | } FlashSVContext; |
| 71 | 72 | |
| 72 | 73 | static int copy_region_enc(const uint8_t *sptr, uint8_t *dptr, int dx, int dy, |
| @@ -121,6 +122,10 @@ static av_cold int flashsv_encode_init(AVCodecContext *avctx) · 48 unmodified lines | ||
| 121 | 122 | nb_blocks = h_blocks * v_blocks; |
| 122 | 123 | s->packet_size = 4 + nb_blocks * (2 + 3 * BLOCK_WIDTH * BLOCK_HEIGHT); |
| 123 | 124 | |
| 125 | + s->compression_level = avctx->compression_level == FF_COMPRESSION_DEFAULT | |
| 126 | + ? Z_DEFAULT_COMPRESSION | |
| 127 | + : av_clip(avctx->compression_level, 0, 9); | |
| 128 | + | |
| 124 | 129 | return 0; |
| 125 | 130 | } |
| 126 | 131 | |
| @@ -170,9 +175,10 @@ static int encode_bitstream(FlashSVContext *s, const AVFrame *p, uint8_t *buf, · 43 unmodified lines | ||
| 170 | 175 | p->linesize[0], previous_frame); |
| 171 | 176 | |
| 172 | 177 | if (res || *I_frame) { |
| 173 | − unsigned long zsize = 3 * block_width * block_height; | |
| 178 | + unsigned long zsize = 3 * block_width * block_height + 12; | |
| 174 | 179 | ret = compress2(ptr + 2, &zsize, s->tmpblock, |
| 175 | − 3 * cur_blk_width * cur_blk_height, 9); | |
| 180 | + 3 * cur_blk_width * cur_blk_height, | |
| 181 | + s->compression_level); | |
| 176 | 182 | |
| 177 | 183 | if (ret != Z_OK) |
| 178 | 184 | av_log(s->avctx, AV_LOG_ERROR, |