FFmpeg
ra144.h
Go to the documentation of this file.
1 /*
2  * Real Audio 1.0 (14.4K)
3  * Copyright (c) 2003 The FFmpeg project
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVCODEC_RA144_H
23 #define AVCODEC_RA144_H
24 
25 #include <stdint.h>
26 
27 #include "libavutil/mem_internal.h"
28 
29 #include "lpc.h"
30 #include "audio_frame_queue.h"
31 #include "audiodsp.h"
32 
33 #define NBLOCKS 4 ///< number of subblocks within a block
34 #define BLOCKSIZE 40 ///< subblock size in 16-bit words
35 #define BUFFERSIZE 146 ///< the size of the adaptive codebook
36 #define FIXED_CB_SIZE 128 ///< size of fixed codebooks
37 #define FRAME_SIZE 20 ///< size of encoded frame
38 #define LPC_ORDER 10 ///< order of LPC filter
39 
40 typedef struct RA144Context {
46 
47  unsigned int old_energy; ///< previous frame energy
48 
49  unsigned int lpc_tables[2][10];
50 
51  /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame
52  * and lpc_coef[1] of the previous one. */
53  unsigned int *lpc_coef[2];
54 
55  unsigned int lpc_refl_rms[2];
56 
58 
59  /** The current subblock padded by the last 10 values of the previous one. */
60  int16_t curr_sblock[50];
61 
62  /** Adaptive codebook, its size is two units bigger to avoid a
63  * buffer overflow. */
64  int16_t adapt_cb[146+2];
65 
67 } RA144Context;
68 
69 void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset);
70 int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx);
71 void ff_eval_coefs(int *coefs, const int *refl);
72 void ff_int_to_int16(int16_t *out, const int *inp);
73 int ff_t_sqrt(unsigned int x);
74 unsigned int ff_rms(const int *data);
75 int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold,
76  int energy);
77 unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy);
78 int ff_irms(AudioDSPContext *adsp, const int16_t *data/*align 16*/);
79 void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs,
80  int cba_idx, int cb1_idx, int cb2_idx,
81  int gval, int gain);
82 
83 extern const int16_t ff_gain_val_tab[256][3];
84 extern const uint8_t ff_gain_exp_tab[256];
85 extern const int8_t ff_cb1_vects[128][40];
86 extern const int8_t ff_cb2_vects[128][40];
87 extern const uint16_t ff_cb1_base[128];
88 extern const uint16_t ff_cb2_base[128];
89 extern const int16_t ff_energy_tab[32];
90 extern const int16_t * const ff_lpc_refl_cb[10];
91 
92 #endif /* AVCODEC_RA144_H */
NBLOCKS
#define NBLOCKS
number of subblocks within a block
Definition: ra144.h:33
RA144Context::avctx
AVCodecContext * avctx
Definition: ra144.h:41
mem_internal.h
out
FILE * out
Definition: movenc.c:54
ff_gain_exp_tab
const uint8_t ff_gain_exp_tab[256]
Definition: ra144.c:95
data
const char data[16]
Definition: mxf.c:146
ff_eval_coefs
void ff_eval_coefs(int *coefs, const int *refl)
Evaluate the LPC filter coefficients from the reflection coefficients.
Definition: ra144.c:1593
lpc.h
ff_rescale_rms
unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy)
Definition: ra144.c:1678
LPCContext
Definition: lpc.h:53
RA144Context::buffer_a
int16_t buffer_a[FFALIGN(BLOCKSIZE, 16)]
Definition: ra144.h:66
audio_frame_queue.h
RA144Context::lpc_coef
unsigned int * lpc_coef[2]
LPC coefficients: lpc_coef[0] is the coefficients of the current frame and lpc_coef[1] of the previou...
Definition: ra144.h:53
ff_lpc_refl_cb
const int16_t *const ff_lpc_refl_cb[10]
Definition: ra144.c:1502
AudioFrameQueue
Definition: audio_frame_queue.h:32
RA144Context::curr_block
int16_t curr_block[NBLOCKS *BLOCKSIZE]
Definition: ra144.h:57
ff_rms
unsigned int ff_rms(const int *data)
Definition: ra144.c:1636
ff_int_to_int16
void ff_int_to_int16(int16_t *out, const int *inp)
Definition: ra144.c:1613
RA144Context
Definition: ra144.h:40
ff_cb1_vects
const int8_t ff_cb1_vects[128][40]
Definition: ra144.c:114
RA144Context::adsp
AudioDSPContext adsp
Definition: ra144.h:42
RA144Context::lpc_tables
unsigned int lpc_tables[2][10]
Definition: ra144.h:49
ff_energy_tab
const int16_t ff_energy_tab[32]
Definition: ra144.c:1440
ff_subblock_synthesis
void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs, int cba_idx, int cb1_idx, int cb2_idx, int gval, int gain)
Definition: ra144.c:1694
source
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a source
Definition: filter_design.txt:255
RA144Context::curr_sblock
int16_t curr_sblock[50]
The current subblock padded by the last 10 values of the previous one.
Definition: ra144.h:60
ff_irms
int ff_irms(AudioDSPContext *adsp, const int16_t *data)
inverse root mean square
Definition: ra144.c:1684
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:87
RA144Context::afq
AudioFrameQueue afq
Definition: ra144.h:44
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
ff_t_sqrt
int ff_t_sqrt(unsigned int x)
Evaluate sqrt(x << 24).
Definition: ra144.c:1625
RA144Context::old_energy
unsigned int old_energy
previous frame energy
Definition: ra144.h:47
ff_interp
int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy)
Definition: ra144.c:1657
ff_gain_val_tab
const int16_t ff_gain_val_tab[256][3]
Definition: ra144.c:28
ff_cb2_vects
const int8_t ff_cb2_vects[128][40]
Definition: ra144.c:758
ff_cb1_base
const uint16_t ff_cb1_base[128]
Definition: ra144.c:1402
ff_copy_and_dup
void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset)
Copy the last offset values of *source to *target.
Definition: ra144.c:1530
RA144Context::adapt_cb
int16_t adapt_cb[146+2]
Adaptive codebook, its size is two units bigger to avoid a buffer overflow.
Definition: ra144.h:64
AVCodecContext
main external API structure.
Definition: avcodec.h:426
ff_cb2_base
const uint16_t ff_cb2_base[128]
Definition: ra144.c:1421
audiodsp.h
ff_eval_refl
int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
Evaluate the reflection coefficients from the filter coefficients.
Definition: ra144.c:1545
RA144Context::last_frame
int last_frame
Definition: ra144.h:45
AudioDSPContext
Definition: audiodsp.h:24
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
RA144Context::lpc_refl_rms
unsigned int lpc_refl_rms[2]
Definition: ra144.h:55
BLOCKSIZE
#define BLOCKSIZE
subblock size in 16-bit words
Definition: ra144.h:34
RA144Context::lpc_ctx
LPCContext lpc_ctx
Definition: ra144.h:43