huffyuv: change statistics initialization
authorChristophe Gisquet <christophe.gisquet@gmail.com>
Wed, 11 Jun 2014 20:15:12 +0000 (22:15 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 19 Jun 2014 04:03:51 +0000 (06:03 +0200)
Normally, a Laplace distribution is more typical of the residuals
encoded, but for noisy input, it's both better and simpler to be
safe and use a 1/d^2 distribution. Second hunk could use some
renormalization but it has effectively little impact.

Output size of ffvhuff on various 4:2:0 sequences:
context=0,1/d:    851974   27226   1137281
context=0,1/d²:   619081   25069   1051500
context=0,1/d³:   501983   30454   1290561
context=0,lapl:   500650   31754   1304082

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
23 files changed:
libavcodec/huffyuvenc.c
tests/ref/seek/vsynth2-huffyuv
tests/ref/vsynth/vsynth1-ffvhuff
tests/ref/vsynth/vsynth1-ffvhuff420p12
tests/ref/vsynth/vsynth1-ffvhuff422p10left
tests/ref/vsynth/vsynth1-ffvhuff444
tests/ref/vsynth/vsynth1-ffvhuff444p16
tests/ref/vsynth/vsynth1-huffyuv
tests/ref/vsynth/vsynth1-huffyuvbgr24
tests/ref/vsynth/vsynth2-ffvhuff
tests/ref/vsynth/vsynth2-ffvhuff420p12
tests/ref/vsynth/vsynth2-ffvhuff422p10left
tests/ref/vsynth/vsynth2-ffvhuff444
tests/ref/vsynth/vsynth2-ffvhuff444p16
tests/ref/vsynth/vsynth2-huffyuv
tests/ref/vsynth/vsynth2-huffyuvbgr24
tests/ref/vsynth/vsynth3-ffvhuff
tests/ref/vsynth/vsynth3-ffvhuff420p12
tests/ref/vsynth/vsynth3-ffvhuff422p10left
tests/ref/vsynth/vsynth3-ffvhuff444
tests/ref/vsynth/vsynth3-ffvhuff444p16
tests/ref/vsynth/vsynth3-huffyuv
tests/ref/vsynth/vsynth3-huffyuvbgr24

index 0ed2c1d..157d67f 100644 (file)
@@ -400,7 +400,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
             for (j = 0; j < s->vlc_n; j++) {
                 int d = FFMIN(j, s->vlc_n - j);
 
-                s->stats[i][j] = 100000000 / (d + 1);
+                s->stats[i][j] = 100000000 / (d*d + 1);
             }
     }
 
@@ -414,7 +414,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
             int pels = s->width * s->height / (i ? 40 : 10);
             for (j = 0; j < s->vlc_n; j++) {
                 int d = FFMIN(j, s->vlc_n - j);
-                s->stats[i][j] = pels/(d + 1);
+                s->stats[i][j] = pels/(d*d + 1);
             }
         }
     } else {
index 69a37f5..ad01899 100644 (file)
@@ -1,46 +1,46 @@
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5724 size:129760
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5754 size:123508
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5724 size:129760
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5754 size:123508
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 1.880000 pts: 1.880000 pos:6069172 size:128520
+ret: 0         st: 0 flags:1 dts: 1.880000 pts: 1.880000 pos:5744998 size:121152
 ret: 0         st: 0 flags:0  ts: 0.800000
-ret: 0         st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos:2579612 size:129192
+ret: 0         st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos:2437994 size:122516
 ret:-1         st: 0 flags:1  ts:-0.320000
 ret:-1         st:-1 flags:0  ts: 2.576668
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.480000 pts: 1.480000 pos:4778228 size:129424
+ret: 0         st: 0 flags:1 dts: 1.480000 pts: 1.480000 pos:4523454 size:122784
 ret: 0         st: 0 flags:0  ts: 0.360000
-ret: 0         st: 0 flags:1 dts: 0.360000 pts: 0.360000 pos:1160248 size:128504
+ret: 0         st: 0 flags:1 dts: 0.360000 pts: 0.360000 pos:1093870 size:121320
 ret:-1         st: 0 flags:1  ts:-0.760000
 ret:-1         st:-1 flags:0  ts: 2.153336
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 1.040000 pts: 1.040000 pos:3355284 size:129424
+ret: 0         st: 0 flags:1 dts: 1.040000 pts: 1.040000 pos:3173590 size:122784
 ret: 0         st: 0 flags:0  ts:-0.040000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5724 size:129760
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5754 size:123508
 ret: 0         st: 0 flags:1  ts: 2.840000
-ret: 0         st: 0 flags:1 dts: 1.960000 pts: 1.960000 pos:6326124 size:128288
+ret: 0         st: 0 flags:1 dts: 1.960000 pts: 1.960000 pos:5987030 size:120672
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.720000 pts: 1.720000 pos:5553996 size:129016
+ret: 0         st: 0 flags:1 dts: 1.720000 pts: 1.720000 pos:5258650 size:121992
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.640000 pts: 0.640000 pos:2062492 size:129204
+ret: 0         st: 0 flags:1 dts: 0.640000 pts: 0.640000 pos:1947350 size:122568
 ret: 0         st: 0 flags:0  ts:-0.480000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5724 size:129760
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5754 size:123508
 ret: 0         st: 0 flags:1  ts: 2.400000
-ret: 0         st: 0 flags:1 dts: 1.960000 pts: 1.960000 pos:6326124 size:128288
+ret: 0         st: 0 flags:1 dts: 1.960000 pts: 1.960000 pos:5987030 size:120672
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.320000 pts: 1.320000 pos:4260860 size:129280
+ret: 0         st: 0 flags:1 dts: 1.320000 pts: 1.320000 pos:4032694 size:122544
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.200000 pts: 0.200000 pos: 646908 size:128204
+ret: 0         st: 0 flags:1 dts: 0.200000 pts: 0.200000 pos: 609906 size:120724
 ret: 0         st: 0 flags:0  ts:-0.920000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5724 size:129760
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5754 size:123508
 ret: 0         st: 0 flags:1  ts: 2.000000
-ret: 0         st: 0 flags:1 dts: 1.960000 pts: 1.960000 pos:6326124 size:128288
+ret: 0         st: 0 flags:1 dts: 1.960000 pts: 1.960000 pos:5987030 size:120672
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.880000 pts: 0.880000 pos:2838068 size:129268
+ret: 0         st: 0 flags:1 dts: 0.880000 pts: 0.880000 pos:2683062 size:122588
 ret:-1         st:-1 flags:1  ts:-0.222493
 ret:-1         st: 0 flags:0  ts: 2.680000
 ret: 0         st: 0 flags:1  ts: 1.560000
-ret: 0         st: 0 flags:1 dts: 1.560000 pts: 1.560000 pos:5037024 size:129284
+ret: 0         st: 0 flags:1 dts: 1.560000 pts: 1.560000 pos:4768978 size:122556
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:1546172 size:128860
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:1458406 size:121888
 ret:-1         st:-1 flags:1  ts:-0.645825
index 037e3a6..a8b9e41 100644 (file)
@@ -1,4 +1,4 @@
-9f1b37f939293e62673a49f38d4fba11 *tests/data/fate/vsynth1-ffvhuff.avi
-5987196 tests/data/fate/vsynth1-ffvhuff.avi
+936c7cb29dc7b12a5db8a0217b3486b9 *tests/data/fate/vsynth1-ffvhuff.avi
+6809210 tests/data/fate/vsynth1-ffvhuff.avi
 c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-ffvhuff.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
index ad4d8a9..334c846 100644 (file)
@@ -1,4 +1,4 @@
-7aad91fbb4f1f9fca8a0918145775a8b *tests/data/fate/vsynth1-ffvhuff420p12.avi
-10267454 tests/data/fate/vsynth1-ffvhuff420p12.avi
+571a999f4f0e5895be97d9240e036695 *tests/data/fate/vsynth1-ffvhuff420p12.avi
+14205352 tests/data/fate/vsynth1-ffvhuff420p12.avi
 b48f32c140712e8c7bf81cfdd66ae312 *tests/data/fate/vsynth1-ffvhuff420p12.out.rawvideo
 stddev:    0.68 PSNR: 51.47 MAXDIFF:    1 bytes:  7603200/  7603200
index fe7215f..0d88cdd 100644 (file)
@@ -1,4 +1,4 @@
-6e043c33756fa245a8103b0db10071e5 *tests/data/fate/vsynth1-ffvhuff422p10left.avi
-10552692 tests/data/fate/vsynth1-ffvhuff422p10left.avi
+43705266ad32d9b98feb54d59c05b83e *tests/data/fate/vsynth1-ffvhuff422p10left.avi
+13860680 tests/data/fate/vsynth1-ffvhuff422p10left.avi
 c31e6caada921ffa3daad3432ef3b754 *tests/data/fate/vsynth1-ffvhuff422p10left.out.rawvideo
 stddev:    1.85 PSNR: 42.78 MAXDIFF:   29 bytes:  7603200/  7603200
index 181ca97..7c518f4 100644 (file)
@@ -1,4 +1,4 @@
-80d9cc81d28509d059bda5e736183b9a *tests/data/fate/vsynth1-ffvhuff444.avi
-10967556 tests/data/fate/vsynth1-ffvhuff444.avi
+962b03019d92658356eb7cdfad857d08 *tests/data/fate/vsynth1-ffvhuff444.avi
+11712338 tests/data/fate/vsynth1-ffvhuff444.avi
 10fb42f1abf40a289c3edafc0390482c *tests/data/fate/vsynth1-ffvhuff444.out.rawvideo
 stddev:    2.67 PSNR: 39.60 MAXDIFF:   43 bytes:  7603200/  7603200
index d25bf73..76acffd 100644 (file)
@@ -1,4 +1,4 @@
-ba3943140ad9d11f1b8019c890a9be19 *tests/data/fate/vsynth1-ffvhuff444p16.avi
-20610414 tests/data/fate/vsynth1-ffvhuff444p16.avi
+9d7ab6d77fb4004512246c2f93f93c29 *tests/data/fate/vsynth1-ffvhuff444p16.avi
+24706272 tests/data/fate/vsynth1-ffvhuff444p16.avi
 ee8379fa217dfd023de3aa6974a14d1e *tests/data/fate/vsynth1-ffvhuff444p16.out.rawvideo
 stddev:    2.66 PSNR: 39.62 MAXDIFF:   44 bytes:  7603200/  7603200
index e83ce5d..f747d9d 100644 (file)
@@ -1,4 +1,4 @@
-958daafcef5d9bff6ba56ba04ab87882 *tests/data/fate/vsynth1-huffyuv.avi
-7933788 tests/data/fate/vsynth1-huffyuv.avi
+b48b81b3bdd4e24834f9ada6f567b94e *tests/data/fate/vsynth1-huffyuv.avi
+8876470 tests/data/fate/vsynth1-huffyuv.avi
 c5ccac874dbf808e9088bc3107860042 *tests/data/fate/vsynth1-huffyuv.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
index 197b49f..c40ad0f 100644 (file)
@@ -1,4 +1,4 @@
-179e6126e977cda3dba49620e070e13f *tests/data/fate/vsynth1-huffyuvbgr24.avi
-11504664 tests/data/fate/vsynth1-huffyuvbgr24.avi
+62748f420e76a0b26886f432074f89a1 *tests/data/fate/vsynth1-huffyuvbgr24.avi
+13196986 tests/data/fate/vsynth1-huffyuvbgr24.avi
 49c03ab1b73b7cd3cabc3c77a9479c9e *tests/data/fate/vsynth1-huffyuvbgr24.out.rawvideo
 stddev:    3.16 PSNR: 38.12 MAXDIFF:   50 bytes:  7603200/  7603200
index 90501c0..921d5bf 100644 (file)
@@ -1,4 +1,4 @@
-90efd24e880e420456ee809170470884 *tests/data/fate/vsynth2-ffvhuff.avi
-4988044 tests/data/fate/vsynth2-ffvhuff.avi
+7cb61df06d2cb4659ceb8d73c4822aaf *tests/data/fate/vsynth2-ffvhuff.avi
+4845022 tests/data/fate/vsynth2-ffvhuff.avi
 dde5895817ad9d219f79a52d0bdfb001 *tests/data/fate/vsynth2-ffvhuff.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
index c0d9e3c..1f1279f 100644 (file)
@@ -1,4 +1,4 @@
-ec4f82082b23def2c737b389538d23a7 *tests/data/fate/vsynth2-ffvhuff420p12.avi
-8601770 tests/data/fate/vsynth2-ffvhuff420p12.avi
+e5873a19c7be1cdf25600eb033738b9e *tests/data/fate/vsynth2-ffvhuff420p12.avi
+10925576 tests/data/fate/vsynth2-ffvhuff420p12.avi
 08b3c6c70eba608bae926608ff253f2a *tests/data/fate/vsynth2-ffvhuff420p12.out.rawvideo
 stddev:    0.68 PSNR: 51.38 MAXDIFF:    1 bytes:  7603200/  7603200
index ae9889b..bb16978 100644 (file)
@@ -1,4 +1,4 @@
-e8a8c447cda75c64336f4c1d79027376 *tests/data/fate/vsynth2-ffvhuff422p10left.avi
-8874580 tests/data/fate/vsynth2-ffvhuff422p10left.avi
+d7d321c3b1ed3378e03b2f618f248d86 *tests/data/fate/vsynth2-ffvhuff422p10left.avi
+10041832 tests/data/fate/vsynth2-ffvhuff422p10left.avi
 a627fb50c8276200fd71383977d87ca3 *tests/data/fate/vsynth2-ffvhuff422p10left.out.rawvideo
 stddev:    0.34 PSNR: 57.43 MAXDIFF:    6 bytes:  7603200/  7603200
index 7013a7a..c4ea9cd 100644 (file)
@@ -1,4 +1,4 @@
-f77a213d963aef0384a8cc2e08a2e6d8 *tests/data/fate/vsynth2-ffvhuff444.avi
-8666652 tests/data/fate/vsynth2-ffvhuff444.avi
+68e78dc89bb596f93a14e7f4a7a24365 *tests/data/fate/vsynth2-ffvhuff444.avi
+7530714 tests/data/fate/vsynth2-ffvhuff444.avi
 d43cb310c130c69214332d74f6ee5f9a *tests/data/fate/vsynth2-ffvhuff444.out.rawvideo
 stddev:    0.41 PSNR: 55.80 MAXDIFF:    7 bytes:  7603200/  7603200
index 30286ff..1f03a03 100644 (file)
@@ -1,4 +1,4 @@
-ffa8c6d9f39d08806f88c4933c3b9fa6 *tests/data/fate/vsynth2-ffvhuff444p16.avi
-21648206 tests/data/fate/vsynth2-ffvhuff444p16.avi
+db17747292df97d6c62b15b041c378da *tests/data/fate/vsynth2-ffvhuff444p16.avi
+26360716 tests/data/fate/vsynth2-ffvhuff444p16.avi
 05ccd9a38f9726030b3099c0c99d3a13 *tests/data/fate/vsynth2-ffvhuff444p16.out.rawvideo
 stddev:    0.45 PSNR: 55.06 MAXDIFF:    7 bytes:  7603200/  7603200
index 0611064..a2d2ae3 100644 (file)
@@ -1,4 +1,4 @@
-a5caf03d83c7f45b34908a0dbf5b4efb *tests/data/fate/vsynth2-huffyuv.avi
-6455220 tests/data/fate/vsynth2-huffyuv.avi
+c639e4044a66dc5dffb46d5d82516ef8 *tests/data/fate/vsynth2-huffyuv.avi
+6108510 tests/data/fate/vsynth2-huffyuv.avi
 dde5895817ad9d219f79a52d0bdfb001 *tests/data/fate/vsynth2-huffyuv.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  7603200/  7603200
index a63985e..939eb2f 100644 (file)
@@ -1,4 +1,4 @@
-4516094cbbac6ef2e52b3ae3cc206ea5 *tests/data/fate/vsynth2-huffyuvbgr24.avi
-9316868 tests/data/fate/vsynth2-huffyuvbgr24.avi
+d72d98a2847811499028f8997320a38b *tests/data/fate/vsynth2-huffyuvbgr24.avi
+8872410 tests/data/fate/vsynth2-huffyuvbgr24.avi
 0a8b7ddfec03622e37c869c5b552f9fc *tests/data/fate/vsynth2-huffyuvbgr24.out.rawvideo
 stddev:    1.24 PSNR: 46.26 MAXDIFF:   17 bytes:  7603200/  7603200
index dbf14a4..c89611f 100644 (file)
@@ -1,4 +1,4 @@
-8cec39ed9e4719726478ab494a16dd4b *tests/data/fate/vsynth3-ffvhuff.avi
-78040 tests/data/fate/vsynth3-ffvhuff.avi
+bc18700e9ce7947fe4c5ffc71457f3c1 *tests/data/fate/vsynth3-ffvhuff.avi
+90206 tests/data/fate/vsynth3-ffvhuff.avi
 a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-ffvhuff.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/    86700
index bf0818a..b51882e 100644 (file)
@@ -1,4 +1,4 @@
-1ed94434195408cba4ee9f0e7de482e8 *tests/data/fate/vsynth3-ffvhuff420p12.avi
-124866 tests/data/fate/vsynth3-ffvhuff420p12.avi
+a6164daa3036ae92eb0b3f0831268165 *tests/data/fate/vsynth3-ffvhuff420p12.avi
+172132 tests/data/fate/vsynth3-ffvhuff420p12.avi
 eb1a8ff2c33ba5145b5a89727ee5dcb8 *tests/data/fate/vsynth3-ffvhuff420p12.out.rawvideo
 stddev:   46.89 PSNR: 14.71 MAXDIFF:  239 bytes:    86700/    86700
index abebb55..7dca14e 100644 (file)
@@ -1,4 +1,4 @@
-dcd4a5cae84b4ab0b376824772e3ad2b *tests/data/fate/vsynth3-ffvhuff422p10left.avi
-127832 tests/data/fate/vsynth3-ffvhuff422p10left.avi
+2459272ee10f3b503940324ba5dcc1e5 *tests/data/fate/vsynth3-ffvhuff422p10left.avi
+168836 tests/data/fate/vsynth3-ffvhuff422p10left.avi
 863818eed035b3fa7b19535927687879 *tests/data/fate/vsynth3-ffvhuff422p10left.out.rawvideo
 stddev:   38.45 PSNR: 16.43 MAXDIFF:  225 bytes:    86700/    86700
index cd9a531..8446a7f 100644 (file)
@@ -1,4 +1,4 @@
-31efbb2ddfe03d625f809156240dd0ef *tests/data/fate/vsynth3-ffvhuff444.avi
-137588 tests/data/fate/vsynth3-ffvhuff444.avi
+134851e6f9702e83c4c9aa6e5ff1eaa4 *tests/data/fate/vsynth3-ffvhuff444.avi
+151362 tests/data/fate/vsynth3-ffvhuff444.avi
 02a85ec07377df6b483281038f8882ee *tests/data/fate/vsynth3-ffvhuff444.out.rawvideo
 stddev:    3.06 PSNR: 38.40 MAXDIFF:   40 bytes:    86700/    86700
index bb9666a..842104f 100644 (file)
@@ -1,4 +1,4 @@
-9a534fb2a739bdf572572867d16b2343 *tests/data/fate/vsynth3-ffvhuff444p16.avi
-258130 tests/data/fate/vsynth3-ffvhuff444p16.avi
+1a6e53646d0988bd67ced92923439e51 *tests/data/fate/vsynth3-ffvhuff444p16.avi
+320084 tests/data/fate/vsynth3-ffvhuff444p16.avi
 e5933e1e6dbacddb78e6d90cd5ed2b5d *tests/data/fate/vsynth3-ffvhuff444p16.out.rawvideo
 stddev:    3.06 PSNR: 38.40 MAXDIFF:   40 bytes:    86700/    86700
index 7040c7c..0a16b65 100644 (file)
@@ -1,4 +1,4 @@
-71353e66bb02b860c048cd438d0bc80f *tests/data/fate/vsynth3-huffyuv.avi
-101484 tests/data/fate/vsynth3-huffyuv.avi
+27cd1ec1151b7456117f98a8cdf281cd *tests/data/fate/vsynth3-huffyuv.avi
+116346 tests/data/fate/vsynth3-huffyuv.avi
 a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-huffyuv.out.rawvideo
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:    86700/    86700
index a007aca..95f4422 100644 (file)
@@ -1,4 +1,4 @@
-1305108d6ab10d3488467fae4c61cbeb *tests/data/fate/vsynth3-huffyuvbgr24.avi
-142020 tests/data/fate/vsynth3-huffyuvbgr24.avi
+a7bf0c82277d59d425ebe4af93f75e27 *tests/data/fate/vsynth3-huffyuvbgr24.avi
+165154 tests/data/fate/vsynth3-huffyuvbgr24.avi
 5d031d2e891b13593b8cd79e63d083b4 *tests/data/fate/vsynth3-huffyuvbgr24.out.rawvideo
 stddev:    3.23 PSNR: 37.92 MAXDIFF:   50 bytes:    86700/    86700