yading@10: /* yading@10: * Real Audio 1.0 (14.4K) yading@10: * Copyright (c) 2003 the ffmpeg project yading@10: * yading@10: * This file is part of FFmpeg. yading@10: * yading@10: * FFmpeg is free software; you can redistribute it and/or yading@10: * modify it under the terms of the GNU Lesser General Public yading@10: * License as published by the Free Software Foundation; either yading@10: * version 2.1 of the License, or (at your option) any later version. yading@10: * yading@10: * FFmpeg is distributed in the hope that it will be useful, yading@10: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@10: * Lesser General Public License for more details. yading@10: * yading@10: * You should have received a copy of the GNU Lesser General Public yading@10: * License along with FFmpeg; if not, write to the Free Software yading@10: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@10: */ yading@10: yading@10: #ifndef AVCODEC_RA144_H yading@10: #define AVCODEC_RA144_H yading@10: yading@10: #include yading@10: #include "lpc.h" yading@10: #include "audio_frame_queue.h" yading@10: yading@10: #define NBLOCKS 4 ///< number of subblocks within a block yading@10: #define BLOCKSIZE 40 ///< subblock size in 16-bit words yading@10: #define BUFFERSIZE 146 ///< the size of the adaptive codebook yading@10: #define FIXED_CB_SIZE 128 ///< size of fixed codebooks yading@10: #define FRAMESIZE 20 ///< size of encoded frame yading@10: #define LPC_ORDER 10 ///< order of LPC filter yading@10: yading@10: typedef struct RA144Context { yading@10: AVCodecContext *avctx; yading@10: LPCContext lpc_ctx; yading@10: AudioFrameQueue afq; yading@10: int last_frame; yading@10: yading@10: unsigned int old_energy; ///< previous frame energy yading@10: yading@10: unsigned int lpc_tables[2][10]; yading@10: yading@10: /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame yading@10: * and lpc_coef[1] of the previous one. */ yading@10: unsigned int *lpc_coef[2]; yading@10: yading@10: unsigned int lpc_refl_rms[2]; yading@10: yading@10: int16_t curr_block[NBLOCKS * BLOCKSIZE]; yading@10: yading@10: /** The current subblock padded by the last 10 values of the previous one. */ yading@10: int16_t curr_sblock[50]; yading@10: yading@10: /** Adaptive codebook, its size is two units bigger to avoid a yading@10: * buffer overflow. */ yading@10: int16_t adapt_cb[146+2]; yading@10: } RA144Context; yading@10: yading@10: void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset); yading@10: int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx); yading@10: void ff_eval_coefs(int *coefs, const int *refl); yading@10: void ff_int_to_int16(int16_t *out, const int *inp); yading@10: int ff_t_sqrt(unsigned int x); yading@10: unsigned int ff_rms(const int *data); yading@10: int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, yading@10: int energy); yading@10: unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy); yading@10: int ff_irms(const int16_t *data); yading@10: void ff_subblock_synthesis(RA144Context *ractx, const int16_t *lpc_coefs, yading@10: int cba_idx, int cb1_idx, int cb2_idx, yading@10: int gval, int gain); yading@10: yading@10: extern const int16_t ff_gain_val_tab[256][3]; yading@10: extern const uint8_t ff_gain_exp_tab[256]; yading@10: extern const int8_t ff_cb1_vects[128][40]; yading@10: extern const int8_t ff_cb2_vects[128][40]; yading@10: extern const uint16_t ff_cb1_base[128]; yading@10: extern const uint16_t ff_cb2_base[128]; yading@10: extern const int16_t ff_energy_tab[32]; yading@10: extern const int16_t * const ff_lpc_refl_cb[10]; yading@10: yading@10: #endif /* AVCODEC_RA144_H */