From 0c90161f0fb905a79bc7c876f57c83f1e776419d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 1 Feb 2005 01:21:32 +0000 Subject: signed 16bit support Originally committed as revision 3913 to svn://svn.ffmpeg.org/ffmpeg/trunk --- tests/tiny_psnr.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'tests/tiny_psnr.c') diff --git a/tests/tiny_psnr.c b/tests/tiny_psnr.c index 996f040496..2f35670979 100644 --- a/tests/tiny_psnr.c +++ b/tests/tiny_psnr.c @@ -24,7 +24,7 @@ #define F 100 #define SIZE 2048 -uint64_t exp16_table[20]={ +uint64_t exp16_table[21]={ 65537, 65538, 65540, @@ -45,6 +45,7 @@ uint64_t exp16_table[20]={ 484249, 3578144, 195360063, + 582360139072LL, }; #if 1 // 16.16 fixpoint exp() @@ -60,14 +61,15 @@ static unsigned int exp16(unsigned int a){ return out; } // 16.16 fixpoint log() -static uint64_t log16(uint64_t a){ +static int64_t log16(uint64_t a){ int i; int out=0; - - assert(a >= (1<<16)); + + if(a < 1<<16) + return -log16((1LL<<32) / a); a<<=16; - for(i=19;i>=0;i--){ + for(i=20;i>=0;i--){ int64_t b= exp16_table[i]; if(a<(b<<16)) continue; out |= 1< \n"); return -1; } @@ -114,16 +118,20 @@ int main(int argc,char* argv[]){ if( fread(buf[1], SIZE, 1, f[1]) != 1) break; for(j=0; j