00001 /* stats.c, coding statistics */ 00002 00003 /* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */ 00004 00005 /* 00006 * Disclaimer of Warranty 00007 * 00008 * These software programs are available to the user without any license fee or 00009 * royalty on an "as is" basis. The MPEG Software Simulation Group disclaims 00010 * any and all warranties, whether express, implied, or statuary, including any 00011 * implied warranties or merchantability or of fitness for a particular 00012 * purpose. In no event shall the copyright-holder be liable for any 00013 * incidental, punitive, or consequential damages of any kind whatsoever 00014 * arising from the use of these programs. 00015 * 00016 * This disclaimer of warranty extends to the user of these programs and user's 00017 * customers, employees, agents, transferees, successors, and assigns. 00018 * 00019 * The MPEG Software Simulation Group does not represent or warrant that the 00020 * programs furnished hereunder are free of infringement of any third-party 00021 * patents. 00022 * 00023 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware, 00024 * are subject to royalty fees to patent holders. Many of these patents are 00025 * general enough such that they are unavoidable regardless of implementation 00026 * design. 00027 * 00028 */ 00029 00030 #include <stdio.h> 00031 #include <math.h> 00032 #include "config.h" 00033 #include "global.h" 00034 00035 /* private prototypes */ 00036 static void calcSNR1 _ANSI_ARGS_((unsigned char *org, unsigned char *rec, 00037 int lx, int w, int h, double *pv, double *pe)); 00038 00039 00040 void calcSNR(org,rec) 00041 unsigned char *org[3]; 00042 unsigned char *rec[3]; 00043 { 00044 } 00045 00046 static void calcSNR1(org,rec,lx,w,h,pv,pe) 00047 unsigned char *org; 00048 unsigned char *rec; 00049 int lx,w,h; 00050 double *pv,*pe; 00051 { 00052 int i, j; 00053 double v1, s1, s2, e2; 00054 00055 s1 = s2 = e2 = 0.0; 00056 00057 for (j=0; j<h; j++) 00058 { 00059 for (i=0; i<w; i++) 00060 { 00061 v1 = org[i]; 00062 s1+= v1; 00063 s2+= v1*v1; 00064 v1-= rec[i]; 00065 e2+= v1*v1; 00066 } 00067 org += lx; 00068 rec += lx; 00069 } 00070 00071 s1 /= w*h; 00072 s2 /= w*h; 00073 e2 /= w*h; 00074 00075 /* prevent division by zero in calcSNR() */ 00076 if(e2==0.0) 00077 e2 = 0.00001; 00078 00079 *pv = s2 - s1*s1; /* variance */ 00080 *pe = e2; /* MSE */ 00081 } 00082 00083 void stats() 00084 { 00085 }
1.5.5