... | ... |
@@ -1544,22 +1544,22 @@ void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset) |
1544 | 1544 |
int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx) |
1545 | 1545 |
{ |
1546 | 1546 |
int b, i, j; |
1547 |
- int buffer1[10]; |
|
1548 |
- int buffer2[10]; |
|
1547 |
+ int buffer1[LPC_ORDER]; |
|
1548 |
+ int buffer2[LPC_ORDER]; |
|
1549 | 1549 |
int *bp1 = buffer1; |
1550 | 1550 |
int *bp2 = buffer2; |
1551 | 1551 |
|
1552 |
- for (i=0; i < 10; i++) |
|
1552 |
+ for (i=0; i < LPC_ORDER; i++) |
|
1553 | 1553 |
buffer2[i] = coefs[i]; |
1554 | 1554 |
|
1555 |
- refl[9] = bp2[9]; |
|
1555 |
+ refl[LPC_ORDER-1] = bp2[LPC_ORDER-1]; |
|
1556 | 1556 |
|
1557 |
- if ((unsigned) bp2[9] + 0x1000 > 0x1fff) { |
|
1557 |
+ if ((unsigned) bp2[LPC_ORDER-1] + 0x1000 > 0x1fff) { |
|
1558 | 1558 |
av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n"); |
1559 | 1559 |
return 1; |
1560 | 1560 |
} |
1561 | 1561 |
|
1562 |
- for (i=8; i >= 0; i--) { |
|
1562 |
+ for (i = LPC_ORDER-2; i >= 0; i--) { |
|
1563 | 1563 |
b = 0x1000-((bp2[i+1] * bp2[i+1]) >> 12); |
1564 | 1564 |
|
1565 | 1565 |
if (!b) |
... | ... |
@@ -1584,12 +1584,12 @@ int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx) |
1584 | 1584 |
*/ |
1585 | 1585 |
void ff_eval_coefs(int *coefs, const int *refl) |
1586 | 1586 |
{ |
1587 |
- int buffer[10]; |
|
1587 |
+ int buffer[LPC_ORDER]; |
|
1588 | 1588 |
int *b1 = buffer; |
1589 | 1589 |
int *b2 = coefs; |
1590 | 1590 |
int i, j; |
1591 | 1591 |
|
1592 |
- for (i=0; i < 10; i++) { |
|
1592 |
+ for (i=0; i < LPC_ORDER; i++) { |
|
1593 | 1593 |
b1[i] = refl[i] << 4; |
1594 | 1594 |
|
1595 | 1595 |
for (j=0; j < i; j++) |
... | ... |
@@ -1598,7 +1598,7 @@ void ff_eval_coefs(int *coefs, const int *refl) |
1598 | 1598 |
FFSWAP(int *, b1, b2); |
1599 | 1599 |
} |
1600 | 1600 |
|
1601 |
- for (i=0; i < 10; i++) |
|
1601 |
+ for (i=0; i < LPC_ORDER; i++) |
|
1602 | 1602 |
coefs[i] >>= 4; |
1603 | 1603 |
} |
1604 | 1604 |
|
... | ... |
@@ -1606,7 +1606,7 @@ void ff_int_to_int16(int16_t *out, const int *inp) |
1606 | 1606 |
{ |
1607 | 1607 |
int i; |
1608 | 1608 |
|
1609 |
- for (i=0; i < 10; i++) |
|
1609 |
+ for (i = 0; i < LPC_ORDER; i++) |
|
1610 | 1610 |
*out++ = *inp++; |
1611 | 1611 |
} |
1612 | 1612 |
|
... | ... |
@@ -1629,9 +1629,9 @@ unsigned int ff_rms(const int *data) |
1629 | 1629 |
{ |
1630 | 1630 |
int i; |
1631 | 1631 |
unsigned int res = 0x10000; |
1632 |
- int b = 10; |
|
1632 |
+ int b = LPC_ORDER; |
|
1633 | 1633 |
|
1634 |
- for (i=0; i < 10; i++) { |
|
1634 |
+ for (i = 0; i < LPC_ORDER; i++) { |
|
1635 | 1635 |
res = (((0x1000000 - data[i]*data[i]) >> 12) * res) >> 12; |
1636 | 1636 |
|
1637 | 1637 |
if (res == 0) |
... | ... |
@@ -1648,13 +1648,13 @@ unsigned int ff_rms(const int *data) |
1648 | 1648 |
|
1649 | 1649 |
int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy) |
1650 | 1650 |
{ |
1651 |
- int work[10]; |
|
1651 |
+ int work[LPC_ORDER]; |
|
1652 | 1652 |
int b = NBLOCKS - a; |
1653 | 1653 |
int i; |
1654 | 1654 |
|
1655 | 1655 |
// Interpolate block coefficients from the this frame's forth block and |
1656 | 1656 |
// last frame's forth block. |
1657 |
- for (i=0; i<10; i++) |
|
1657 |
+ for (i = 0; i < LPC_ORDER; i++) |
|
1658 | 1658 |
out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2; |
1659 | 1659 |
|
1660 | 1660 |
if (ff_eval_refl(work, out, ractx->avctx)) { |
... | ... |
@@ -1690,7 +1690,7 @@ void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs, |
1690 | 1690 |
int cba_idx, int cb1_idx, int cb2_idx, |
1691 | 1691 |
int gval, int gain) |
1692 | 1692 |
{ |
1693 |
- uint16_t buffer_a[40]; |
|
1693 |
+ uint16_t buffer_a[BLOCKSIZE]; |
|
1694 | 1694 |
uint16_t *block; |
1695 | 1695 |
int m[3]; |
1696 | 1696 |
|
... | ... |
@@ -1711,10 +1711,10 @@ void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs, |
1711 | 1711 |
ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL, |
1712 | 1712 |
ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]); |
1713 | 1713 |
|
1714 |
- memcpy(ractx->curr_sblock, ractx->curr_sblock + 40, |
|
1715 |
- 10*sizeof(*ractx->curr_sblock)); |
|
1714 |
+ memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE, |
|
1715 |
+ LPC_ORDER*sizeof(*ractx->curr_sblock)); |
|
1716 | 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)); |
|
1717 |
+ if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + LPC_ORDER, lpc_coefs, |
|
1718 |
+ block, BLOCKSIZE, LPC_ORDER, 1, 0xfff)) |
|
1719 |
+ memset(ractx->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*ractx->curr_sblock)); |
|
1720 | 1720 |
} |
... | ... |
@@ -59,10 +59,10 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, |
59 | 59 |
{ |
60 | 60 |
const uint8_t *buf = avpkt->data; |
61 | 61 |
int buf_size = avpkt->size; |
62 |
- static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; |
|
63 |
- unsigned int refl_rms[4]; // RMS of the reflection coefficients |
|
64 |
- uint16_t block_coefs[4][10]; // LPC coefficients of each sub-block |
|
65 |
- unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame |
|
62 |
+ static const uint8_t sizes[LPC_ORDER] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; |
|
63 |
+ unsigned int refl_rms[NBLOCKS]; // RMS of the reflection coefficients |
|
64 |
+ uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block |
|
65 |
+ unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame |
|
66 | 66 |
int i, j; |
67 | 67 |
int out_size; |
68 | 68 |
int16_t *data = vdata; |
... | ... |
@@ -77,15 +77,15 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, |
77 | 77 |
return AVERROR(EINVAL); |
78 | 78 |
} |
79 | 79 |
|
80 |
- if(buf_size < 20) { |
|
80 |
+ if(buf_size < FRAMESIZE) { |
|
81 | 81 |
av_log(avctx, AV_LOG_ERROR, |
82 | 82 |
"Frame too small (%d bytes). Truncated file?\n", buf_size); |
83 | 83 |
*data_size = 0; |
84 | 84 |
return buf_size; |
85 | 85 |
} |
86 |
- init_get_bits(&gb, buf, 20 * 8); |
|
86 |
+ init_get_bits(&gb, buf, FRAMESIZE * 8); |
|
87 | 87 |
|
88 |
- for (i=0; i<10; i++) |
|
88 |
+ for (i = 0; i < LPC_ORDER; i++) |
|
89 | 89 |
lpc_refl[i] = ff_lpc_refl_cb[i][get_bits(&gb, sizes[i])]; |
90 | 90 |
|
91 | 91 |
ff_eval_coefs(ractx->lpc_coef[0], lpc_refl); |
... | ... |
@@ -102,7 +102,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, |
102 | 102 |
|
103 | 103 |
ff_int_to_int16(block_coefs[3], ractx->lpc_coef[0]); |
104 | 104 |
|
105 |
- for (i=0; i < 4; i++) { |
|
105 |
+ for (i=0; i < NBLOCKS; i++) { |
|
106 | 106 |
do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb); |
107 | 107 |
|
108 | 108 |
for (j=0; j < BLOCKSIZE; j++) |
... | ... |
@@ -115,7 +115,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, |
115 | 115 |
FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); |
116 | 116 |
|
117 | 117 |
*data_size = out_size; |
118 |
- return 20; |
|
118 |
+ return FRAMESIZE; |
|
119 | 119 |
} |
120 | 120 |
|
121 | 121 |
AVCodec ff_ra_144_decoder = { |