24 #define BITSTREAM_READER_LE
32 #define MAX_BACKWARD_FILTER_ORDER 36
33 #define MAX_BACKWARD_FILTER_LEN 40
34 #define MAX_BACKWARD_FILTER_NONREC 35
36 #define RA288_BLOCK_SIZE 5
37 #define RA288_BLOCKS_PER_FRAME 32
74 static void convolve(
float *tgt,
const float *src,
int len,
int n)
89 memmove(ractx->
sp_hist + 70, ractx->
sp_hist + 75, 36*
sizeof(*block));
93 for (i=0; i < 10; i++)
94 sum -= gain_block[9-i] * ractx->
gain_lpc[i];
97 sum = av_clipf(sum, 0, 60);
101 sumsum = exp(sum * 0.1151292546497) * gain * (1.0/(1<<23));
103 for (i=0; i < 5; i++)
104 buffer[i] =
codetable[cb_coef][i] * sumsum;
111 memmove(gain_block, gain_block + 1, 9 *
sizeof(*gain_block));
113 gain_block[9] = 10 * log10(sum) - 32;
131 int order,
int n,
int non_rec,
float *out,
132 float *hist,
float *out2,
const float *window)
143 convolve(buffer1, work + order , n , order);
144 convolve(buffer2, work + order + n, non_rec, order);
146 for (i=0; i <= order; i++) {
147 out2[i] = out2[i] * 0.5625 + buffer1[i];
148 out [i] = out2[i] + buffer2[i];
159 float *hist,
float *rec,
const float *window,
160 float *lpc,
const float *
tab,
161 int order,
int n,
int non_rec,
int move_size)
170 memmove(hist, hist + n, move_size*
sizeof(*hist));
174 int *got_frame_ptr,
AVPacket *avpkt)
176 const uint8_t *buf = avpkt->
data;
177 int buf_size = avpkt->
size;
183 if (buf_size < avctx->block_align) {
185 "Error! Input buffer is too small [%d<%d]\n",
202 int cb_coef =
get_bits(&gb, 6 + (i&1));
204 decode(ractx, gain, cb_coef);
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const float gain_window[FFALIGN(38, 8)]
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
float ff_dot_productf(const float *a, const float *b, int length)
Return the dot product.
static void backward_filter(RA288Context *ractx, float *hist, float *rec, const float *window, float *lpc, const float *tab, int order, int n, int non_rec, int move_size)
Backward synthesis filter, find the LPC coefficients from past speech data.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define MAX_BACKWARD_FILTER_ORDER
AVFrame * coded_frame
the picture in the bitstream
#define DECLARE_ALIGNED(n, t, v)
static void decode(RA288Context *ractx, float gain, int cb_coef)
static const float syn_bw_tab[FFALIGN(36, 8)]
synthesis bandwidth broadening table
float sp_lpc[FFALIGN(36, 8)]
LPC coefficients for speech data (spec: A)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static const float amptable[8]
float sp_hist[111]
speech data history (spec: SB).
enum AVSampleFormat sample_fmt
audio sample format
#define MAX_BACKWARD_FILTER_NONREC
float gain_hist[38]
log-gain history (spec: SBLG).
bitstream reader API header.
#define LOCAL_ALIGNED_16(t, v,...)
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
static int init(AVCodecParserContext *s)
static const float syn_window[FFALIGN(111, 8)]
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define MAX_BACKWARD_FILTER_LEN
static const float gain_bw_tab[FFALIGN(10, 8)]
gain bandwidth broadening table
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static void convolve(float *tgt, const float *src, int len, int n)
AVCodec ff_ra_288_decoder
#define RA288_BLOCKS_PER_FRAME
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
static const int16_t codetable[128][5]
float sp_rec[37]
speech part of the gain autocorrelation (spec: REXP)
static int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order, LPC_TYPE *lpc, int lpc_stride, int fail, int normalize)
Levinson-Durbin recursion.
float gain_lpc[FFALIGN(10, 8)]
LPC coefficients for gain (spec: GB)
main external API structure.
static void do_hybrid_window(RA288Context *ractx, int order, int n, int non_rec, float *out, float *hist, float *out2, const float *window)
Hybrid window filtering, see blocks 36 and 49 of the G.728 specification.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int ra288_decode_init(AVCodecContext *avctx)
static int ra288_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
common internal api header.
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
float gain_rec[11]
recursive part of the gain autocorrelation (spec: REXPLG)
static const struct @46 tab
TwinVQ codebooks.
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
int nb_samples
number of audio samples (per channel) described by this frame