PageRenderTime 42ms CodeModel.GetById 17ms app.highlight 19ms RepoModel.GetById 2ms app.codeStats 0ms

/xbmc/visualizations/Goom/goom2k4-0/src/filter_test/px_py_calc.c

http://github.com/xbmc/xbmc
C | 94 lines | 56 code | 21 blank | 17 comment | 5 complexity | 714b611cb4f91d559d170df51f75cb17 MD5 | raw file
 1#include "mmx.h"
 2
 3int testD [] = {0x1200, 0x2011, 0, 0x12, 0x5331, 0x8000};
 4int testS [] = {0x1205, 0x11, 0x4210, 0x412, 0x121, 0x1211};
 5
 6int ratios [] = {0x8000, 0x4000, 0x1234, 0x6141, 0xffff, 0};
 7
 8int main () {
 9	int nbERROR = 0;
10	int i,j;
11	volatile mmx_t ratiox;
12
13	volatile mmx_t sortie;
14
15	/* creation des variables de test */
16	volatile int buffratio = 0x8000;
17	volatile int loop = 0;
18	volatile int *buffS;
19	volatile int *buffD;
20	buffS = malloc (256);
21	buffD = malloc (256);
22
23	buffS = buffS + (unsigned)buffS % 64;
24	buffD = buffD + (unsigned)buffD % 64;
25
26	for (j=0;j<6;j++)
27	for (i=0;i<3;i++) {
28		
29		buffratio = ratios[j];
30
31		buffS[0] = testS[i<<1];
32		buffS[1] = testS[(i<<1)+1];
33		
34		buffD[0] = testD[i*2];
35		buffD[1] = testD[i*2+1];
36
37		/* code */
38		
39		ratiox.d[0] = buffratio;
40		ratiox.d[1] = buffratio;
41		movq_m2r (ratiox, mm6);
42		pslld_i2r (16,mm6);
43		
44		/*     |0hhhhhhh|llllvvvv|
45				 x |00000000|bbbbbbbb|
46				    =================
47				   |.bl.high|..bl.low|
48				 + |..bh.low|00000000|
49				    =================
50				          result1
51		*/
52	
53		/*
54		 * pre : mm6 = [buffratio<<16|buffratio<<16]
55		 */
56
57		movq_m2r (buffS[loop],mm0);               /* mm0 = S */
58		movq_m2r (buffD[loop],mm1);               /* mm1 = D */
59		psubd_r2r (mm0,mm1);           /* mm1 = D - S */
60		movq_r2r (mm1, mm2);           /* mm2 = D - S */
61		
62		pslld_i2r (16,mm1);
63		mmx_r2r (pmulhuw, mm6, mm1);    /* mm1 = ?? */
64		pmullw_r2r (mm6, mm2);
65		
66		paddd_r2r (mm2, mm1);     /* mm1 = (D - S) * buffratio >> 16 */
67		pslld_i2r (16,mm0);
68		
69		paddd_r2r (mm1, mm0);     /* mm0 = S + mm1 */
70		psrld_i2r (16, mm0);
71		movq_r2m (mm0, sortie);
72		
73		/*
74		 * post : mm0 = S + ((D-S)*buffratio)>>16
75		 * modified = mm0,mm1,mm2
76		 */
77
78		if (
79			(buffS[0] + (((buffD[0]-buffS[0]) * buffratio)>>16) != sortie.d[0])
80			| (buffS[1] + (((buffD[1]-buffS[1]) * buffratio)>>16) != sortie.d[1]))
81			{
82				nbERROR++;
83				printf ("\ns : (0x%08x,0x%08x)\n", buffS[0], buffS[1]);
84				printf ("d : (0x%08x,0x%08x)\n", buffD[0], buffD[1]);		
85				printf ("ratio : (0x%08x,0x%08x)\n", buffratio, buffratio);
86				
87				printf ("en mmx : (0x%08x,0x%08x)\n", sortie.d[0], sortie.d[1]);
88				printf ("en c : (0x%08x,0x%08x)\n",
89								buffS[0] + (((buffD[0]-buffS[0]) * buffratio)>>16),
90								buffS[1] + (((buffD[1]-buffS[1]) * buffratio)>>16));
91			}
92	}
93	printf ("%d errors\n",nbERROR);
94}