* added simple test main - see comments about how to
compile - should be probably made as a regression test Originally committed as revision 565 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
		@@ -928,6 +928,7 @@ static void clear_blocks_mmx(DCTELEM *blocks)
 | 
			
		||||
static void just_return() { return; }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef TESTCPU_MAIN
 | 
			
		||||
void dsputil_init_mmx(void)
 | 
			
		||||
{
 | 
			
		||||
    mm_flags = mm_support();
 | 
			
		||||
@@ -1080,3 +1081,44 @@ void dsputil_set_bit_exact_mmx(void)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#else // TESTCPU_MAIN
 | 
			
		||||
/*
 | 
			
		||||
 * for testing speed of various routine - should be probably extended
 | 
			
		||||
 * for a general purpose regression test later
 | 
			
		||||
 *
 | 
			
		||||
 * for now use it this way:
 | 
			
		||||
 *
 | 
			
		||||
 * gcc -O4 -fomit-frame-pointer -DHAVE_AV_CONFIG_H -DTESTCPU_MAIN  -I../.. -o test dsputil_mmx.c
 | 
			
		||||
 *
 | 
			
		||||
 * in libavcodec/i386 directory - then run ./test
 | 
			
		||||
 */
 | 
			
		||||
static inline long long rdtsc()
 | 
			
		||||
{
 | 
			
		||||
    long long l;
 | 
			
		||||
    asm volatile(   "rdtsc\n\t"
 | 
			
		||||
		    : "=A" (l)
 | 
			
		||||
		);
 | 
			
		||||
    return l;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(int argc, char* argv[])
 | 
			
		||||
{
 | 
			
		||||
    volatile int v;
 | 
			
		||||
    int i;
 | 
			
		||||
    const int linesize = 720;
 | 
			
		||||
    char bu[32768];
 | 
			
		||||
    uint64_t te, ts = rdtsc();
 | 
			
		||||
    char* im = bu;
 | 
			
		||||
    op_pixels_func fc = put_pixels_y2_mmx2;
 | 
			
		||||
    for(i=0; i<1000000; i++){
 | 
			
		||||
	fc(im, im + 1000, linesize, 16);
 | 
			
		||||
	im += 16; //
 | 
			
		||||
	if (im > bu + 10000)
 | 
			
		||||
            im = bu;
 | 
			
		||||
    }
 | 
			
		||||
    te = rdtsc();
 | 
			
		||||
    printf("CPU Ticks: %7d\n", (int)(te - ts));
 | 
			
		||||
    fflush(stdout);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user