fixpoint log() for tiny_psnr so it can output actual PSNR
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 31 Dec 2003 02:32:54 +0000 (02:32 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 31 Dec 2003 02:32:54 +0000 (02:32 +0000)
Originally committed as revision 2640 to svn://svn.ffmpeg.org/ffmpeg/trunk

tests/ffmpeg.regression.ref
tests/rotozoom.regression.ref
tests/tiny_psnr.c

index 4ec3c8f..fc6e052 100644 (file)
@@ -1,70 +1,70 @@
 ffmpeg regression test
 74e25b401f34321aeb854e264ef62df8 *./data/a-mpeg1.mpg
 1ee8816bd078efe66be0090b1d9b0af1 *./data/out.yuv
 ffmpeg regression test
 74e25b401f34321aeb854e264ef62df8 *./data/a-mpeg1.mpg
 1ee8816bd078efe66be0090b1d9b0af1 *./data/out.yuv
-stddev:  7.63 bytes:7602176
+stddev:  7.63 PSNR:30.47 bytes:7602176
 b588110bebb48b5a1815ac26d0f0c9cc *./data/a-mpeg2.mpg
 ddfa5c618dab54df0f47976ddd55d90f *./data/out.yuv
 b588110bebb48b5a1815ac26d0f0c9cc *./data/a-mpeg2.mpg
 ddfa5c618dab54df0f47976ddd55d90f *./data/out.yuv
-stddev:  7.65 bytes:7602176
+stddev:  7.65 PSNR:30.44 bytes:7602176
 345b79f7afe43abc0128a7b1d5fff949 *./data/a-mpeg2i.mpg
 5df468301367ed2dde5f064bf4c17301 *./data/out.yuv
 345b79f7afe43abc0128a7b1d5fff949 *./data/a-mpeg2i.mpg
 5df468301367ed2dde5f064bf4c17301 *./data/out.yuv
-stddev:  7.96 bytes:7602176
+stddev:  7.96 PSNR:30.10 bytes:7602176
 d0dc46dd831398237a690ebbeff18b64 *./data/a-msmpeg4v2.avi
 712aa6c959d1d90a78fe98657cbff19c *./data/out.yuv
 d0dc46dd831398237a690ebbeff18b64 *./data/a-msmpeg4v2.avi
 712aa6c959d1d90a78fe98657cbff19c *./data/out.yuv
-stddev:  8.11 bytes:7602176
+stddev:  8.11 PSNR:29.94 bytes:7602176
 dae855177b45cbe6e40c6777f95095ef *./data/a-msmpeg4.avi
 8786aa956838234fe3e48d0ef8cbd46c *./data/out.yuv
 dae855177b45cbe6e40c6777f95095ef *./data/a-msmpeg4.avi
 8786aa956838234fe3e48d0ef8cbd46c *./data/out.yuv
-stddev:  8.12 bytes:7602176
+stddev:  8.12 PSNR:29.93 bytes:7602176
 6633a1111c734c9156729b8b7e198c17 *./data/a-wmv1.avi
 7261e23fd8ad1de6efee022051b936be *./data/out.yuv
 6633a1111c734c9156729b8b7e198c17 *./data/a-wmv1.avi
 7261e23fd8ad1de6efee022051b936be *./data/out.yuv
-stddev:  8.10 bytes:7602176
+stddev:  8.10 PSNR:29.94 bytes:7602176
 30dcbbe391149d981162a1f4727c43d6 *./data/a-wmv2.avi
 7261e23fd8ad1de6efee022051b936be *./data/out.yuv
 30dcbbe391149d981162a1f4727c43d6 *./data/a-wmv2.avi
 7261e23fd8ad1de6efee022051b936be *./data/out.yuv
-stddev:  8.10 bytes:7602176
+stddev:  8.10 PSNR:29.94 bytes:7602176
 4bf9df20cdeb1aa01115761642b4e80b *./data/a-h263.avi
 545df74e0aa443499600faedd10a7065 *./data/out.yuv
 4bf9df20cdeb1aa01115761642b4e80b *./data/a-h263.avi
 545df74e0aa443499600faedd10a7065 *./data/out.yuv
-stddev:  8.18 bytes:7602176
+stddev:  8.18 PSNR:29.86 bytes:7602176
 920a0a8a0063655d1f34dcaad7857f98 *./data/a-h263p.avi
 0eb167c9dfcbeeecbf3debed8af8f811 *./data/out.yuv
 920a0a8a0063655d1f34dcaad7857f98 *./data/a-h263p.avi
 0eb167c9dfcbeeecbf3debed8af8f811 *./data/out.yuv
-stddev:  2.08 bytes:7602176
+stddev:  2.08 PSNR:41.74 bytes:7602176
 66f8b4b5b4f0655cff7bdbc44969cab3 *./data/a-odivx.mp4
 5bd332c77ef45e58b7017e06a0467dd3 *./data/out.yuv
 66f8b4b5b4f0655cff7bdbc44969cab3 *./data/a-odivx.mp4
 5bd332c77ef45e58b7017e06a0467dd3 *./data/out.yuv
-stddev:  7.94 bytes:7602176
+stddev:  7.94 PSNR:30.12 bytes:7602176
 5704a082cc5c5970620123ae20566286 *./data/a-huffyuv.avi
 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
 5704a082cc5c5970620123ae20566286 *./data/a-huffyuv.avi
 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
-stddev:  0.00 bytes:7602176
+stddev:  0.00 PSNR:99.99 bytes:7602176
 e9f63126859b97cd23cd1413038f8f7b *./data/a-mpeg4-rc.avi
 90a159074b1b109569914ee63f387860 *./data/out.yuv
 e9f63126859b97cd23cd1413038f8f7b *./data/a-mpeg4-rc.avi
 90a159074b1b109569914ee63f387860 *./data/out.yuv
-stddev: 10.18 bytes:7145472
+stddev: 10.18 PSNR:27.96 bytes:7145472
 d7d295f97a1e07b633f973d2325880ce *./data/a-mpeg4-adv.avi
 612f79510c8098f1421aa154047e2bf2 *./data/out.yuv
 d7d295f97a1e07b633f973d2325880ce *./data/a-mpeg4-adv.avi
 612f79510c8098f1421aa154047e2bf2 *./data/out.yuv
-stddev:  7.25 bytes:7602176
+stddev:  7.25 PSNR:30.91 bytes:7602176
 f863f4198521bd76930ea33991b47273 *./data/a-error-mpeg4-adv.avi
 ba7fcd126c7c9fead5a5de71aaaf0624 *./data/out.yuv
 f863f4198521bd76930ea33991b47273 *./data/a-error-mpeg4-adv.avi
 ba7fcd126c7c9fead5a5de71aaaf0624 *./data/out.yuv
-stddev: 16.80 bytes:7602176
+stddev: 16.80 PSNR:23.61 bytes:7602176
 328ebd044362116e274739e23c482ee7 *./data/a-mpeg1b.mpg
 788a9d500dc8986231a18076fc80fd73 *./data/out.yuv
 328ebd044362116e274739e23c482ee7 *./data/a-mpeg1b.mpg
 788a9d500dc8986231a18076fc80fd73 *./data/out.yuv
-stddev: 10.07 bytes:7145472
+stddev: 10.07 PSNR:28.06 bytes:7145472
 07042f42b3119c39eb26537a84a451df *./data/a-mjpeg.avi
 f23a9e50a559e174766ee808c48fea22 *./data/out.yuv
 07042f42b3119c39eb26537a84a451df *./data/a-mjpeg.avi
 f23a9e50a559e174766ee808c48fea22 *./data/out.yuv
-stddev:  8.87 bytes:7602176
+stddev:  8.87 PSNR:29.15 bytes:7602176
 1d565db4a3a054261af95f2483a37cd6 *./data/a-ljpeg.avi
 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
 1d565db4a3a054261af95f2483a37cd6 *./data/a-ljpeg.avi
 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
-stddev:  0.00 bytes:7602176
+stddev:  0.00 PSNR:99.99 bytes:7602176
 4b37703d3dc03873f99603165c0fe11e *./data/a-rv10.rm
 255469fef47bee94cfb2e3385ebb736b *./data/out.yuv
 4b37703d3dc03873f99603165c0fe11e *./data/a-rv10.rm
 255469fef47bee94cfb2e3385ebb736b *./data/out.yuv
-stddev: 13.42 bytes:7602176
+stddev: 13.42 PSNR:25.56 bytes:7602176
 89ad858355f9b0a92d024c5ba6e369dd *./data/a-asv1.avi
 b3e1696d73071c8f7f0ff4e10c1677ca *./data/out.yuv
 89ad858355f9b0a92d024c5ba6e369dd *./data/a-asv1.avi
 b3e1696d73071c8f7f0ff4e10c1677ca *./data/out.yuv
-stddev: 19.19 bytes:7602176
+stddev: 19.19 PSNR:22.46 bytes:7602176
 3909db39c3d2e9a72a952254e8685ff7 *./data/a-asv2.avi
 551b263bfb2acb9ea6dd2000f184494f *./data/out.yuv
 3909db39c3d2e9a72a952254e8685ff7 *./data/a-asv2.avi
 551b263bfb2acb9ea6dd2000f184494f *./data/out.yuv
-stddev: 17.98 bytes:7602176
+stddev: 17.98 PSNR:23.02 bytes:7602176
 37a528aa9efc28c5c3cc8191da90e012 *./data/a-flv.flv
 57ea0821ec4377e96647adc22717a4ba *./data/out.yuv
 37a528aa9efc28c5c3cc8191da90e012 *./data/a-flv.flv
 57ea0821ec4377e96647adc22717a4ba *./data/out.yuv
-stddev:  8.19 bytes:7602176
+stddev:  8.19 PSNR:29.85 bytes:7602176
 0ed9b02681d6d44bf8c390ba6c4f5c66 *./data/a-ffv1.avi
 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
 0ed9b02681d6d44bf8c390ba6c4f5c66 *./data/a-ffv1.avi
 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
-stddev:  0.00 bytes:7602176
+stddev:  0.00 PSNR:99.99 bytes:7602176
 21f8ff9f1daacd9133683bb4ea0f50a4 *./data/a-mp2.mp2
 624d9789f3ac193bbae4af3bd8cb02b7 *./data/out.wav
 d056da679e6d6682812fffb28a7f0db6 *./data/a-ac3.rm
 21f8ff9f1daacd9133683bb4ea0f50a4 *./data/a-mp2.mp2
 624d9789f3ac193bbae4af3bd8cb02b7 *./data/out.wav
 d056da679e6d6682812fffb28a7f0db6 *./data/a-ac3.rm
index 3277747..3f9edc6 100644 (file)
@@ -1,70 +1,70 @@
 ffmpeg regression test
 a6ccb5e768c7bed7a08f8e4343d81871 *./data/a-mpeg1.mpg
 9364e15902bc56603dfb453f8bf146e0 *./data/out.yuv
 ffmpeg regression test
 a6ccb5e768c7bed7a08f8e4343d81871 *./data/a-mpeg1.mpg
 9364e15902bc56603dfb453f8bf146e0 *./data/out.yuv
-stddev:  4.93 bytes:7602176
+stddev:  4.93 PSNR:34.25 bytes:7602176
 aa0f088777131d8ffb627e6ff37312ca *./data/a-mpeg2.mpg
 830e7d798089ea6213e0867fd7676fde *./data/out.yuv
 aa0f088777131d8ffb627e6ff37312ca *./data/a-mpeg2.mpg
 830e7d798089ea6213e0867fd7676fde *./data/out.yuv
-stddev:  4.95 bytes:7602176
+stddev:  4.95 PSNR:34.22 bytes:7602176
 ed480119089c61ba5a5a8668675c7d49 *./data/a-mpeg2i.mpg
 a6ec3343ce12d72ccc7d0d8303b84781 *./data/out.yuv
 ed480119089c61ba5a5a8668675c7d49 *./data/a-mpeg2i.mpg
 a6ec3343ce12d72ccc7d0d8303b84781 *./data/out.yuv
-stddev:  4.96 bytes:7602176
+stddev:  4.96 PSNR:34.20 bytes:7602176
 14db391f167b52b21a983157b410affc *./data/a-msmpeg4v2.avi
 fc8881e0904af9491d5fa0163183954b *./data/out.yuv
 14db391f167b52b21a983157b410affc *./data/a-msmpeg4v2.avi
 fc8881e0904af9491d5fa0163183954b *./data/out.yuv
-stddev:  5.29 bytes:7602176
+stddev:  5.29 PSNR:33.64 bytes:7602176
 484b4dccac1e552f0f29971f4a066598 *./data/a-msmpeg4.avi
 dd82e8badc40ad5f76b0ffc1d6945b1c *./data/out.yuv
 484b4dccac1e552f0f29971f4a066598 *./data/a-msmpeg4.avi
 dd82e8badc40ad5f76b0ffc1d6945b1c *./data/out.yuv
-stddev:  5.29 bytes:7602176
+stddev:  5.29 PSNR:33.64 bytes:7602176
 d63c0cbb6d845bfd8e2735b4ea733a53 *./data/a-wmv1.avi
 407c23671e7c7265c19c91966dbba317 *./data/out.yuv
 d63c0cbb6d845bfd8e2735b4ea733a53 *./data/a-wmv1.avi
 407c23671e7c7265c19c91966dbba317 *./data/out.yuv
-stddev:  5.29 bytes:7602176
+stddev:  5.29 PSNR:33.65 bytes:7602176
 ba4616dc4db0db636a7c26bc8f2de04e *./data/a-wmv2.avi
 407c23671e7c7265c19c91966dbba317 *./data/out.yuv
 ba4616dc4db0db636a7c26bc8f2de04e *./data/a-wmv2.avi
 407c23671e7c7265c19c91966dbba317 *./data/out.yuv
-stddev:  5.29 bytes:7602176
+stddev:  5.29 PSNR:33.65 bytes:7602176
 f980b5e38c4b919fbe5b660fe12fcf1a *./data/a-h263.avi
 8bcc9f78373ec424e864b40734e124ba *./data/out.yuv
 f980b5e38c4b919fbe5b660fe12fcf1a *./data/a-h263.avi
 8bcc9f78373ec424e864b40734e124ba *./data/out.yuv
-stddev:  5.41 bytes:7602176
+stddev:  5.41 PSNR:33.45 bytes:7602176
 f7828488c31ccb6787367ef4e4a2ad42 *./data/a-h263p.avi
 7d39d1f272205a6a231d0e0baf32ff9d *./data/out.yuv
 f7828488c31ccb6787367ef4e4a2ad42 *./data/a-h263p.avi
 7d39d1f272205a6a231d0e0baf32ff9d *./data/out.yuv
-stddev:  1.91 bytes:7602176
+stddev:  1.91 PSNR:42.49 bytes:7602176
 a831828595e5764e6ee30c2d9e548385 *./data/a-odivx.mp4
 ad75d173bd30d642147f00da21df0012 *./data/out.yuv
 a831828595e5764e6ee30c2d9e548385 *./data/a-odivx.mp4
 ad75d173bd30d642147f00da21df0012 *./data/out.yuv
-stddev:  5.27 bytes:7602176
+stddev:  5.27 PSNR:33.67 bytes:7602176
 242a7a18c2793e115007bc163861ef4e *./data/a-huffyuv.avi
 dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
 242a7a18c2793e115007bc163861ef4e *./data/a-huffyuv.avi
 dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
-stddev:  0.00 bytes:7602176
+stddev:  0.00 PSNR:99.99 bytes:7602176
 6a469f42ce6946dd4c708f9e51e3da6a *./data/a-mpeg4-rc.avi
 df9de7134d961119705b4e0cabca1f12 *./data/out.yuv
 6a469f42ce6946dd4c708f9e51e3da6a *./data/a-mpeg4-rc.avi
 df9de7134d961119705b4e0cabca1f12 *./data/out.yuv
-stddev:  4.20 bytes:7145472
+stddev:  4.20 PSNR:35.64 bytes:7145472
 483504d060b0bd8ac1acfa3a823c2ad7 *./data/a-mpeg4-adv.avi
 08d24bdd7da80cffaf8abaa3e71b1843 *./data/out.yuv
 483504d060b0bd8ac1acfa3a823c2ad7 *./data/a-mpeg4-adv.avi
 08d24bdd7da80cffaf8abaa3e71b1843 *./data/out.yuv
-stddev:  4.96 bytes:7602176
+stddev:  4.96 PSNR:34.20 bytes:7602176
 03ff35856faefb4882eaf4d86d95bea7 *./data/a-error-mpeg4-adv.avi
 8550acff0851ee915bd5800f1e20f37c *./data/out.yuv
 03ff35856faefb4882eaf4d86d95bea7 *./data/a-error-mpeg4-adv.avi
 8550acff0851ee915bd5800f1e20f37c *./data/out.yuv
-stddev:  9.66 bytes:7602176
+stddev:  9.66 PSNR:28.42 bytes:7602176
 671802a2c5078e69f7f422765ea87f2a *./data/a-mpeg1b.mpg
 d3d5876cef34b728602d5a22eee9249f *./data/out.yuv
 671802a2c5078e69f7f422765ea87f2a *./data/a-mpeg1b.mpg
 d3d5876cef34b728602d5a22eee9249f *./data/out.yuv
-stddev:  5.93 bytes:7145472
+stddev:  5.93 PSNR:32.66 bytes:7145472
 e9218a1db885fe0262e88f9df630307d *./data/a-mjpeg.avi
 a365b4da246ad68caf96b702b7f961a1 *./data/out.yuv
 e9218a1db885fe0262e88f9df630307d *./data/a-mjpeg.avi
 a365b4da246ad68caf96b702b7f961a1 *./data/out.yuv
-stddev:  4.76 bytes:7602176
+stddev:  4.76 PSNR:34.56 bytes:7602176
 defd90b44bced2772c6ca0d8eb75f668 *./data/a-ljpeg.avi
 dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
 defd90b44bced2772c6ca0d8eb75f668 *./data/a-ljpeg.avi
 dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
-stddev:  0.00 bytes:7602176
+stddev:  0.00 PSNR:99.99 bytes:7602176
 1b46671251277c14f3a24a034648c458 *./data/a-rv10.rm
 e1923bc2940a017858e354c3fb0e6244 *./data/out.yuv
 1b46671251277c14f3a24a034648c458 *./data/a-rv10.rm
 e1923bc2940a017858e354c3fb0e6244 *./data/out.yuv
-stddev: 13.18 bytes:7602176
+stddev: 13.18 PSNR:25.72 bytes:7602176
 9c4f5a4613a5595c90c6b99bf143b6a9 *./data/a-asv1.avi
 4251d7f496bbf362251b065e840a1b73 *./data/out.yuv
 9c4f5a4613a5595c90c6b99bf143b6a9 *./data/a-asv1.avi
 4251d7f496bbf362251b065e840a1b73 *./data/out.yuv
-stddev:  9.80 bytes:7602176
+stddev:  9.80 PSNR:28.29 bytes:7602176
 19652f2aac2d4d0379d37ce17e0bbea7 *./data/a-asv2.avi
 7d887519f7884e7c49c591831c11ac50 *./data/out.yuv
 19652f2aac2d4d0379d37ce17e0bbea7 *./data/a-asv2.avi
 7d887519f7884e7c49c591831c11ac50 *./data/out.yuv
-stddev:  9.71 bytes:7602176
+stddev:  9.71 PSNR:28.37 bytes:7602176
 bee27a404ab6a1b7ab1d3551eb4f1877 *./data/a-flv.flv
 86da6ee46d2df190b4a0d72523b14a25 *./data/out.yuv
 bee27a404ab6a1b7ab1d3551eb4f1877 *./data/a-flv.flv
 86da6ee46d2df190b4a0d72523b14a25 *./data/out.yuv
-stddev:  5.29 bytes:7602176
+stddev:  5.29 PSNR:33.64 bytes:7602176
 0db09835ebc3d22f166f30879f3ccc38 *./data/a-ffv1.avi
 dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
 0db09835ebc3d22f166f30879f3ccc38 *./data/a-ffv1.avi
 dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
-stddev:  0.00 bytes:7602176
+stddev:  0.00 PSNR:99.99 bytes:7602176
 21f8ff9f1daacd9133683bb4ea0f50a4 *./data/a-mp2.mp2
 624d9789f3ac193bbae4af3bd8cb02b7 *./data/out.wav
 d056da679e6d6682812fffb28a7f0db6 *./data/a-ac3.rm
 21f8ff9f1daacd9133683bb4ea0f50a4 *./data/a-mp2.mp2
 624d9789f3ac193bbae4af3bd8cb02b7 *./data/out.wav
 d056da679e6d6682812fffb28a7f0db6 *./data/a-ac3.rm
index 2104dd4..84ad90e 100644 (file)
 
 #include <stdio.h>
 #include <inttypes.h>
 
 #include <stdio.h>
 #include <inttypes.h>
+#include <assert.h>
 
 #define F 100
 #define SIZE 2048
 
 
 #define F 100
 #define SIZE 2048
 
+uint64_t exp16_table[20]={
+     65537,
+     65538,
+     65540,
+     65544,
+     65552,
+     65568,
+     65600,
+     65664,
+     65793,
+     66050,
+     66568,
+     67616,
+     69763,
+     74262,
+     84150,
+    108051,
+    178145,
+    484249,
+   3578144,
+ 195360063,
+};
+#if 1
+// 16.16 fixpoint exp()
+static unsigned int exp16(unsigned int a){
+    int i;
+    int out= 1<<16;
+
+    for(i=19;i>=0;i--){
+        if(a&(1<<i))
+            out= (out*exp16_table[i] + (1<<15))>>16;
+    }
+
+    return out;
+}
+// 16.16 fixpoint log()
+static uint64_t log16(uint64_t a){
+    int i;
+    int out=0;
+    
+    assert(a >= (1<<16));
+    a<<=16;
+    
+    for(i=19;i>=0;i--){
+        if(a<(exp16_table[i]<<16)) continue;
+        out |= 1<<i;
+        a = ((a<<16) + exp16_table[i]/2)/exp16_table[i];
+    }
+    return out;
+}
+
+#endif
 static uint64_t int_sqrt(uint64_t a)
 {
     uint64_t ret=0;
 static uint64_t int_sqrt(uint64_t a)
 {
     uint64_t ret=0;
@@ -45,6 +98,7 @@ int main(int argc,char* argv[]){
     uint64_t dev;
     FILE *f[2];
     uint8_t buf[2][SIZE];
     uint64_t dev;
     FILE *f[2];
     uint8_t buf[2][SIZE];
+    uint64_t psnr;
     
     if(argc!=3){
         printf("tiny_psnr <file1> <file2>\n");
     
     if(argc!=3){
         printf("tiny_psnr <file1> <file2>\n");
@@ -66,9 +120,16 @@ int main(int argc,char* argv[]){
     }
     
     dev= int_sqrt((sse*F*F)/i);
     }
     
     dev= int_sqrt((sse*F*F)/i);
+    if(sse)
+        psnr= (log16(256*256*255*255LL*i/sse)*284619LL*F + (1<<31)) / (1LL<<32);
+    else
+        psnr= 100*F-1; //floating point free infinity :)
     
     
-    //FIXME someone should write a integer fixpoint log() function for bitexact PSNR scores ...
-    printf("stddev:%3d.%02d bytes:%d\n", (int)(dev/F), (int)(dev%F), i);
-    
+    printf("stddev:%3d.%02d PSNR:%2d.%02d bytes:%d\n", 
+        (int)(dev/F), (int)(dev%F), 
+        (int)(psnr/F), (int)(psnr%F),
+        i);
     return 0;
 }
     return 0;
 }
+
+