mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
Split do_output_subblock() into common code and decoder specific parts
Patch by Francesco Lavra (firstnamelastname@interfree.it) Originally committed as revision 23576 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
5ec29beeb4
commit
756e346798
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "celp_filters.h"
|
||||||
#include "ra144.h"
|
#include "ra144.h"
|
||||||
|
|
||||||
const int16_t ff_gain_val_tab[256][3] = {
|
const int16_t ff_gain_val_tab[256][3] = {
|
||||||
@ -1684,3 +1685,36 @@ int ff_irms(const int16_t *data)
|
|||||||
|
|
||||||
return 0x20000000 / (ff_t_sqrt(sum) >> 8);
|
return 0x20000000 / (ff_t_sqrt(sum) >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
|
||||||
|
int cba_idx, int cb1_idx, int cb2_idx,
|
||||||
|
int gval, int gain)
|
||||||
|
{
|
||||||
|
uint16_t buffer_a[40];
|
||||||
|
uint16_t *block;
|
||||||
|
int m[3];
|
||||||
|
|
||||||
|
if (cba_idx) {
|
||||||
|
cba_idx += BLOCKSIZE/2 - 1;
|
||||||
|
ff_copy_and_dup(buffer_a, ractx->adapt_cb, cba_idx);
|
||||||
|
m[0] = (ff_irms(buffer_a) * gval) >> 12;
|
||||||
|
} else {
|
||||||
|
m[0] = 0;
|
||||||
|
}
|
||||||
|
m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8;
|
||||||
|
m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8;
|
||||||
|
memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE,
|
||||||
|
(BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb));
|
||||||
|
|
||||||
|
block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE;
|
||||||
|
|
||||||
|
ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
|
||||||
|
ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]);
|
||||||
|
|
||||||
|
memcpy(ractx->curr_sblock, ractx->curr_sblock + 40,
|
||||||
|
10*sizeof(*ractx->curr_sblock));
|
||||||
|
|
||||||
|
if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs,
|
||||||
|
block, BLOCKSIZE, 10, 1, 0xfff))
|
||||||
|
memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock));
|
||||||
|
}
|
||||||
|
@ -61,6 +61,9 @@ int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold,
|
|||||||
int energy);
|
int energy);
|
||||||
unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy);
|
unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy);
|
||||||
int ff_irms(const int16_t *data);
|
int ff_irms(const int16_t *data);
|
||||||
|
void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
|
||||||
|
int cba_idx, int cb1_idx, int cb2_idx,
|
||||||
|
int gval, int gain);
|
||||||
|
|
||||||
extern const int16_t ff_gain_val_tab[256][3];
|
extern const int16_t ff_gain_val_tab[256][3];
|
||||||
extern const uint8_t ff_gain_exp_tab[256];
|
extern const uint8_t ff_gain_exp_tab[256];
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "ra144.h"
|
#include "ra144.h"
|
||||||
#include "celp_filters.h"
|
|
||||||
|
|
||||||
|
|
||||||
static av_cold int ra144_decode_init(AVCodecContext * avctx)
|
static av_cold int ra144_decode_init(AVCodecContext * avctx)
|
||||||
@ -45,39 +44,13 @@ static av_cold int ra144_decode_init(AVCodecContext * avctx)
|
|||||||
static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs,
|
static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs,
|
||||||
int gval, GetBitContext *gb)
|
int gval, GetBitContext *gb)
|
||||||
{
|
{
|
||||||
uint16_t buffer_a[40];
|
|
||||||
uint16_t *block;
|
|
||||||
int cba_idx = get_bits(gb, 7); // index of the adaptive CB, 0 if none
|
int cba_idx = get_bits(gb, 7); // index of the adaptive CB, 0 if none
|
||||||
int gain = get_bits(gb, 8);
|
int gain = get_bits(gb, 8);
|
||||||
int cb1_idx = get_bits(gb, 7);
|
int cb1_idx = get_bits(gb, 7);
|
||||||
int cb2_idx = get_bits(gb, 7);
|
int cb2_idx = get_bits(gb, 7);
|
||||||
int m[3];
|
|
||||||
|
|
||||||
if (cba_idx) {
|
ff_subblock_synthesis(ractx, lpc_coefs, cba_idx, cb1_idx, cb2_idx, gval,
|
||||||
cba_idx += BLOCKSIZE/2 - 1;
|
gain);
|
||||||
ff_copy_and_dup(buffer_a, ractx->adapt_cb, cba_idx);
|
|
||||||
m[0] = (ff_irms(buffer_a) * gval) >> 12;
|
|
||||||
} else {
|
|
||||||
m[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8;
|
|
||||||
m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8;
|
|
||||||
|
|
||||||
memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE,
|
|
||||||
(BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb));
|
|
||||||
|
|
||||||
block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE;
|
|
||||||
|
|
||||||
ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
|
|
||||||
ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]);
|
|
||||||
|
|
||||||
memcpy(ractx->curr_sblock, ractx->curr_sblock + 40,
|
|
||||||
10*sizeof(*ractx->curr_sblock));
|
|
||||||
|
|
||||||
if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs,
|
|
||||||
block, BLOCKSIZE, 10, 1, 0xfff))
|
|
||||||
memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Uncompress one block (20 bytes -> 160*2 bytes). */
|
/** Uncompress one block (20 bytes -> 160*2 bytes). */
|
||||||
|
Loading…
Reference in New Issue
Block a user