1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Real Audio 1.0 (14.4K)
3cabdff1aSopenharmony_ci * Copyright (c) 2003 The FFmpeg project
4cabdff1aSopenharmony_ci *
5cabdff1aSopenharmony_ci * This file is part of FFmpeg.
6cabdff1aSopenharmony_ci *
7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
11cabdff1aSopenharmony_ci *
12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cabdff1aSopenharmony_ci * Lesser General Public License for more details.
16cabdff1aSopenharmony_ci *
17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20cabdff1aSopenharmony_ci */
21cabdff1aSopenharmony_ci
22cabdff1aSopenharmony_ci#ifndef AVCODEC_RA144_H
23cabdff1aSopenharmony_ci#define AVCODEC_RA144_H
24cabdff1aSopenharmony_ci
25cabdff1aSopenharmony_ci#include <stdint.h>
26cabdff1aSopenharmony_ci
27cabdff1aSopenharmony_ci#include "libavutil/mem_internal.h"
28cabdff1aSopenharmony_ci
29cabdff1aSopenharmony_ci#include "lpc.h"
30cabdff1aSopenharmony_ci#include "audio_frame_queue.h"
31cabdff1aSopenharmony_ci#include "audiodsp.h"
32cabdff1aSopenharmony_ci
33cabdff1aSopenharmony_ci#define NBLOCKS         4       ///< number of subblocks within a block
34cabdff1aSopenharmony_ci#define BLOCKSIZE       40      ///< subblock size in 16-bit words
35cabdff1aSopenharmony_ci#define BUFFERSIZE      146     ///< the size of the adaptive codebook
36cabdff1aSopenharmony_ci#define FIXED_CB_SIZE   128     ///< size of fixed codebooks
37cabdff1aSopenharmony_ci#define FRAME_SIZE      20      ///< size of encoded frame
38cabdff1aSopenharmony_ci#define LPC_ORDER       10      ///< order of LPC filter
39cabdff1aSopenharmony_ci
40cabdff1aSopenharmony_citypedef struct RA144Context {
41cabdff1aSopenharmony_ci    AVCodecContext *avctx;
42cabdff1aSopenharmony_ci    AudioDSPContext adsp;
43cabdff1aSopenharmony_ci    LPCContext lpc_ctx;
44cabdff1aSopenharmony_ci    AudioFrameQueue afq;
45cabdff1aSopenharmony_ci    int last_frame;
46cabdff1aSopenharmony_ci
47cabdff1aSopenharmony_ci    unsigned int     old_energy;        ///< previous frame energy
48cabdff1aSopenharmony_ci
49cabdff1aSopenharmony_ci    unsigned int     lpc_tables[2][10];
50cabdff1aSopenharmony_ci
51cabdff1aSopenharmony_ci    /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame
52cabdff1aSopenharmony_ci     *  and lpc_coef[1] of the previous one. */
53cabdff1aSopenharmony_ci    unsigned int    *lpc_coef[2];
54cabdff1aSopenharmony_ci
55cabdff1aSopenharmony_ci    unsigned int     lpc_refl_rms[2];
56cabdff1aSopenharmony_ci
57cabdff1aSopenharmony_ci    int16_t curr_block[NBLOCKS * BLOCKSIZE];
58cabdff1aSopenharmony_ci
59cabdff1aSopenharmony_ci    /** The current subblock padded by the last 10 values of the previous one. */
60cabdff1aSopenharmony_ci    int16_t curr_sblock[50];
61cabdff1aSopenharmony_ci
62cabdff1aSopenharmony_ci    /** Adaptive codebook, its size is two units bigger to avoid a
63cabdff1aSopenharmony_ci     *  buffer overflow. */
64cabdff1aSopenharmony_ci    int16_t adapt_cb[146+2];
65cabdff1aSopenharmony_ci
66cabdff1aSopenharmony_ci    DECLARE_ALIGNED(16, int16_t, buffer_a)[FFALIGN(BLOCKSIZE,16)];
67cabdff1aSopenharmony_ci} RA144Context;
68cabdff1aSopenharmony_ci
69cabdff1aSopenharmony_civoid ff_copy_and_dup(int16_t *target, const int16_t *source, int offset);
70cabdff1aSopenharmony_ciint ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx);
71cabdff1aSopenharmony_civoid ff_eval_coefs(int *coefs, const int *refl);
72cabdff1aSopenharmony_civoid ff_int_to_int16(int16_t *out, const int *inp);
73cabdff1aSopenharmony_ciint ff_t_sqrt(unsigned int x);
74cabdff1aSopenharmony_ciunsigned int ff_rms(const int *data);
75cabdff1aSopenharmony_ciint ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold,
76cabdff1aSopenharmony_ci              int energy);
77cabdff1aSopenharmony_ciunsigned int ff_rescale_rms(unsigned int rms, unsigned int energy);
78cabdff1aSopenharmony_ciint ff_irms(AudioDSPContext *adsp, const int16_t *data/*align 16*/);
79cabdff1aSopenharmony_civoid ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs,
80cabdff1aSopenharmony_ci                           int cba_idx, int cb1_idx, int cb2_idx,
81cabdff1aSopenharmony_ci                           int gval, int gain);
82cabdff1aSopenharmony_ci
83cabdff1aSopenharmony_ciextern const int16_t ff_gain_val_tab[256][3];
84cabdff1aSopenharmony_ciextern const uint8_t ff_gain_exp_tab[256];
85cabdff1aSopenharmony_ciextern const int8_t ff_cb1_vects[128][40];
86cabdff1aSopenharmony_ciextern const int8_t ff_cb2_vects[128][40];
87cabdff1aSopenharmony_ciextern const uint16_t ff_cb1_base[128];
88cabdff1aSopenharmony_ciextern const uint16_t ff_cb2_base[128];
89cabdff1aSopenharmony_ciextern const int16_t ff_energy_tab[32];
90cabdff1aSopenharmony_ciextern const int16_t * const ff_lpc_refl_cb[10];
91cabdff1aSopenharmony_ci
92cabdff1aSopenharmony_ci#endif /* AVCODEC_RA144_H */
93