You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.1KB

  1. /*
  2. * Real Audio 1.0 (14.4K)
  3. * Copyright (c) 2003 The FFmpeg project
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef AVCODEC_RA144_H
  22. #define AVCODEC_RA144_H
  23. #include <stdint.h>
  24. #include "lpc.h"
  25. #include "audio_frame_queue.h"
  26. #define NBLOCKS 4 ///< number of subblocks within a block
  27. #define BLOCKSIZE 40 ///< subblock size in 16-bit words
  28. #define BUFFERSIZE 146 ///< the size of the adaptive codebook
  29. #define FIXED_CB_SIZE 128 ///< size of fixed codebooks
  30. #define FRAMESIZE 20 ///< size of encoded frame
  31. #define LPC_ORDER 10 ///< order of LPC filter
  32. typedef struct RA144Context {
  33. AVCodecContext *avctx;
  34. LPCContext lpc_ctx;
  35. AudioFrameQueue afq;
  36. int last_frame;
  37. unsigned int old_energy; ///< previous frame energy
  38. unsigned int lpc_tables[2][10];
  39. /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame
  40. * and lpc_coef[1] of the previous one. */
  41. unsigned int *lpc_coef[2];
  42. unsigned int lpc_refl_rms[2];
  43. int16_t curr_block[NBLOCKS * BLOCKSIZE];
  44. /** The current subblock padded by the last 10 values of the previous one. */
  45. int16_t curr_sblock[50];
  46. /** Adaptive codebook, its size is two units bigger to avoid a
  47. * buffer overflow. */
  48. uint16_t adapt_cb[146+2];
  49. } RA144Context;
  50. void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset);
  51. int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx);
  52. void ff_eval_coefs(int *coefs, const int *refl);
  53. void ff_int_to_int16(int16_t *out, const int *inp);
  54. int ff_t_sqrt(unsigned int x);
  55. unsigned int ff_rms(const int *data);
  56. int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold,
  57. int energy);
  58. unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy);
  59. int ff_irms(const int16_t *data);
  60. void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
  61. int cba_idx, int cb1_idx, int cb2_idx,
  62. int gval, int gain);
  63. extern const int16_t ff_gain_val_tab[256][3];
  64. extern const uint8_t ff_gain_exp_tab[256];
  65. extern const int8_t ff_cb1_vects[128][40];
  66. extern const int8_t ff_cb2_vects[128][40];
  67. extern const uint16_t ff_cb1_base[128];
  68. extern const uint16_t ff_cb2_base[128];
  69. extern const int16_t ff_energy_tab[32];
  70. extern const int16_t * const ff_lpc_refl_cb[10];
  71. #endif /* AVCODEC_RA144_H */