20 lines
871 B
C
20 lines
871 B
C
#define MINIMP3_IMPLEMENTATION
|
|
#include "minimp3_ex.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
static double now(){ struct timespec ts; clock_gettime(CLOCK_MONOTONIC,&ts); return ts.tv_sec+ts.tv_nsec*1e-9; }
|
|
int main(int argc,char**argv){
|
|
if(argc<2){fprintf(stderr,"usage: %s file.mp3\n",argv[0]);return 1;}
|
|
mp3dec_t dec; mp3dec_init(&dec);
|
|
mp3dec_file_info_t info; memset(&info,0,sizeof info);
|
|
double t0=now(); int r=mp3dec_load(&dec,argv[1],&info,NULL,NULL); double t1=now();
|
|
if(r){fprintf(stderr,"decode fail %d\n",r);return 1;}
|
|
long long frames=info.samples/info.channels;
|
|
printf("rate=%d ch=%d total_pcm_frames=%lld\n",info.hz,info.channels,frames);
|
|
printf("wall=%.3f s throughput=%.1f xRT (%.1f frames/s)\n",(t1-t0),
|
|
(double)frames/info.hz/(t1-t0),(double)frames/(t1-t0));
|
|
free(info.buffer); return 0;
|
|
}
|