1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <time.h>
#include <stdio.h>
#include "codec2.h"
int main() {
struct timespec tstart={0,0}, tend={0,0};
short input[976692];
FILE * recoded = fopen("count-recoded.raw", "w+");
FILE * f = fopen("count.raw", "r");
void * codec2 = codec2_create(CODEC2_MODE_700C);
int nsam = codec2_samples_per_frame(codec2);
int nbit = codec2_bits_per_frame(codec2);
int off = 0;
unsigned char bits[128];
fread(input, 976692, 1, f);
fclose(f);
clock_gettime(CLOCK_MONOTONIC, &tstart);
while (off < 976692 / 2) {
codec2_encode(codec2, bits, input + off);
codec2_decode(codec2, input + off, bits);
off += 320;
}
clock_gettime(CLOCK_MONOTONIC, &tend);
printf("%lf\n", ((double)tend.tv_sec + 1.0e-9*tend.tv_nsec) - ((double)tstart.tv_sec + 1.0e-9*tstart.tv_nsec));
fwrite(input, 976692, 1, recoded);
codec2_destroy(codec2);
}
|