mask mousewheel segv bug, mask opengl sw fallback read to ram, fix tiff config withou...
[goodguy/cinelerra.git] / cinelerra-5.1 / libzmpeg3 / video / tst.c
1 #include <stdio.h>
2 #include <stdint.h>
3 #include <stdlib.h>
4 //#define MMX_TRACE
5 #include "mmx.h"
6
7 static inline int clip2(int v, int mn, int mx) {
8   if( v > mx ) return mx;
9   if( v < mn ) return mn;
10   return v;
11 }
12
13 static inline uint8_t clip(int32_t v) {
14   return ((uint8_t)v) == v ? v : clip2(v,0,255);
15 }
16
17 #define m_(v) (*(mmx_t*)(((long long *)(v))))
18
19 int main(int ac, char **av)
20 {
21    int i, j, k, n;
22    unsigned char dat0[8] = { 0x01, 0xf2, 0x03, 0x04, 0x05, 0x06, 0xf7, 0x08 };
23    long long *datp = (long long *)&dat0;
24    int16_t dat1[8] = { 0x10, 0x20, -0x130, -0x140, 0x50, -0x160, -0x170, 0x80 };
25    volatile uint8_t *rfp = dat0;
26    volatile int16_t *bp  = dat1;
27    unsigned char ans1[8], ans2[8];
28
29    n = 0;
30    for( i=-32768; i<32768; ++i ) {
31      j = 0;
32      while( j < 256 ) {
33         for( k=0; k<8; ++k ) {
34           dat0[k] = i;
35           dat1[k] = j++;
36         }
37        movq_m2r(m_(&rfp[0]),mm1);  /* rfp[0..7] */
38        pxor_r2r(mm3,mm3);
39        pxor_r2r(mm4,mm4);
40        movq_m2r(m_(&bp[0]),mm5);   /* bp[0..3] */
41        movq_r2r(mm1,mm2);
42        movq_m2r(m_(&bp[4]),mm6);   /* bp[4..7] */
43        punpcklbw_r2r(mm3,mm1);     /* rfp[0,2,4,6] */
44        punpckhbw_r2r(mm3,mm2);     /* rfp[1,3,5,7] */
45        paddsw_r2r(mm5,mm1);        /* bp[0..3] */
46        paddsw_r2r(mm6,mm2);        /* bp[4..7] */
47        pcmpgtw_r2r(mm1,mm3);
48        pcmpgtw_r2r(mm2,mm4);
49        pandn_r2r(mm1,mm3);
50        pandn_r2r(mm2,mm4);
51        packuswb_r2r(mm4,mm3);
52        movq_r2m(mm3,m_(&ans1[0]));
53        emms();
54
55        ans2[0] = clip(bp[0] + rfp[0]);
56        ans2[1] = clip(bp[1] + rfp[1]);
57        ans2[2] = clip(bp[2] + rfp[2]);
58        ans2[3] = clip(bp[3] + rfp[3]);
59        ans2[4] = clip(bp[4] + rfp[4]);
60        ans2[5] = clip(bp[5] + rfp[5]);
61        ans2[6] = clip(bp[6] + rfp[6]);
62        ans2[7] = clip(bp[7] + rfp[7]);
63
64        if( *(uint64_t *)&ans1[0] != *(uint64_t *)&ans2[0] )
65        {
66          printf(" i=%5d %02x %02x %02x %02x  %02x %02x %02x %02x\n", i,
67            ans1[0], ans1[1], ans1[2], ans1[3], ans1[4], ans1[5], ans1[6], ans1[7]);
68          printf(" j=%5d %02x %02x %02x %02x  %02x %02x %02x %02x\n", j,
69            ans2[0], ans2[1], ans2[2], ans2[3], ans2[4], ans2[5], ans2[6], ans2[7]);
70        //  exit(0);
71        }
72        n += 8;
73      }
74    }
75
76    printf("n=%d\n",n);
77    return 0;
78 }