summaryrefslogtreecommitdiff
path: root/tools/audio/sampleconv/src/codec/vadpcm.h
blob: f6a080bf844c23dba8eb37c71f9a29a407c65047 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
 * SPDX-FileCopyrightText: Copyright (C) 2024 ZeldaRET
 * SPDX-License-Identifier: CC0-1.0
 */
#ifndef CODEC_VADPCM_H
#define CODEC_VADPCM_H

#include <stdbool.h>
#include <stdint.h>

#define VADPCM_BOOK_SIZE(order, npredictors)       (8 * (order) * (npredictors))
#define VADPCM_BOOK_SIZE_BYTES(order, npredictors) (sizeof(int16_t) * VADPCM_BOOK_SIZE(order, npredictors))

typedef struct {
    int16_t order;
    int16_t npredictors;
} ALADPCMbookhead;

typedef int16_t ALADPCMbookstate[];

typedef struct {
    uint32_t start;
    uint32_t end;
    uint32_t count;
    int16_t state[16];
} ALADPCMloop;

typedef struct {
    unsigned int order;
    unsigned int bits;
    unsigned int refine_iters;
    double thresh;
    unsigned int frame_size;
} table_design_spec;

int
tabledesign_run(int16_t *order_out, int16_t *npredictors_out, int16_t **book_data_out, void *sample_data,
                size_t num_samples, const table_design_spec *design);

struct container_data;
struct codec_spec;
struct enc_dec_opts;

int
vadpcm_enc(struct container_data *ctnr, const struct codec_spec *codec, const struct enc_dec_opts *opts);

int
vadpcm_dec(struct container_data *ctnr, const struct codec_spec *codec, const struct enc_dec_opts *opts);

#endif