comparison ra144dec.c @ 11868:159554445343 libavcodec

Split do_output_subblock() into common code and decoder specific parts Patch by Francesco Lavra (firstnamelastname@interfree.it)
author vitor
date Fri, 11 Jun 2010 08:05:17 +0000
parents 0d8f35836b20
children
comparison
equal deleted inserted replaced
11867:ba4e21f7bd3a 11868:159554445343
24 24
25 #include "libavutil/intmath.h" 25 #include "libavutil/intmath.h"
26 #include "avcodec.h" 26 #include "avcodec.h"
27 #include "get_bits.h" 27 #include "get_bits.h"
28 #include "ra144.h" 28 #include "ra144.h"
29 #include "celp_filters.h"
30 29
31 30
32 static av_cold int ra144_decode_init(AVCodecContext * avctx) 31 static av_cold int ra144_decode_init(AVCodecContext * avctx)
33 { 32 {
34 RA144Context *ractx = avctx->priv_data; 33 RA144Context *ractx = avctx->priv_data;
43 } 42 }
44 43
45 static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs, 44 static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs,
46 int gval, GetBitContext *gb) 45 int gval, GetBitContext *gb)
47 { 46 {
48 uint16_t buffer_a[40];
49 uint16_t *block;
50 int cba_idx = get_bits(gb, 7); // index of the adaptive CB, 0 if none 47 int cba_idx = get_bits(gb, 7); // index of the adaptive CB, 0 if none
51 int gain = get_bits(gb, 8); 48 int gain = get_bits(gb, 8);
52 int cb1_idx = get_bits(gb, 7); 49 int cb1_idx = get_bits(gb, 7);
53 int cb2_idx = get_bits(gb, 7); 50 int cb2_idx = get_bits(gb, 7);
54 int m[3];
55 51
56 if (cba_idx) { 52 ff_subblock_synthesis(ractx, lpc_coefs, cba_idx, cb1_idx, cb2_idx, gval,
57 cba_idx += BLOCKSIZE/2 - 1; 53 gain);
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
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));
81 } 54 }
82 55
83 /** Uncompress one block (20 bytes -> 160*2 bytes). */ 56 /** Uncompress one block (20 bytes -> 160*2 bytes). */
84 static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, 57 static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
85 int *data_size, AVPacket *avpkt) 58 int *data_size, AVPacket *avpkt)