diff options
author | michael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-12-15 22:32:14 +0000 |
---|---|---|
committer | michael <michael@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-12-15 22:32:14 +0000 |
commit | a41588092790928ed243477999ef7b7ef7a8a4cf (patch) | |
tree | a257c782344d0b6bacd19e3162d0784df2215ce4 /liba52 | |
parent | 7a7eaccc0b45debfa99ecc9226b3c1bc9f438bec (diff) | |
download | mpv-a41588092790928ed243477999ef7b7ef7a8a4cf.tar.bz2 mpv-a41588092790928ed243477999ef7b7ef7a8a4cf.tar.xz |
benchmarking code (#define TIMING)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3508 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'liba52')
-rw-r--r-- | liba52/test.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/liba52/test.c b/liba52/test.c index c23ed4f64c..fcfc5cf207 100644 --- a/liba52/test.c +++ b/liba52/test.c @@ -4,6 +4,8 @@ // writes it to stdout. resulting stream playbackable with sox: // play -c 2 -r 48000 out.sw +//#define TIMING //needs Pentium or newer + #include <stdio.h> #include <stdlib.h> #include <inttypes.h> @@ -17,6 +19,25 @@ static int buf_size=0; static int16_t out_buf[6*256*6]; +#ifdef TIMING +static inline long long rdtsc() +{ + long long l; + asm volatile( "rdtsc\n\t" + : "=A" (l) + ); +// printf("%d\n", int(l/1000)); + return l; +} + +#define STARTTIMING t=rdtsc(); +#define ENDTIMING sum+=rdtsc()-t; t=rdtsc(); +#else +#define STARTTIMING ; +#define ENDTIMING ; +#endif + + static inline int16_t convert (int32_t i) { if (i > 0x43c07fff) @@ -126,6 +147,9 @@ int main(){ int accel=0; int sample_rate=0; int bit_rate=0; +#ifdef TIMING +long long t, sum=0; +#endif samples = a52_init (accel); if (samples == NULL) { @@ -144,7 +168,9 @@ while(1){ if(c<0) goto eof; buf[buf_size++]=c; } +STARTTIMING length = a52_syncinfo (buf, &flags, &sample_rate, &bit_rate); +ENDTIMING if(!length){ // bad file => resync memcpy(buf,buf+1,6); @@ -161,8 +187,10 @@ while(1){ // decode: flags=A52_STEREO; // A52_DOLBY // A52_2F2R // A52_3F2R | A52_LFE flags |= A52_ADJUST_LEVEL; +STARTTIMING if (a52_frame (&state, buf, &flags, &level, bias)) { fprintf(stderr,"error at decoding\n"); continue; } +ENDTIMING // a52_dynrng (&state, NULL, NULL); // disable dynamic range compensation @@ -170,8 +198,10 @@ while(1){ for (i = 0; i < 6; i++) { int32_t * f = (int32_t *) samples; int i; +STARTTIMING if (a52_block (&state, samples)) { fprintf(stderr,"error at sampling\n"); break; } +ENDTIMING // resample to STEREO/DOLBY: for (i = 0; i < 256; i++) { s16[2*i] = convert (f[i]); @@ -185,4 +215,8 @@ while(1){ eof: +#ifdef TIMING +fprintf(stderr, "%4.4fm cycles\n",sum/1000000.0); +#endif + } |