Revision 756e3467

View differences:

libavcodec/ra144.c
21 21

  
22 22
#include <stdint.h>
23 23
#include "avcodec.h"
24
#include "celp_filters.h"
24 25
#include "ra144.h"
25 26

  
26 27
const int16_t ff_gain_val_tab[256][3] = {
......
1684 1685

  
1685 1686
    return 0x20000000 / (ff_t_sqrt(sum) >> 8);
1686 1687
}
1688

  
1689
void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
1690
                           int cba_idx, int cb1_idx, int cb2_idx,
1691
                           int gval, int gain)
1692
{
1693
    uint16_t buffer_a[40];
1694
    uint16_t *block;
1695
    int m[3];
1696

  
1697
    if (cba_idx) {
1698
        cba_idx += BLOCKSIZE/2 - 1;
1699
        ff_copy_and_dup(buffer_a, ractx->adapt_cb, cba_idx);
1700
        m[0] = (ff_irms(buffer_a) * gval) >> 12;
1701
    } else {
1702
        m[0] = 0;
1703
    }
1704
    m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8;
1705
    m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8;
1706
    memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE,
1707
            (BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb));
1708

  
1709
    block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE;
1710

  
1711
    ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
1712
               ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]);
1713

  
1714
    memcpy(ractx->curr_sblock, ractx->curr_sblock + 40,
1715
           10*sizeof(*ractx->curr_sblock));
1716

  
1717
    if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs,
1718
                                    block, BLOCKSIZE, 10, 1, 0xfff))
1719
        memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock));
1720
}
libavcodec/ra144.h
61 61
              int energy);
62 62
unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy);
63 63
int ff_irms(const int16_t *data);
64
void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
65
                           int cba_idx, int cb1_idx, int cb2_idx,
66
                           int gval, int gain);
64 67

  
65 68
extern const int16_t ff_gain_val_tab[256][3];
66 69
extern const uint8_t ff_gain_exp_tab[256];
libavcodec/ra144dec.c
26 26
#include "avcodec.h"
27 27
#include "get_bits.h"
28 28
#include "ra144.h"
29
#include "celp_filters.h"
30 29

  
31 30

  
32 31
static av_cold int ra144_decode_init(AVCodecContext * avctx)
......
45 44
static void do_output_subblock(RA144Context *ractx, const uint16_t  *lpc_coefs,
46 45
                               int gval, GetBitContext *gb)
47 46
{
48
    uint16_t buffer_a[40];
49
    uint16_t *block;
50 47
    int cba_idx = get_bits(gb, 7); // index of the adaptive CB, 0 if none
51 48
    int gain    = get_bits(gb, 8);
52 49
    int cb1_idx = get_bits(gb, 7);
53 50
    int cb2_idx = get_bits(gb, 7);
54
    int m[3];
55

  
56
    if (cba_idx) {
57
        cba_idx += BLOCKSIZE/2 - 1;
58
        ff_copy_and_dup(buffer_a, ractx->adapt_cb, cba_idx);
59
        m[0] = (ff_irms(buffer_a) * gval) >> 12;
60
    } else {
61
        m[0] = 0;
62
    }
63

  
64
    m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8;
65
    m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8;
66

  
67
    memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE,
68
            (BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb));
69

  
70
    block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE;
71

  
72
    ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
73
               ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]);
74

  
75
    memcpy(ractx->curr_sblock, ractx->curr_sblock + 40,
76
           10*sizeof(*ractx->curr_sblock));
77 51

  
78
    if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs,
79
                                    block, BLOCKSIZE, 10, 1, 0xfff))
80
        memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock));
52
    ff_subblock_synthesis(ractx, lpc_coefs, cba_idx, cb1_idx, cb2_idx, gval,
53
                          gain);
81 54
}
82 55

  
83 56
/** Uncompress one block (20 bytes -> 160*2 bytes). */

Also available in: Unified diff