File: tvq_mbest.c

package info (click to toggle)
codec2 1.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 121,056 kB
  • sloc: ansic: 414,118; sh: 2,612; objc: 2,574; python: 2,105; cpp: 2,091; asm: 683; makefile: 598
file content (31 lines) | stat: -rw-r--r-- 918 bytes parent folder | download
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
/*
  tvq_mbest.c
  David Rowe Dec 2019

  Generate some test vectors to exercise misc/vq_mbest.c
*/

#include <assert.h>
#include <stdlib.h>
#include <stdio.h>

void write_float_file(char fn[], float *values, int n) {
    FILE *f=fopen(fn,"wb");
    assert(f != NULL);
    assert(fwrite(values, sizeof(float), n, f) == n);
    fclose(f);
}

int main(void) {
    /* we're only interested in searching the inner 2 values, outer elements should be
       ignored */
    float target[] = {0.0,1.0,1.0,0.0};
    write_float_file("target.f32", target, 4);
    float vq1[] = {1.0,0.9,0.9,1.0,  /* this will be a better match on first stage */
		   2.0,0.8,0.8,2.0}; /* but after second stage should choose this  */
    write_float_file("vq1.f32", vq1, 8);
    float vq2[] = {10.0,0.3,0.3,10.0,
		   20.0,0.2,0.2,20.0}; /* 0.8+0.2 == 1.0 so best 2nd stage entry     */
    write_float_file("vq2.f32", vq2, 8);
    return 0;
}