--- trunk/xvidcore/examples/xvid_stat.c 2002/04/29 07:23:16 151 +++ trunk/xvidcore/examples/xvid_stat.c 2002/09/12 19:18:12 479 @@ -1,22 +1,36 @@ -/************************************************************************** +/***************************************************************************** * - * XVID MPEG-4 VIDEO CODEC - Example for encoding and decoding + * XVID MPEG-4 VIDEO CODEC + * - Console based test application - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Copyright(C) 2002 Christoph Lampert * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is an implementation of a part of one or more MPEG-4 + * Video tools as specified in ISO/IEC 14496-2 standard. Those intending + * to use this software module in hardware or software products are + * advised that its use may infringe existing patents or copyrights, and + * any such use would be at such party's own risk. The original + * developer of this software module and his/her company, and subsequent + * editors and their companies, will have no liability for use of this + * software or modifications or derivatives thereof. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - *************************************************************************/ + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: xvid_stat.c,v 1.5 2002-09-12 19:18:12 chl Exp $ + * + ****************************************************************************/ /************************************************************************ * @@ -65,7 +79,7 @@ #include // needed for log10 #include // only needed for gettimeofday -#include "xvid.h" /* comes with XviD */ +#include "../src/xvid.h" /* comes with XviD */ int motion_presets[7] = { 0, // Q 0 @@ -107,7 +121,6 @@ #define MAX(A,B) ( ((A)>(B)) ? (A) : (B) ) #define SMALL_EPS 1e-10 - /* these are global variables. Not very elegant, but easy, and this is an easy program */ int XDIM=0; @@ -142,7 +155,6 @@ } - double absdistq(int x,int y, unsigned char* buf1, int stride1, unsigned char* buf2, int stride2) /* returns the sum of squared distances (SSD) between two images of dimensions x times y */ { @@ -262,14 +274,24 @@ #define FRAMERATE_INCR 1001 -int enc_init() +int enc_init(int use_assembler) { /* initialize encoder for first use, pass all needed parameters to the codec */ int xerr; XVID_INIT_PARAM xinit; XVID_ENC_PARAM xparam; - xinit.cpu_flags = XVID_CPU_FORCE; + if(use_assembler) + +#ifdef ARCH_IA64 + xinit.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64; +#else + xinit.cpu_flags = 0; +#endif + + else + xinit.cpu_flags = XVID_CPU_FORCE; + xvid_init(NULL, 0, &xinit, NULL); xparam.width = XDIM; @@ -285,8 +307,8 @@ xparam.fbase = (int)(FRAMERATE_INCR * ARG_FRAMERATE); } xparam.rc_reaction_delay_factor = 16; - xparam.rc_averaging_period = 100; - xparam.rc_buffer = 10; + xparam.rc_averaging_period = 100; + xparam.rc_buffer = 10; xparam.rc_bitrate = ARG_BITRATE*1000; xparam.min_quantizer = 1; xparam.max_quantizer = 31; @@ -350,14 +372,24 @@ /* Routines for decoding: init encoder, frame step, release encoder */ /*********************************************************************/ -int dec_init() /* init decoder before first run */ +int dec_init(int use_assembler) /* init decoder before first run */ { int xerr; XVID_INIT_PARAM xinit; XVID_DEC_PARAM xparam; - xinit.cpu_flags = 0; + if(use_assembler) + +#ifdef ARCH_IA64 + xinit.cpu_flags = XVID_CPU_FORCE | XVID_CPU_IA64; +#else + xinit.cpu_flags = 0; +#endif + + else + xinit.cpu_flags = XVID_CPU_FORCE; + xvid_init(NULL, 0, &xinit, NULL); xparam.width = XDIM; xparam.height = YDIM; @@ -413,7 +445,7 @@ int m4v_size; int frame_type[ABS_MAXFRAMENR]; - int Iframes=0, Pframes=0, Bframes=0; + int Iframes=0, Pframes=0, use_assembler=0; double framepsnr[ABS_MAXFRAMENR]; double Ipsnr=0.,Imaxpsnr=0.,Iminpsnr=999.,Ivarpsnr=0.; @@ -429,6 +461,8 @@ { pgmflag = 1; + if (argc==2 && !strcmp(argv[1],"-asm")) + use_assembler = 1; if (argc>=3) { XDIM = atoi(argv[1]); YDIM = atoi(argv[2]); @@ -505,14 +539,14 @@ /*********************************************************************/ - status = enc_init(); + status = enc_init(use_assembler); if (status) { printf("Encore INIT problem, return value %d\n", status); goto release_all; } - status = dec_init(); + status = dec_init(use_assembler); if (status) { printf("Decore INIT problem, return value %d\n", status); @@ -624,10 +658,7 @@ Iframes++; Ipsnr += framepsnr[i]; break; - case 2: default: - Bframes++; - Bpsnr += framepsnr[i]; break; } } @@ -636,9 +667,6 @@ Ppsnr /= Pframes; if (Iframes) Ipsnr /= Iframes; - if (Bframes) - Bpsnr /= Bframes; - for (i=0;i Bmaxpsnr) - Bmaxpsnr = framepsnr[i]; - if (framepsnr[i] < Pminpsnr) - Bminpsnr = framepsnr[i]; - Bvarpsnr += (framepsnr[i] - Bpsnr)*(framepsnr[i] - Bpsnr) /Bframes; + default: break; } } @@ -677,8 +699,6 @@ printf("enc: %6.1f fps, dec: %6.1f fps \n",1/totalenctime, 1/totaldectime); printf("PSNR P(%d): %5.2f ( %5.2f , %5.2f ; %5.4f ) ",Pframes,Ppsnr,Pminpsnr,Pmaxpsnr,sqrt(Pvarpsnr/filenr)); printf("I(%d): %5.2f ( %5.2f , %5.2f ; %5.4f ) ",Iframes,Ipsnr,Iminpsnr,Imaxpsnr,sqrt(Ivarpsnr/filenr)); - if (Bframes) - printf("B(%d): %5.2f ( %5.2f , %5.2f ; %5.4f ) ",Bframes,Bpsnr,Bminpsnr,Bmaxpsnr,sqrt(Bvarpsnr/filenr)); printf("\n"); /*********************************************************************/