History

avcodec/flashsvenc: add compression_level option

This allows setting the compression level used by zlib.

Ramiro Polla committed 2 years ago

Commit 3661d191 parent 38272335 files · +13 −7Browse files

Unified · Split

5 files
  1. libavcodec/flashsvenc.c +8 −2
  2. tests/ref/vsynth/vsynth1-flashsv +1 −1
  3. tests/ref/vsynth/vsynth2-flashsv +2 −2
  4. tests/ref/vsynth/vsynth3-flashsv +1 −1
  5. tests/ref/vsynth/vsynth_lena-flashsv +1 −1
libavcodec/flashsvenc.c+8−2
@@ -67,6 +67,7 @@ typedef struct FlashSVContext { · 66 unmodified lines
67 unsigned packet_size;67 unsigned packet_size;
68 int64_t last_key_frame;68 int64_t last_key_frame;
69 uint8_t tmpblock[3 * 256 * 256];69 uint8_t tmpblock[3 * 256 * 256];
70 int compression_level;
70} FlashSVContext;71} FlashSVContext;
71 72
72static int copy_region_enc(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,73static 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 nb_blocks = h_blocks * v_blocks;122 nb_blocks = h_blocks * v_blocks;
122 s->packet_size = 4 + nb_blocks * (2 + 3 * BLOCK_WIDTH * BLOCK_HEIGHT);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 return 0;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 p->linesize[0], previous_frame);175 p->linesize[0], previous_frame);
171 176
172 if (res || *I_frame) {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 ret = compress2(ptr + 2, &zsize, s->tmpblock,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 if (ret != Z_OK)183 if (ret != Z_OK)
178 av_log(s->avctx, AV_LOG_ERROR,184 av_log(s->avctx, AV_LOG_ERROR,
tests/ref/vsynth/vsynth1-flashsv+1−1
@@ -1,4 +1,4 @@
197894502b4cb57aca1105b6333f72dae *tests/data/fate/vsynth1-flashsv.flv161b0825258ac6fe85691bdefd892960d *tests/data/fate/vsynth1-flashsv.flv
214681925 tests/data/fate/vsynth1-flashsv.flv214681925 tests/data/fate/vsynth1-flashsv.flv
3791e1fb999deb2e4156e2286d48c4ed1 *tests/data/fate/vsynth1-flashsv.out.rawvideo3791e1fb999deb2e4156e2286d48c4ed1 *tests/data/fate/vsynth1-flashsv.out.rawvideo
4stddev: 2.84 PSNR: 39.04 MAXDIFF: 49 bytes: 7603200/ 76032004stddev: 2.84 PSNR: 39.04 MAXDIFF: 49 bytes: 7603200/ 7603200
tests/ref/vsynth/vsynth2-flashsv+2−2
@@ -1,4 +1,4 @@
1f4b45770dd93b43b4077532e8ef90bfc *tests/data/fate/vsynth2-flashsv.flv1a2f145e6e44b51f8fc64ead06a994273 *tests/data/fate/vsynth2-flashsv.flv
211636546 tests/data/fate/vsynth2-flashsv.flv211637702 tests/data/fate/vsynth2-flashsv.flv
37f0fc12c02e68faddc153e69ddd6841c *tests/data/fate/vsynth2-flashsv.out.rawvideo37f0fc12c02e68faddc153e69ddd6841c *tests/data/fate/vsynth2-flashsv.out.rawvideo
4stddev: 1.20 PSNR: 46.52 MAXDIFF: 20 bytes: 7603200/ 76032004stddev: 1.20 PSNR: 46.52 MAXDIFF: 20 bytes: 7603200/ 7603200
tests/ref/vsynth/vsynth3-flashsv+1−1
@@ -1,4 +1,4 @@
1832fe60169f4d91339458c60a5292924 *tests/data/fate/vsynth3-flashsv.flv1a05a9ab0ae21925dd10a83639de77d77 *tests/data/fate/vsynth3-flashsv.flv
2171419 tests/data/fate/vsynth3-flashsv.flv2171419 tests/data/fate/vsynth3-flashsv.flv
3faa660b0ecaaab1bf9b5d7284019aa01 *tests/data/fate/vsynth3-flashsv.out.rawvideo3faa660b0ecaaab1bf9b5d7284019aa01 *tests/data/fate/vsynth3-flashsv.out.rawvideo
4stddev: 2.97 PSNR: 38.67 MAXDIFF: 49 bytes: 86700/ 867004stddev: 2.97 PSNR: 38.67 MAXDIFF: 49 bytes: 86700/ 86700
tests/ref/vsynth/vsynth_lena-flashsv+1−1
@@ -1,4 +1,4 @@
10667077971e0cb63b5f49c580006e90e *tests/data/fate/vsynth_lena-flashsv.flv159cdcf5f92c5113e27b2fda632ccd55c *tests/data/fate/vsynth_lena-flashsv.flv
212368953 tests/data/fate/vsynth_lena-flashsv.flv212368953 tests/data/fate/vsynth_lena-flashsv.flv
33a984506f1ebfc9fb73b6814cab201cc *tests/data/fate/vsynth_lena-flashsv.out.rawvideo33a984506f1ebfc9fb73b6814cab201cc *tests/data/fate/vsynth_lena-flashsv.out.rawvideo
4stddev: 0.66 PSNR: 51.73 MAXDIFF: 14 bytes: 7603200/ 76032004stddev: 0.66 PSNR: 51.73 MAXDIFF: 14 bytes: 7603200/ 7603200

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t