2003-06-29 21:11:55 +02:00
|
|
|
/*
|
|
|
|
* Real Audio 1.0 (14.4K)
|
|
|
|
* Copyright (c) 2003 the ffmpeg project
|
|
|
|
*
|
2006-10-07 17:30:46 +02:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2003-06-29 21:11:55 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 17:30:46 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-06-29 21:11:55 +02:00
|
|
|
*
|
2006-10-07 17:30:46 +02:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2003-06-29 21:11:55 +02:00
|
|
|
* 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
|
2006-10-07 17:30:46 +02:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2006-01-12 23:43:26 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-06-29 21:11:55 +02:00
|
|
|
*/
|
|
|
|
|
2008-08-31 09:39:47 +02:00
|
|
|
#ifndef AVCODEC_RA144_H
|
|
|
|
#define AVCODEC_RA144_H
|
2003-06-29 21:11:55 +02:00
|
|
|
|
2008-06-16 10:25:48 +02:00
|
|
|
#include <stdint.h>
|
2011-01-21 01:11:44 +01:00
|
|
|
#include "lpc.h"
|
2012-02-28 07:48:31 +01:00
|
|
|
#include "audio_frame_queue.h"
|
2012-03-04 13:28:16 +01:00
|
|
|
#include "dsputil.h"
|
2008-06-16 10:25:48 +02:00
|
|
|
|
2010-06-11 10:01:51 +02:00
|
|
|
#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
|
2010-06-11 11:01:25 +02:00
|
|
|
#define FIXED_CB_SIZE 128 ///< size of fixed codebooks
|
2013-06-30 13:45:10 +02:00
|
|
|
#define FRAME_SIZE 20 ///< size of encoded frame
|
2010-06-11 11:01:25 +02:00
|
|
|
#define LPC_ORDER 10 ///< order of LPC filter
|
2010-06-11 10:01:51 +02:00
|
|
|
|
2012-09-27 10:19:53 +02:00
|
|
|
typedef struct RA144Context {
|
2010-06-11 10:01:51 +02:00
|
|
|
AVCodecContext *avctx;
|
2012-03-04 13:28:16 +01:00
|
|
|
DSPContext dsp;
|
2011-01-21 01:11:44 +01:00
|
|
|
LPCContext lpc_ctx;
|
2012-02-28 07:48:31 +01:00
|
|
|
AudioFrameQueue afq;
|
2012-02-28 07:02:28 +01:00
|
|
|
int last_frame;
|
2010-06-11 10:01:51 +02:00
|
|
|
|
|
|
|
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];
|
|
|
|
|
2010-06-11 11:01:25 +02:00
|
|
|
int16_t curr_block[NBLOCKS * BLOCKSIZE];
|
|
|
|
|
2010-06-11 10:01:51 +02:00
|
|
|
/** 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. */
|
2013-04-17 21:09:06 +02:00
|
|
|
int16_t adapt_cb[146+2];
|
2012-03-04 13:28:16 +01:00
|
|
|
|
|
|
|
DECLARE_ALIGNED(16, int16_t, buffer_a)[FFALIGN(BLOCKSIZE,16)];
|
2010-06-11 10:01:51 +02:00
|
|
|
} RA144Context;
|
|
|
|
|
2010-06-11 10:03:43 +02:00
|
|
|
void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset);
|
|
|
|
int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx);
|
|
|
|
void ff_eval_coefs(int *coefs, const int *refl);
|
|
|
|
void ff_int_to_int16(int16_t *out, const int *inp);
|
|
|
|
int ff_t_sqrt(unsigned int x);
|
|
|
|
unsigned int ff_rms(const int *data);
|
|
|
|
int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold,
|
|
|
|
int energy);
|
|
|
|
unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy);
|
2012-03-04 13:28:16 +01:00
|
|
|
int ff_irms(DSPContext *dsp, const int16_t *data/*align 16*/);
|
2013-04-17 21:09:06 +02:00
|
|
|
void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs,
|
2010-06-11 10:05:17 +02:00
|
|
|
int cba_idx, int cb1_idx, int cb2_idx,
|
|
|
|
int gval, int gain);
|
2010-06-11 10:01:51 +02:00
|
|
|
|
2010-06-11 10:03:43 +02:00
|
|
|
extern const int16_t ff_gain_val_tab[256][3];
|
|
|
|
extern const uint8_t ff_gain_exp_tab[256];
|
|
|
|
extern const int8_t ff_cb1_vects[128][40];
|
|
|
|
extern const int8_t ff_cb2_vects[128][40];
|
|
|
|
extern const uint16_t ff_cb1_base[128];
|
|
|
|
extern const uint16_t ff_cb2_base[128];
|
|
|
|
extern const int16_t ff_energy_tab[32];
|
|
|
|
extern const int16_t * const ff_lpc_refl_cb[10];
|
2003-06-29 21:11:55 +02:00
|
|
|
|
2008-08-31 09:39:47 +02:00
|
|
|
#endif /* AVCODEC_RA144_H */
|