comparison ra144.c @ 11866:0d8f35836b20 libavcodec

Add ff_ prefix to non-static functions Patch by Francesco Lavra (firstnamelastname@interfree.it)
author vitor
date Fri, 11 Jun 2010 08:03:43 +0000
parents 6111134a3d94
children ba4e21f7bd3a
comparison
equal deleted inserted replaced
11865:6111134a3d94 11866:0d8f35836b20
21 21
22 #include <stdint.h> 22 #include <stdint.h>
23 #include "avcodec.h" 23 #include "avcodec.h"
24 #include "ra144.h" 24 #include "ra144.h"
25 25
26 const int16_t gain_val_tab[256][3] = { 26 const int16_t ff_gain_val_tab[256][3] = {
27 { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668}, 27 { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668},
28 {1246, 839, 1394}, {2560,1386, 991}, { 925, 687, 608}, {2208, 797, 1144}, 28 {1246, 839, 1394}, {2560,1386, 991}, { 925, 687, 608}, {2208, 797, 1144},
29 { 535, 832, 799}, { 762, 605, 1154}, { 832,1122, 1003}, {1180, 687, 1176}, 29 { 535, 832, 799}, { 762, 605, 1154}, { 832,1122, 1003}, {1180, 687, 1176},
30 {1292, 901, 732}, {1656, 689, 896}, {1750,1248, 848}, {2284, 942, 1022}, 30 {1292, 901, 732}, {1656, 689, 896}, {1750,1248, 848}, {2284, 942, 1022},
31 { 824,1472, 643}, { 517, 765, 512}, { 562,1816, 1522}, { 694,1826, 2700}, 31 { 824,1472, 643}, { 517, 765, 512}, { 562,1816, 1522}, { 694,1826, 2700},
88 {3936, 556, 1140}, {3936, 540, 740}, {4216, 764, 874}, {8480,1328, 1014}, 88 {3936, 556, 1140}, {3936, 540, 740}, {4216, 764, 874}, {8480,1328, 1014},
89 {2184, 515, 1042}, {4432, 934, 1344}, {4784, 945, 1112}, {5016,1062, 733}, 89 {2184, 515, 1042}, {4432, 934, 1344}, {4784, 945, 1112}, {5016,1062, 733},
90 {9216,1020, 2028}, {9968, 924, 1188}, {5424, 909, 1206}, {6512, 744, 1086} 90 {9216,1020, 2028}, {9968, 924, 1188}, {5424, 909, 1206}, {6512, 744, 1086}
91 }; 91 };
92 92
93 const uint8_t gain_exp_tab[256] = { 93 const uint8_t ff_gain_exp_tab[256] = {
94 15, 15, 15, 15, 15, 16, 14, 15, 14, 14, 14, 14, 14, 14, 14, 14, 94 15, 15, 15, 15, 15, 16, 14, 15, 14, 14, 14, 14, 14, 14, 14, 14,
95 14, 13, 14, 14, 13, 14, 13, 14, 13, 13, 13, 14, 13, 13, 14, 13, 95 14, 13, 14, 14, 13, 14, 13, 14, 13, 13, 13, 14, 13, 13, 14, 13,
96 13, 13, 13, 13, 14, 13, 12, 12, 13, 13, 13, 12, 13, 13, 13, 13, 96 13, 13, 13, 13, 14, 13, 12, 12, 13, 13, 13, 12, 13, 13, 13, 13,
97 13, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 13, 13, 97 13, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 13, 13,
98 13, 13, 13, 12, 12, 12, 13, 13, 12, 12, 12, 13, 12, 12, 12, 12, 98 13, 13, 13, 12, 12, 12, 13, 13, 12, 12, 12, 13, 12, 12, 12, 12,
107 13, 13, 12, 12, 13, 13, 13, 14, 12, 13, 13, 13, 13, 13, 13, 13, 107 13, 13, 12, 12, 13, 13, 13, 14, 12, 13, 13, 13, 13, 13, 13, 13,
108 11, 10, 11, 10, 11, 11, 10, 10, 11, 11, 11, 11, 10, 9, 11, 10, 108 11, 10, 11, 10, 11, 11, 10, 10, 11, 11, 11, 11, 10, 9, 11, 10,
109 12, 12, 11, 12, 12, 12, 12, 13, 11, 12, 12, 12, 13, 13, 12, 12 109 12, 12, 11, 12, 12, 12, 12, 13, 11, 12, 12, 12, 13, 13, 12, 12
110 }; 110 };
111 111
112 const int8_t cb1_vects[128][40]={ 112 const int8_t ff_cb1_vects[128][40]={
113 { 113 {
114 38, -4, 15, -4, 14, -13, 12, -11, -2, -6, 114 38, -4, 15, -4, 14, -13, 12, -11, -2, -6,
115 -6, -11, -45, -16, -11, -13, -7, 6, -12, 4, 115 -6, -11, -45, -16, -11, -13, -7, 6, -12, 4,
116 -20, 3, -16, 12, -1, 12, 46, 24, 0, 33, 116 -20, 3, -16, 12, -1, 12, 46, 24, 0, 33,
117 -3, 9, -12, -12, -8, -7, 17, -6, 0, -2, 117 -3, 9, -12, -12, -8, -7, 17, -6, 0, -2,
751 20, -3, 16, -12, 1, -12, -46, -24, 0, -33, 751 20, -3, 16, -12, 1, -12, -46, -24, 0, -33,
752 3, -9, 12, 12, 8, 7, -17, 6, 0, 2 752 3, -9, 12, 12, 8, 7, -17, 6, 0, 2
753 } 753 }
754 }; 754 };
755 755
756 const int8_t cb2_vects[128][40]={ 756 const int8_t ff_cb2_vects[128][40]={
757 { 757 {
758 73, -32, -60, -15, -26, 59, 2, -33, 30, -10, 758 73, -32, -60, -15, -26, 59, 2, -33, 30, -10,
759 -3, -17, 8, 30, -1, -26, -4, -22, 10, 16, 759 -3, -17, 8, 30, -1, -26, -4, -22, 10, 16,
760 -36, -5, -11, 56, 37, 6, -10, -5, -13, -3, 760 -36, -5, -11, 56, 37, 6, -10, -5, -13, -3,
761 6, -5, 11, 4, -19, -5, -16, 41, 24, 13, 761 6, -5, 11, 4, -19, -5, -16, 41, 24, 13,
1395 36, 5, 11, -56, -37, -6, 10, 5, 13, 3, 1395 36, 5, 11, -56, -37, -6, 10, 5, 13, 3,
1396 -6, 5, -11, -4, 19, 5, 16, -41, -24, -13 1396 -6, 5, -11, -4, 19, 5, 16, -41, -24, -13
1397 } 1397 }
1398 }; 1398 };
1399 1399
1400 const uint16_t cb1_base[128]={ 1400 const uint16_t ff_cb1_base[128]={
1401 19657, 18474, 18365, 17520, 21048, 18231, 18584, 16671, 1401 19657, 18474, 18365, 17520, 21048, 18231, 18584, 16671,
1402 20363, 19069, 19409, 18430, 21844, 18753, 19613, 17411, 1402 20363, 19069, 19409, 18430, 21844, 18753, 19613, 17411,
1403 20389, 21772, 20129, 21702, 20978, 20472, 19627, 19387, 1403 20389, 21772, 20129, 21702, 20978, 20472, 19627, 19387,
1404 21477, 23134, 21841, 23919, 22089, 21519, 21134, 20852, 1404 21477, 23134, 21841, 23919, 22089, 21519, 21134, 20852,
1405 19675, 17821, 19044, 17477, 19986, 16955, 18446, 16086, 1405 19675, 17821, 19044, 17477, 19986, 16955, 18446, 16086,
1414 19387, 19627, 20472, 20978, 21702, 20129, 21772, 20389, 1414 19387, 19627, 20472, 20978, 21702, 20129, 21772, 20389,
1415 17411, 19613, 18753, 21844, 18430, 19409, 19069, 20363, 1415 17411, 19613, 18753, 21844, 18430, 19409, 19069, 20363,
1416 16671, 18584, 18231, 21048, 17520, 18365, 18474, 19657, 1416 16671, 18584, 18231, 21048, 17520, 18365, 18474, 19657,
1417 }; 1417 };
1418 1418
1419 const uint16_t cb2_base[128]={ 1419 const uint16_t ff_cb2_base[128]={
1420 12174, 13380, 13879, 13832, 13170, 13227, 13204, 12053, 1420 12174, 13380, 13879, 13832, 13170, 13227, 13204, 12053,
1421 12410, 13988, 14348, 14631, 13100, 13415, 13224, 12268, 1421 12410, 13988, 14348, 14631, 13100, 13415, 13224, 12268,
1422 11982, 13825, 13499, 14210, 13877, 14788, 13811, 13109, 1422 11982, 13825, 13499, 14210, 13877, 14788, 13811, 13109,
1423 11449, 13275, 12833, 13717, 12728, 13696, 12759, 12405, 1423 11449, 13275, 12833, 13717, 12728, 13696, 12759, 12405,
1424 10230, 12185, 11628, 13161, 11762, 13458, 12312, 12818, 1424 10230, 12185, 11628, 13161, 11762, 13458, 12312, 12818,
1433 13109, 13811, 14788, 13877, 14210, 13499, 13825, 11982, 1433 13109, 13811, 14788, 13877, 14210, 13499, 13825, 11982,
1434 12268, 13224, 13415, 13100, 14631, 14348, 13988, 12410, 1434 12268, 13224, 13415, 13100, 14631, 14348, 13988, 12410,
1435 12053, 13204, 13227, 13170, 13832, 13879, 13380, 12174, 1435 12053, 13204, 13227, 13170, 13832, 13879, 13380, 12174,
1436 }; 1436 };
1437 1437
1438 const int16_t energy_tab[32]={ 1438 const int16_t ff_energy_tab[32]={
1439 0, 16, 20, 25, 32, 41, 51, 65, 1439 0, 16, 20, 25, 32, 41, 51, 65,
1440 81, 103, 129, 163, 205, 259, 326, 410, 1440 81, 103, 129, 163, 205, 259, 326, 410,
1441 516, 650, 819, 1031, 1298, 1634, 2057, 2590, 1441 516, 650, 819, 1031, 1298, 1634, 2057, 2590,
1442 3261, 4105, 5168, 6507, 8192, 10313, 12983, 16345 1442 3261, 4105, 5168, 6507, 8192, 10313, 12983, 16345
1443 }; 1443 };
1495 1495
1496 static const int16_t lpc_refl_cb10[4]={ 1496 static const int16_t lpc_refl_cb10[4]={
1497 -617, 190, 802, 1483 1497 -617, 190, 802, 1483
1498 }; 1498 };
1499 1499
1500 const int16_t * const lpc_refl_cb[10]={ 1500 const int16_t * const ff_lpc_refl_cb[10]={
1501 lpc_refl_cb1, lpc_refl_cb2, lpc_refl_cb3, lpc_refl_cb4, lpc_refl_cb5, 1501 lpc_refl_cb1, lpc_refl_cb2, lpc_refl_cb3, lpc_refl_cb4, lpc_refl_cb5,
1502 lpc_refl_cb6, lpc_refl_cb7, lpc_refl_cb8, lpc_refl_cb9, lpc_refl_cb10 1502 lpc_refl_cb6, lpc_refl_cb7, lpc_refl_cb8, lpc_refl_cb9, lpc_refl_cb10
1503 }; 1503 };
1504 1504
1505 void add_wav(int16_t *dest, int n, int skip_first, int *m, const int16_t *s1, 1505 void ff_add_wav(int16_t *dest, int n, int skip_first, int *m, const int16_t *s1,
1506 const int8_t *s2, const int8_t *s3) 1506 const int8_t *s2, const int8_t *s3)
1507 { 1507 {
1508 int i; 1508 int i;
1509 int v[3]; 1509 int v[3];
1510 1510
1511 v[0] = 0; 1511 v[0] = 0;
1512 for (i=!skip_first; i<3; i++) 1512 for (i=!skip_first; i<3; i++)
1513 v[i] = (gain_val_tab[n][i] * m[i]) >> gain_exp_tab[n]; 1513 v[i] = (ff_gain_val_tab[n][i] * m[i]) >> ff_gain_exp_tab[n];
1514 1514
1515 if (v[0]) { 1515 if (v[0]) {
1516 for (i=0; i < BLOCKSIZE; i++) 1516 for (i=0; i < BLOCKSIZE; i++)
1517 dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12; 1517 dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12;
1518 } else { 1518 } else {
1523 1523
1524 /** 1524 /**
1525 * Copy the last offset values of *source to *target. If those values are not 1525 * Copy the last offset values of *source to *target. If those values are not
1526 * enough to fill the target buffer, fill it with another copy of those values. 1526 * enough to fill the target buffer, fill it with another copy of those values.
1527 */ 1527 */
1528 void copy_and_dup(int16_t *target, const int16_t *source, int offset) 1528 void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset)
1529 { 1529 {
1530 source += BUFFERSIZE - offset; 1530 source += BUFFERSIZE - offset;
1531 1531
1532 memcpy(target, source, FFMIN(BLOCKSIZE, offset)*sizeof(*target)); 1532 memcpy(target, source, FFMIN(BLOCKSIZE, offset)*sizeof(*target));
1533 if (offset < BLOCKSIZE) 1533 if (offset < BLOCKSIZE)
1538 * Evaluate the reflection coefficients from the filter coefficients. 1538 * Evaluate the reflection coefficients from the filter coefficients.
1539 * 1539 *
1540 * @return 1 if one of the reflection coefficients is greater than 1540 * @return 1 if one of the reflection coefficients is greater than
1541 * 4095, 0 if not. 1541 * 4095, 0 if not.
1542 */ 1542 */
1543 int eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx) 1543 int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
1544 { 1544 {
1545 int b, i, j; 1545 int b, i, j;
1546 int buffer1[10]; 1546 int buffer1[10];
1547 int buffer2[10]; 1547 int buffer2[10];
1548 int *bp1 = buffer1; 1548 int *bp1 = buffer1;
1579 1579
1580 /** 1580 /**
1581 * Evaluate the LPC filter coefficients from the reflection coefficients. 1581 * Evaluate the LPC filter coefficients from the reflection coefficients.
1582 * Does the inverse of the eval_refl() function. 1582 * Does the inverse of the eval_refl() function.
1583 */ 1583 */
1584 void eval_coefs(int *coefs, const int *refl) 1584 void ff_eval_coefs(int *coefs, const int *refl)
1585 { 1585 {
1586 int buffer[10]; 1586 int buffer[10];
1587 int *b1 = buffer; 1587 int *b1 = buffer;
1588 int *b2 = coefs; 1588 int *b2 = coefs;
1589 int i, j; 1589 int i, j;
1599 1599
1600 for (i=0; i < 10; i++) 1600 for (i=0; i < 10; i++)
1601 coefs[i] >>= 4; 1601 coefs[i] >>= 4;
1602 } 1602 }
1603 1603
1604 void int_to_int16(int16_t *out, const int *inp) 1604 void ff_int_to_int16(int16_t *out, const int *inp)
1605 { 1605 {
1606 int i; 1606 int i;
1607 1607
1608 for (i=0; i < 10; i++) 1608 for (i=0; i < 10; i++)
1609 *out++ = *inp++; 1609 *out++ = *inp++;
1611 1611
1612 /** 1612 /**
1613 * Evaluate sqrt(x << 24). x must fit in 20 bits. This value is evaluated in an 1613 * Evaluate sqrt(x << 24). x must fit in 20 bits. This value is evaluated in an
1614 * odd way to make the output identical to the binary decoder. 1614 * odd way to make the output identical to the binary decoder.
1615 */ 1615 */
1616 int t_sqrt(unsigned int x) 1616 int ff_t_sqrt(unsigned int x)
1617 { 1617 {
1618 int s = 2; 1618 int s = 2;
1619 while (x > 0xfff) { 1619 while (x > 0xfff) {
1620 s++; 1620 s++;
1621 x >>= 2; 1621 x >>= 2;
1622 } 1622 }
1623 1623
1624 return ff_sqrt(x << 20) << s; 1624 return ff_sqrt(x << 20) << s;
1625 } 1625 }
1626 1626
1627 unsigned int rms(const int *data) 1627 unsigned int ff_rms(const int *data)
1628 { 1628 {
1629 int i; 1629 int i;
1630 unsigned int res = 0x10000; 1630 unsigned int res = 0x10000;
1631 int b = 10; 1631 int b = 10;
1632 1632
1640 b++; 1640 b++;
1641 res <<= 2; 1641 res <<= 2;
1642 } 1642 }
1643 } 1643 }
1644 1644
1645 return t_sqrt(res) >> b; 1645 return ff_t_sqrt(res) >> b;
1646 } 1646 }
1647 1647
1648 int interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy) 1648 int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy)
1649 { 1649 {
1650 int work[10]; 1650 int work[10];
1651 int b = NBLOCKS - a; 1651 int b = NBLOCKS - a;
1652 int i; 1652 int i;
1653 1653
1654 // Interpolate block coefficients from the this frame's forth block and 1654 // Interpolate block coefficients from the this frame's forth block and
1655 // last frame's forth block. 1655 // last frame's forth block.
1656 for (i=0; i<10; i++) 1656 for (i=0; i<10; i++)
1657 out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2; 1657 out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2;
1658 1658
1659 if (eval_refl(work, out, ractx->avctx)) { 1659 if (ff_eval_refl(work, out, ractx->avctx)) {
1660 // The interpolated coefficients are unstable, copy either new or old 1660 // The interpolated coefficients are unstable, copy either new or old
1661 // coefficients. 1661 // coefficients.
1662 int_to_int16(out, ractx->lpc_coef[copyold]); 1662 ff_int_to_int16(out, ractx->lpc_coef[copyold]);
1663 return rescale_rms(ractx->lpc_refl_rms[copyold], energy); 1663 return ff_rescale_rms(ractx->lpc_refl_rms[copyold], energy);
1664 } else { 1664 } else {
1665 return rescale_rms(rms(work), energy); 1665 return ff_rescale_rms(ff_rms(work), energy);
1666 } 1666 }
1667 } 1667 }
1668 1668
1669 unsigned int rescale_rms(unsigned int rms, unsigned int energy) 1669 unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy)
1670 { 1670 {
1671 return (rms * energy) >> 10; 1671 return (rms * energy) >> 10;
1672 } 1672 }
1673 1673
1674 /** inverse root mean square */ 1674 /** inverse root mean square */
1675 int irms(const int16_t *data) 1675 int ff_irms(const int16_t *data)
1676 { 1676 {
1677 unsigned int i, sum = 0; 1677 unsigned int i, sum = 0;
1678 1678
1679 for (i=0; i < BLOCKSIZE; i++) 1679 for (i=0; i < BLOCKSIZE; i++)
1680 sum += data[i] * data[i]; 1680 sum += data[i] * data[i];
1681 1681
1682 if (sum == 0) 1682 if (sum == 0)
1683 return 0; /* OOPS - division by zero */ 1683 return 0; /* OOPS - division by zero */
1684 1684
1685 return 0x20000000 / (t_sqrt(sum) >> 8); 1685 return 0x20000000 / (ff_t_sqrt(sum) >> 8);
1686 } 1686 }