aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/ra144.h
blob: 8b350c5feab39de3d8dbbace2b1e576a5569fdfc (plain) (blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Real Audio 1.0 (14.4K)
 * Copyright (c) 2003 the ffmpeg project
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef AVCODEC_RA144_H
#define AVCODEC_RA144_H

#include <stdint.h>

#define NBLOCKS         4       ///< number of subblocks within a block
#define BLOCKSIZE       40      ///< subblock size in 16-bit words
#define BUFFERSIZE      146     ///< the size of the adaptive codebook

typedef struct {
    AVCodecContext *avctx;

    unsigned int     old_energy;        ///< previous frame energy

    unsigned int     lpc_tables[2][10];

    /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame
     *  and lpc_coef[1] of the previous one. */
    unsigned int    *lpc_coef[2];

    unsigned int     lpc_refl_rms[2];

    /** The current subblock padded by the last 10 values of the previous one. */
    int16_t curr_sblock[50];

    /** Adaptive codebook, its size is two units bigger to avoid a
     *  buffer overflow. */
    uint16_t adapt_cb[146+2];
} RA144Context;

void add_wav(int16_t *dest, int n, int skip_first, int *m, const int16_t *s1,
             const int8_t *s2, const int8_t *s3);
void copy_and_dup(int16_t *target, const int16_t *source, int offset);
int eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx);
void eval_coefs(int *coefs, const int *refl);
void int_to_int16(int16_t *out, const int *inp);
int t_sqrt(unsigned int x);
unsigned int rms(const int *data);
int interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy);
unsigned int rescale_rms(unsigned int rms, unsigned int energy);
int irms(const int16_t *data);

extern const int16_t gain_val_tab[256][3];
extern const uint8_t gain_exp_tab[256];
extern const int8_t cb1_vects[128][40];
extern const int8_t cb2_vects[128][40];
extern const uint16_t cb1_base[128];
extern const uint16_t cb2_base[128];
extern const int16_t energy_tab[32];
extern const int16_t * const lpc_refl_cb[10];

#endif /* AVCODEC_RA144_H */