check_long_fs.c 1.44 KB
Newer Older
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
1 2 3 4 5
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "check_aec.h"

6
#define BUF_SIZE (64 * 4)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
7 8 9

int check_long_fs(struct test_state *state)
{
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
10 11
    int size = state->bytes_per_sample;
    int bs = state->strm->block_size;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
12

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
13
    for (int i = 0; i < bs / 2; i++) {
14 15
        state->out(state->ubuf + size * i, state->xmin, size);
        state->out(state->ubuf + bs * size / 2 + size * i, 65000, size);
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
16 17 18 19
    }

    printf("Checking long fs ... ");

20 21 22
    const int status = state->codec(state);
    if (status == 0)
      printf ("%s\n", CHECK_PASS);
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
23

24
    return status;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
25 26
}

27
int main(void)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
28 29
{
    struct test_state state;
30
    state.dump = 0;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
31 32 33 34 35 36 37 38
    state.buf_len = state.ibuf_len = BUF_SIZE;
    state.cbuf_len = 2 * BUF_SIZE;

    state.ubuf = (unsigned char *)malloc(state.buf_len);
    state.cbuf = (unsigned char *)malloc(state.cbuf_len);
    state.obuf = (unsigned char *)malloc(state.buf_len);

    if (!state.ubuf || !state.cbuf || !state.obuf) {
39 40 41 42 43 44
        fprintf(stderr, "Not enough memory.\n");

        free(state.ubuf);
        free(state.cbuf);
        free(state.obuf);

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
45 46 47
        return 99;
    }

48
    struct aec_stream strm;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
49 50
    strm.flags = AEC_DATA_PREPROCESS;
    state.strm = &strm;
51
    strm.bits_per_sample = 16;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
52
    strm.block_size = 64;
53
    strm.rsi = 1;
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
54 55 56
    state.codec = encode_decode_large;
    update_state(&state);

57
    const int status = check_long_fs(&state);
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
58 59 60 61 62 63 64

    free(state.ubuf);
    free(state.cbuf);
    free(state.obuf);

    return status;
}