2 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 static uint64_t int_sqrt(uint64_t a)
33 uint64_t b= ret_sq + (1ULL<<(s*2)) + (ret<<s)*2;
42 int main(int argc,char* argv[]){
50 printf("tiny_psnr <file1> <file2>\n");
54 f[0]= fopen(argv[1], "r");
55 f[1]= fopen(argv[2], "r");
58 if( fread(buf[0], SIZE, 1, f[0]) != 1) break;
59 if( fread(buf[1], SIZE, 1, f[1]) != 1) break;
61 for(j=0; j<SIZE; i++,j++){
62 const int a= buf[0][j];
63 const int b= buf[1][j];
68 dev= int_sqrt((sse*F*F)/i);
70 //FIXME someone should write a integer fixpoint log() function for bitexact PSNR scores ...
71 printf("stddev:%3d.%02d bytes:%d\n", (int)(dev/F), (int)(dev%F), i);