summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmad/layer3.c
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmad/layer3.c') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/layer3.c232
1 files changed, 214 insertions, 18 deletions
diff --git a/core/multimedia/opieplayer/libmad/layer3.c b/core/multimedia/opieplayer/libmad/layer3.c
index 03f13fe..3c5dd9e 100644
--- a/core/multimedia/opieplayer/libmad/layer3.c
+++ b/core/multimedia/opieplayer/libmad/layer3.c
@@ -1,15 +1,15 @@
1/* 1/*
2 * libmad - MPEG audio decoder library 2 * libmad - MPEG audio decoder library
3 * Copyright (C) 2000-2001 Robert Leslie 3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
@@ -279,26 +279,26 @@ unsigned char const sfb_8000_long[] = {
279# define sfb_11025_short sfb_12000_short 279# define sfb_11025_short sfb_12000_short
280 280
281static 281static
282unsigned char const sfb_8000_short[] = { 282unsigned char const sfb_8000_short[] = {
283 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 16, 283 8, 8, 8, 8, 8, 8, 8, 8, 8, 12, 12, 12, 16,
284 16, 16, 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, 284 16, 16, 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36,
285 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26 285 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26
286}; 286};
287 287
288# define sfb_12000_mixed sfb_16000_mixed 288# define sfb_12000_mixed sfb_16000_mixed
289# define sfb_11025_mixed sfb_12000_mixed 289# define sfb_11025_mixed sfb_12000_mixed
290 290
291/* the 8000 Hz short block scalefactor bands do not break after the first 36 291/* the 8000 Hz short block scalefactor bands do not break after
292 frequency lines, so this is probably wrong */ 292 the first 36 frequency lines, so this is probably wrong */
293static 293static
294unsigned char const sfb_8000_mixed[] = { 294unsigned char const sfb_8000_mixed[] = {
295 /* long */ 12, 12, 12, 295 /* long */ 12, 12, 12,
296 /* short */ 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16, 296 /* short */ 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16,
297 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, 36, 297 20, 20, 20, 24, 24, 24, 28, 28, 28, 36, 36, 36,
298 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26 298 2, 2, 2, 2, 2, 2, 2, 2, 2, 26, 26, 26
299}; 299};
300 300
301static 301static
302struct { 302struct {
303 unsigned char const *l; 303 unsigned char const *l;
304 unsigned char const *s; 304 unsigned char const *s;
@@ -373,25 +373,25 @@ mad_fixed_t const cs[8] = {
373static 373static
374mad_fixed_t const ca[8] = { 374mad_fixed_t const ca[8] = {
375 -MAD_F(0x083b5fe7) /* -0.514495755 */, -MAD_F(0x078c36d2) /* -0.471731969 */, 375 -MAD_F(0x083b5fe7) /* -0.514495755 */, -MAD_F(0x078c36d2) /* -0.471731969 */,
376 -MAD_F(0x05039814) /* -0.313377454 */, -MAD_F(0x02e91dd1) /* -0.181913200 */, 376 -MAD_F(0x05039814) /* -0.313377454 */, -MAD_F(0x02e91dd1) /* -0.181913200 */,
377 -MAD_F(0x0183603a) /* -0.094574193 */, -MAD_F(0x00a7cb87) /* -0.040965583 */, 377 -MAD_F(0x0183603a) /* -0.094574193 */, -MAD_F(0x00a7cb87) /* -0.040965583 */,
378 -MAD_F(0x003a2847) /* -0.014198569 */, -MAD_F(0x000f27b4) /* -0.003699975 */ 378 -MAD_F(0x003a2847) /* -0.014198569 */, -MAD_F(0x000f27b4) /* -0.003699975 */
379}; 379};
380 380
381/* 381/*
382 * IMDCT coefficients for short blocks 382 * IMDCT coefficients for short blocks
383 * derived from section 2.4.3.4.10.2 of ISO/IEC 11172-3 383 * derived from section 2.4.3.4.10.2 of ISO/IEC 11172-3
384 * 384 *
385 * imdct_s[i/even][k] = cos((PI / 24) * (2 * (i / 2) + 7) * (2 * k + 1)) 385 * imdct_s[i/even][k] = cos((PI / 24) * (2 * (i / 2) + 7) * (2 * k + 1))
386 * imdct_s[i /odd][k] = cos((PI / 24) * (2 * (6 + (i-1)/2) + 7) * (2 * k + 1)) 386 * imdct_s[i /odd][k] = cos((PI / 24) * (2 * (6 + (i-1)/2) + 7) * (2 * k + 1))
387 */ 387 */
388static 388static
389mad_fixed_t const imdct_s[6][6] = { 389mad_fixed_t const imdct_s[6][6] = {
390# include "imdct_s.dat" 390# include "imdct_s.dat"
391}; 391};
392 392
393# if !defined(ASO_IMDCT) 393# if !defined(ASO_IMDCT)
394/* 394/*
395 * windowing coefficients for long blocks 395 * windowing coefficients for long blocks
396 * derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3 396 * derived from section 2.4.3.4.10.3 of ISO/IEC 11172-3
397 * 397 *
@@ -452,25 +452,25 @@ mad_fixed_t const is_table[7] = {
452 MAD_F(0x05db3d74) /* 0.366025404 */, 452 MAD_F(0x05db3d74) /* 0.366025404 */,
453 MAD_F(0x08000000) /* 0.500000000 */, 453 MAD_F(0x08000000) /* 0.500000000 */,
454 MAD_F(0x0a24c28c) /* 0.633974596 */, 454 MAD_F(0x0a24c28c) /* 0.633974596 */,
455 MAD_F(0x0c9e69d1) /* 0.788675135 */, 455 MAD_F(0x0c9e69d1) /* 0.788675135 */,
456 MAD_F(0x10000000) /* 1.000000000 */ 456 MAD_F(0x10000000) /* 1.000000000 */
457}; 457};
458 458
459/* 459/*
460 * coefficients for LSF intensity stereo processing 460 * coefficients for LSF intensity stereo processing
461 * derived from section 2.4.3.2 of ISO/IEC 13818-3 461 * derived from section 2.4.3.2 of ISO/IEC 13818-3
462 * 462 *
463 * is_lsf_table[0][i] = (1 / sqrt(sqrt(2)))^(i + 1) 463 * is_lsf_table[0][i] = (1 / sqrt(sqrt(2)))^(i + 1)
464 * is_lsf_table[1][i] = (1 / sqrt(2))^(i + 1) 464 * is_lsf_table[1][i] = (1 / sqrt(2)) ^(i + 1)
465 */ 465 */
466static 466static
467mad_fixed_t const is_lsf_table[2][15] = { 467mad_fixed_t const is_lsf_table[2][15] = {
468 { 468 {
469 MAD_F(0x0d744fcd) /* 0.840896415 */, 469 MAD_F(0x0d744fcd) /* 0.840896415 */,
470 MAD_F(0x0b504f33) /* 0.707106781 */, 470 MAD_F(0x0b504f33) /* 0.707106781 */,
471 MAD_F(0x09837f05) /* 0.594603558 */, 471 MAD_F(0x09837f05) /* 0.594603558 */,
472 MAD_F(0x08000000) /* 0.500000000 */, 472 MAD_F(0x08000000) /* 0.500000000 */,
473 MAD_F(0x06ba27e6) /* 0.420448208 */, 473 MAD_F(0x06ba27e6) /* 0.420448208 */,
474 MAD_F(0x05a8279a) /* 0.353553391 */, 474 MAD_F(0x05a8279a) /* 0.353553391 */,
475 MAD_F(0x04c1bf83) /* 0.297301779 */, 475 MAD_F(0x04c1bf83) /* 0.297301779 */,
476 MAD_F(0x04000000) /* 0.250000000 */, 476 MAD_F(0x04000000) /* 0.250000000 */,
@@ -1566,24 +1566,211 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines)
1566 1566
1567 xr[ i] = MAD_F_MLZ(hi, lo); 1567 xr[ i] = MAD_F_MLZ(hi, lo);
1568# if defined(ASO_ZEROCHECK) 1568# if defined(ASO_ZEROCHECK)
1569 } 1569 }
1570# endif 1570# endif
1571 } 1571 }
1572 } 1572 }
1573} 1573}
1574 1574
1575# if defined(ASO_IMDCT) 1575# if defined(ASO_IMDCT)
1576void III_imdct_l(mad_fixed_t const [18], mad_fixed_t [36], unsigned int); 1576void III_imdct_l(mad_fixed_t const [18], mad_fixed_t [36], unsigned int);
1577# else 1577# else
1578# if 1
1579static
1580void fastsdct(mad_fixed_t const x[9], mad_fixed_t y[18])
1581{
1582 mad_fixed_t a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12;
1583 mad_fixed_t a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25;
1584 mad_fixed_t m0, m1, m2, m3, m4, m5, m6, m7;
1585
1586 enum {
1587 c0 = MAD_F(0x1f838b8d), /* 2 * cos( 1 * PI / 18) */
1588 c1 = MAD_F(0x1bb67ae8), /* 2 * cos( 3 * PI / 18) */
1589 c2 = MAD_F(0x18836fa3), /* 2 * cos( 4 * PI / 18) */
1590 c3 = MAD_F(0x1491b752), /* 2 * cos( 5 * PI / 18) */
1591 c4 = MAD_F(0x0af1d43a), /* 2 * cos( 7 * PI / 18) */
1592 c5 = MAD_F(0x058e86a0), /* 2 * cos( 8 * PI / 18) */
1593 c6 = -MAD_F(0x1e11f642) /* 2 * cos(16 * PI / 18) */
1594 };
1595
1596 a0 = x[3] + x[5];
1597 a1 = x[3] - x[5];
1598 a2 = x[6] + x[2];
1599 a3 = x[6] - x[2];
1600 a4 = x[1] + x[7];
1601 a5 = x[1] - x[7];
1602 a6 = x[8] + x[0];
1603 a7 = x[8] - x[0];
1604
1605 a8 = a0 + a2;
1606 a9 = a0 - a2;
1607 a10 = a0 - a6;
1608 a11 = a2 - a6;
1609 a12 = a8 + a6;
1610 a13 = a1 - a3;
1611 a14 = a13 + a7;
1612 a15 = a3 + a7;
1613 a16 = a1 - a7;
1614 a17 = a1 + a3;
1615
1616 m0 = mad_f_mul(a17, -c3);
1617 m1 = mad_f_mul(a16, -c0);
1618 m2 = mad_f_mul(a15, -c4);
1619 m3 = mad_f_mul(a14, -c1);
1620 m4 = mad_f_mul(a5, -c1);
1621 m5 = mad_f_mul(a11, -c6);
1622 m6 = mad_f_mul(a10, -c5);
1623 m7 = mad_f_mul(a9, -c2);
1624
1625 a18 = x[4] + a4;
1626 a19 = 2 * x[4] - a4;
1627 a20 = a19 + m5;
1628 a21 = a19 - m5;
1629 a22 = a19 + m6;
1630 a23 = m4 + m2;
1631 a24 = m4 - m2;
1632 a25 = m4 + m1;
1633
1634 /* output to every other slot for convenience */
1635
1636 y[ 0] = a18 + a12;
1637 y[ 2] = m0 - a25;
1638 y[ 4] = m7 - a20;
1639 y[ 6] = m3;
1640 y[ 8] = a21 - m6;
1641 y[10] = a24 - m1;
1642 y[12] = a12 - 2 * a18;
1643 y[14] = a23 + m0;
1644 y[16] = a22 + m7;
1645}
1646
1647static inline
1648void sdctII(mad_fixed_t const x[18], mad_fixed_t X[18])
1649{
1650 mad_fixed_t tmp[9];
1651 int i;
1652
1653 /* scale[i] = 2 * cos(PI * (2 * i + 1) / (2 * 18)) */
1654 static mad_fixed_t const scale[9] = {
1655 MAD_F(0x1fe0d3b4), MAD_F(0x1ee8dd47), MAD_F(0x1d007930),
1656 MAD_F(0x1a367e59), MAD_F(0x16a09e66), MAD_F(0x125abcf8),
1657 MAD_F(0x0d8616bc), MAD_F(0x08483ee1), MAD_F(0x02c9fad7)
1658 };
1659
1660 /* divide the 18-point SDCT-II into two 9-point SDCT-IIs */
1661
1662 /* even input butterfly */
1663
1664 for (i = 0; i < 9; i += 3) {
1665 tmp[i + 0] = x[i + 0] + x[18 - (i + 0) - 1];
1666 tmp[i + 1] = x[i + 1] + x[18 - (i + 1) - 1];
1667 tmp[i + 2] = x[i + 2] + x[18 - (i + 2) - 1];
1668 }
1669
1670 fastsdct(tmp, &X[0]);
1671
1672 /* odd input butterfly and scaling */
1673
1674 for (i = 0; i < 9; i += 3) {
1675 tmp[i + 0] = mad_f_mul(x[i + 0] - x[18 - (i + 0) - 1], scale[i + 0]);
1676 tmp[i + 1] = mad_f_mul(x[i + 1] - x[18 - (i + 1) - 1], scale[i + 1]);
1677 tmp[i + 2] = mad_f_mul(x[i + 2] - x[18 - (i + 2) - 1], scale[i + 2]);
1678 }
1679
1680 fastsdct(tmp, &X[1]);
1681
1682 /* output accumulation */
1683
1684 for (i = 3; i < 18; i += 8) {
1685 X[i + 0] -= X[(i + 0) - 2];
1686 X[i + 2] -= X[(i + 2) - 2];
1687 X[i + 4] -= X[(i + 4) - 2];
1688 X[i + 6] -= X[(i + 6) - 2];
1689 }
1690}
1691
1692static inline
1693void dctIV(mad_fixed_t const y[18], mad_fixed_t X[18])
1694{
1695 mad_fixed_t tmp[18];
1696 int i;
1697
1698 /* scale[i] = 2 * cos(PI * (2 * i + 1) / (4 * 18)) */
1699 static mad_fixed_t const scale[18] = {
1700 MAD_F(0x1ff833fa), MAD_F(0x1fb9ea93), MAD_F(0x1f3dd120),
1701 MAD_F(0x1e84d969), MAD_F(0x1d906bcf), MAD_F(0x1c62648b),
1702 MAD_F(0x1afd100f), MAD_F(0x1963268b), MAD_F(0x1797c6a4),
1703 MAD_F(0x159e6f5b), MAD_F(0x137af940), MAD_F(0x11318ef3),
1704 MAD_F(0x0ec6a507), MAD_F(0x0c3ef153), MAD_F(0x099f61c5),
1705 MAD_F(0x06ed12c5), MAD_F(0x042d4544), MAD_F(0x0165547c)
1706 };
1707
1708 /* scaling */
1709
1710 for (i = 0; i < 18; i += 3) {
1711 tmp[i + 0] = mad_f_mul(y[i + 0], scale[i + 0]);
1712 tmp[i + 1] = mad_f_mul(y[i + 1], scale[i + 1]);
1713 tmp[i + 2] = mad_f_mul(y[i + 2], scale[i + 2]);
1714 }
1715
1716 /* SDCT-II */
1717
1718 sdctII(tmp, X);
1719
1720 /* scale reduction and output accumulation */
1721
1722 X[0] /= 2;
1723 for (i = 1; i < 17; i += 4) {
1724 X[i + 0] = X[i + 0] / 2 - X[(i + 0) - 1];
1725 X[i + 1] = X[i + 1] / 2 - X[(i + 1) - 1];
1726 X[i + 2] = X[i + 2] / 2 - X[(i + 2) - 1];
1727 X[i + 3] = X[i + 3] / 2 - X[(i + 3) - 1];
1728 }
1729 X[17] = X[17] / 2 - X[16];
1730}
1731
1732/*
1733 * NAME:imdct36
1734 * DESCRIPTION:perform X[18]->x[36] IMDCT using Szu-Wei Lee's fast algorithm
1735 */
1736static inline
1737void imdct36(mad_fixed_t const x[18], mad_fixed_t y[36])
1738{
1739 mad_fixed_t tmp[18];
1740 int i;
1741
1742 /* DCT-IV */
1743
1744 dctIV(x, tmp);
1745
1746 /* convert 18-point DCT-IV to 36-point IMDCT */
1747
1748 for (i = 0; i < 9; i += 3) {
1749 y[i + 0] = tmp[9 + (i + 0)];
1750 y[i + 1] = tmp[9 + (i + 1)];
1751 y[i + 2] = tmp[9 + (i + 2)];
1752 }
1753 for (i = 9; i < 27; i += 3) {
1754 y[i + 0] = -tmp[36 - (9 + (i + 0)) - 1];
1755 y[i + 1] = -tmp[36 - (9 + (i + 1)) - 1];
1756 y[i + 2] = -tmp[36 - (9 + (i + 2)) - 1];
1757 }
1758 for (i = 27; i < 36; i += 3) {
1759 y[i + 0] = -tmp[(i + 0) - 27];
1760 y[i + 1] = -tmp[(i + 1) - 27];
1761 y[i + 2] = -tmp[(i + 2) - 27];
1762 }
1763}
1764# else
1578/* 1765/*
1579 * NAME:imdct36 1766 * NAME:imdct36
1580 * DESCRIPTION:perform X[18]->x[36] IMDCT 1767 * DESCRIPTION:perform X[18]->x[36] IMDCT
1581 */ 1768 */
1582static inline 1769static inline
1583void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36]) 1770void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36])
1584{ 1771{
1585 mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; 1772 mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7;
1586 mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; 1773 mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15;
1587 register mad_fixed64hi_t hi; 1774 register mad_fixed64hi_t hi;
1588 register mad_fixed64lo_t lo; 1775 register mad_fixed64lo_t lo;
1589 1776
@@ -1856,24 +2043,25 @@ void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36])
1856 MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0e313245)); 2043 MAD_F_MLA(hi, lo, X[5], -MAD_F(0x0e313245));
1857 MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0d7e8807)); 2044 MAD_F_MLA(hi, lo, X[6], -MAD_F(0x0d7e8807));
1858 MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0bcbe352)); 2045 MAD_F_MLA(hi, lo, X[8], -MAD_F(0x0bcbe352));
1859 MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0acf37ad)); 2046 MAD_F_MLA(hi, lo, X[9], -MAD_F(0x0acf37ad));
1860 MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0898c779)); 2047 MAD_F_MLA(hi, lo, X[11], -MAD_F(0x0898c779));
1861 MAD_F_MLA(hi, lo, X[12], -MAD_F(0x07635284)); 2048 MAD_F_MLA(hi, lo, X[12], -MAD_F(0x07635284));
1862 MAD_F_MLA(hi, lo, X[14], -MAD_F(0x04cfb0e2)); 2049 MAD_F_MLA(hi, lo, X[14], -MAD_F(0x04cfb0e2));
1863 MAD_F_MLA(hi, lo, X[15], -MAD_F(0x03768962)); 2050 MAD_F_MLA(hi, lo, X[15], -MAD_F(0x03768962));
1864 MAD_F_MLA(hi, lo, X[17], -MAD_F(0x00b2aa3e)); 2051 MAD_F_MLA(hi, lo, X[17], -MAD_F(0x00b2aa3e));
1865 2052
1866 x[26] = x[27] = MAD_F_MLZ(hi, lo) + t5; 2053 x[26] = x[27] = MAD_F_MLZ(hi, lo) + t5;
1867} 2054}
2055# endif
1868 2056
1869/* 2057/*
1870 * NAME:III_imdct_l() 2058 * NAME:III_imdct_l()
1871 * DESCRIPTION:perform IMDCT and windowing for long blocks 2059 * DESCRIPTION:perform IMDCT and windowing for long blocks
1872 */ 2060 */
1873static 2061static
1874void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36], 2062void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36],
1875 unsigned int block_type) 2063 unsigned int block_type)
1876{ 2064{
1877 unsigned int i; 2065 unsigned int i;
1878 2066
1879 /* IMDCT */ 2067 /* IMDCT */
@@ -1920,35 +2108,43 @@ void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36],
1920 for (i = 0; i < 36; i += 4) { 2108 for (i = 0; i < 36; i += 4) {
1921 z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]); 2109 z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]);
1922 z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]); 2110 z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]);
1923 z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]); 2111 z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]);
1924 z[i + 3] = mad_f_mul(z[i + 3], window_l[i + 3]); 2112 z[i + 3] = mad_f_mul(z[i + 3], window_l[i + 3]);
1925 } 2113 }
1926# else 2114# else
1927 for (i = 0; i < 36; ++i) z[i] = mad_f_mul(z[i], window_l[i]); 2115 for (i = 0; i < 36; ++i) z[i] = mad_f_mul(z[i], window_l[i]);
1928# endif 2116# endif
1929 break; 2117 break;
1930 2118
1931 case 1: /* start block */ 2119 case 1: /* start block */
1932 for (i = 0; i < 18; ++i) z[i] = mad_f_mul(z[i], window_l[i]); 2120 for (i = 0; i < 18; i += 3) {
2121 z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]);
2122 z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]);
2123 z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]);
2124 }
1933 /* (i = 18; i < 24; ++i) z[i] unchanged */ 2125 /* (i = 18; i < 24; ++i) z[i] unchanged */
1934 for (i = 24; i < 30; ++i) z[i] = mad_f_mul(z[i], window_s[i - 18]); 2126 for (i = 24; i < 30; ++i) z[i] = mad_f_mul(z[i], window_s[i - 18]);
1935 for (i = 30; i < 36; ++i) z[i] = 0; 2127 for (i = 30; i < 36; ++i) z[i] = 0;
1936 break; 2128 break;
1937 2129
1938 case 3: /* stop block */ 2130 case 3: /* stop block */
1939 for (i = 0; i < 6; ++i) z[i] = 0; 2131 for (i = 0; i < 6; ++i) z[i] = 0;
1940 for (i = 6; i < 12; ++i) z[i] = mad_f_mul(z[i], window_s[i - 6]); 2132 for (i = 6; i < 12; ++i) z[i] = mad_f_mul(z[i], window_s[i - 6]);
1941 /* (i = 12; i < 18; ++i) z[i] unchanged */ 2133 /* (i = 12; i < 18; ++i) z[i] unchanged */
1942 for (i = 18; i < 36; ++i) z[i] = mad_f_mul(z[i], window_l[i]); 2134 for (i = 18; i < 36; i += 3) {
2135 z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]);
2136 z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]);
2137 z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]);
2138 }
1943 break; 2139 break;
1944 } 2140 }
1945} 2141}
1946# endif /* ASO_IMDCT */ 2142# endif /* ASO_IMDCT */
1947 2143
1948/* 2144/*
1949 * NAME:III_imdct_s() 2145 * NAME:III_imdct_s()
1950 * DESCRIPTION:perform IMDCT and windowing for short blocks 2146 * DESCRIPTION:perform IMDCT and windowing for short blocks
1951 */ 2147 */
1952static 2148static
1953void III_imdct_s(mad_fixed_t const X[18], mad_fixed_t z[36]) 2149void III_imdct_s(mad_fixed_t const X[18], mad_fixed_t z[36])
1954{ 2150{
@@ -2033,49 +2229,49 @@ void III_overlap(mad_fixed_t const output[36], mad_fixed_t overlap[18],
2033 mad_fixed_t sample[18][32], unsigned int sb) 2229 mad_fixed_t sample[18][32], unsigned int sb)
2034{ 2230{
2035 unsigned int i; 2231 unsigned int i;
2036 2232
2037# if defined(ASO_INTERLEAVE2) 2233# if defined(ASO_INTERLEAVE2)
2038 { 2234 {
2039 register mad_fixed_t tmp1, tmp2; 2235 register mad_fixed_t tmp1, tmp2;
2040 2236
2041 tmp1 = overlap[0]; 2237 tmp1 = overlap[0];
2042 tmp2 = overlap[1]; 2238 tmp2 = overlap[1];
2043 2239
2044 for (i = 0; i < 16; i += 2) { 2240 for (i = 0; i < 16; i += 2) {
2045 sample[i + 0][sb] = output[i + 0] + tmp1; 2241 sample[i + 0][sb] = output[i + 0 + 0] + tmp1;
2046 overlap[i + 0] = output[i + 0 + 18]; 2242 overlap[i + 0] = output[i + 0 + 18];
2047 tmp1 = overlap[i + 2]; 2243 tmp1 = overlap[i + 2];
2048 2244
2049 sample[i + 1][sb] = output[i + 1] + tmp2; 2245 sample[i + 1][sb] = output[i + 1 + 0] + tmp2;
2050 overlap[i + 1] = output[i + 1 + 18]; 2246 overlap[i + 1] = output[i + 1 + 18];
2051 tmp2 = overlap[i + 3]; 2247 tmp2 = overlap[i + 3];
2052 } 2248 }
2053 2249
2054 sample[16][sb] = output[16] + tmp1; 2250 sample[16][sb] = output[16 + 0] + tmp1;
2055 overlap[16] = output[16 + 18]; 2251 overlap[16] = output[16 + 18];
2056 sample[17][sb] = output[17] + tmp2; 2252 sample[17][sb] = output[17 + 0] + tmp2;
2057 overlap[17] = output[17 + 18]; 2253 overlap[17] = output[17 + 18];
2058 } 2254 }
2059# elif 0 2255# elif 0
2060 for (i = 0; i < 18; i += 2) { 2256 for (i = 0; i < 18; i += 2) {
2061 sample[i + 0][sb] = output[i + 0] + overlap[i + 0]; 2257 sample[i + 0][sb] = output[i + 0 + 0] + overlap[i + 0];
2062 overlap[i + 0] = output[i + 0 + 18]; 2258 overlap[i + 0] = output[i + 0 + 18];
2063 2259
2064 sample[i + 1][sb] = output[i + 1] + overlap[i + 1]; 2260 sample[i + 1][sb] = output[i + 1 + 0] + overlap[i + 1];
2065 overlap[i + 1] = output[i + 1 + 18]; 2261 overlap[i + 1] = output[i + 1 + 18];
2066 } 2262 }
2067# else 2263# else
2068 for (i = 0; i < 18; ++i) { 2264 for (i = 0; i < 18; ++i) {
2069 sample[i][sb] = output[i] + overlap[i]; 2265 sample[i][sb] = output[i + 0] + overlap[i];
2070 overlap[i] = output[i + 18]; 2266 overlap[i] = output[i + 18];
2071 } 2267 }
2072# endif 2268# endif
2073} 2269}
2074 2270
2075/* 2271/*
2076 * NAME:III_overlap_z() 2272 * NAME:III_overlap_z()
2077 * DESCRIPTION:perform "overlap-add" of zero IMDCT outputs 2273 * DESCRIPTION:perform "overlap-add" of zero IMDCT outputs
2078 */ 2274 */
2079static inline 2275static inline
2080void III_overlap_z(mad_fixed_t overlap[18], 2276void III_overlap_z(mad_fixed_t overlap[18],
2081 mad_fixed_t sample[18][32], unsigned int sb) 2277 mad_fixed_t sample[18][32], unsigned int sb)
@@ -2445,30 +2641,30 @@ int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame)
2445 } 2641 }
2446 2642
2447 frame_free = frame_space - frame_used; 2643 frame_free = frame_space - frame_used;
2448 2644
2449 /* decode main_data */ 2645 /* decode main_data */
2450 2646
2451 if (result == 0) { 2647 if (result == 0) {
2452 error = III_decode(&ptr, frame, &si, nch); 2648 error = III_decode(&ptr, frame, &si, nch);
2453 if (error) { 2649 if (error) {
2454 stream->error = error; 2650 stream->error = error;
2455 result = -1; 2651 result = -1;
2456 } 2652 }
2457 }
2458 2653
2459 /* designate ancillary bits */ 2654 /* designate ancillary bits */
2460 2655
2461 stream->anc_ptr = ptr; 2656 stream->anc_ptr = ptr;
2462 stream->anc_bitlen = md_len * CHAR_BIT - data_bitlen; 2657 stream->anc_bitlen = md_len * CHAR_BIT - data_bitlen;
2658 }
2463 2659
2464# if 0 && defined(DEBUG) 2660# if 0 && defined(DEBUG)
2465 fprintf(stderr, 2661 fprintf(stderr,
2466 "main_data_begin:%u, md_len:%u, frame_free:%u, " 2662 "main_data_begin:%u, md_len:%u, frame_free:%u, "
2467 "data_bitlen:%u, anc_bitlen: %u\n", 2663 "data_bitlen:%u, anc_bitlen: %u\n",
2468 si.main_data_begin, md_len, frame_free, 2664 si.main_data_begin, md_len, frame_free,
2469 data_bitlen, stream->anc_bitlen); 2665 data_bitlen, stream->anc_bitlen);
2470# endif 2666# endif
2471 2667
2472 /* preload main_data buffer with up to 511 bytes for next frame(s) */ 2668 /* preload main_data buffer with up to 511 bytes for next frame(s) */
2473 2669
2474 if (frame_free >= next_md_begin) { 2670 if (frame_free >= next_md_begin) {