*/
#include "avcodec.h"
-#include "bitstream.h"
+#include "get_bits.h"
#include "ra144.h"
#include "celp_filters.h"
typedef struct {
+ AVCodecContext *avctx;
+
unsigned int old_energy; ///< previous frame energy
unsigned int lpc_tables[2][10];
{
RA144Context *ractx = avctx->priv_data;
+ ractx->avctx = avctx;
+
ractx->lpc_coef[0] = ractx->lpc_tables[0];
ractx->lpc_coef[1] = ractx->lpc_tables[1];
for (i=!skip_first; i<3; i++)
v[i] = (gain_val_tab[n][i] * m[i]) >> gain_exp_tab[n];
- for (i=0; i < BLOCKSIZE; i++)
- dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12;
+ if (v[0]) {
+ for (i=0; i < BLOCKSIZE; i++)
+ dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12;
+ } else {
+ for (i=0; i < BLOCKSIZE; i++)
+ dest[i] = ( s2[i]*v[1] + s3[i]*v[2]) >> 12;
+ }
}
static unsigned int rescale_rms(unsigned int rms, unsigned int energy)
block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE;
- add_wav(block, gain, cba_idx, m, buffer_a,
+ add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
cb1_vects[cb1_idx], cb2_vects[cb2_idx]);
memcpy(ractx->curr_sblock, ractx->curr_sblock + 40,
* @return 1 if one of the reflection coefficients is greater than
* 4095, 0 if not.
*/
-static int eval_refl(int *refl, const int16_t *coefs, RA144Context *ractx)
+static int eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
{
int b, i, j;
int buffer1[10];
refl[9] = bp2[9];
if ((unsigned) bp2[9] + 0x1000 > 0x1fff) {
- av_log(ractx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
+ av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
return 1;
}
for (i=0; i<30; i++)
out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2;
- if (eval_refl(work, out, ractx)) {
+ if (eval_refl(work, out, ractx->avctx)) {
// The interpolated coefficients are unstable, copy either new or old
// coefficients.
int_to_int16(out, ractx->lpc_coef[copyold]);
/** Uncompress one block (20 bytes -> 160*2 bytes). */
static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
- int *data_size, const uint8_t *buf, int buf_size)
+ int *data_size, AVPacket *avpkt)
{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2};
unsigned int refl_rms[4]; // RMS of the reflection coefficients
uint16_t block_coefs[4][30]; // LPC coefficients of each sub-block