ReactOS 0.4.15-dev-8417-gb6b82fe
layer3.c File Reference
#include "mpg123lib_intern.h"
#include "huffman.h"
#include "getbits.h"
#include "debug.h"
Include dependency graph for layer3.c:

Go to the source code of this file.

Classes

struct  III_sideinfo
 
struct  bandInfoStruct
 

Macros

#define NEW_DCT9
 
#define MASK_STYPE   int32_t
 
#define MASK_UTYPE   uint32_t
 
#define MASK_TYPE   MASK_UTYPE
 
#define MSB_MASK   ((MASK_UTYPE)mask & (MASK_UTYPE)1<<(sizeof(MASK_TYPE)*8-1))
 
#define BITSHIFT   ((sizeof(MASK_TYPE)-1)*8)
 
#define REFRESH_MASK
 
#define CHECK_XRPNT
 
#define MACRO(v)
 
#define DCT12_PART1
 
#define DCT12_PART2
 

Functions

static ALIGNED (16)
 
real init_layer3_gainpow2 (mpg123_handle *fr, int i)
 
void init_layer3 (void)
 
void init_layer3_stuff (mpg123_handle *fr, real(*gainpow2)(mpg123_handle *fr, int i))
 
static int III_get_side_info (mpg123_handle *fr, struct III_sideinfo *si, int stereo, int ms_stereo, long sfreq, int single)
 
static int III_get_scale_factors_1 (mpg123_handle *fr, int *scf, struct gr_info_s *gr_info, int ch, int gr)
 
static int III_get_scale_factors_2 (mpg123_handle *fr, int *scf, struct gr_info_s *gr_info, int i_stereo)
 
static int III_dequantize_sample (mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT], int *scf, struct gr_info_s *gr_info, int sfreq, int part2bits)
 
static void III_i_stereo (real xr_buf[2][SBLIMIT][SSLIMIT], int *scalefac, struct gr_info_s *gr_info, int sfreq, int ms_stereo, int lsf)
 
static void III_antialias (real xr[SBLIMIT][SSLIMIT], struct gr_info_s *gr_info)
 
void dct36 (real *inbuf, real *o1, real *o2, real *wintab, real *tsbuf)
 
static void dct12 (real *in, real *rawout1, real *rawout2, register real *wi, register real *ts)
 
static void III_hybrid (real fsIn[SBLIMIT][SSLIMIT], real tsOut[SSLIMIT][SBLIMIT], int ch, struct gr_info_s *gr_info, mpg123_handle *fr)
 
static void fill_pinfo_side (mpg123_handle *fr, struct III_sideinfo *si, int gr, int stereo1)
 
int do_layer3 (mpg123_handle *fr)
 

Variables

static real ispow [8207]
 
static real aa_ca [8]
 
static real aa_cs [8]
 
static const struct bandInfoStruct bandInfo [9]
 
static int mapbuf0 [9][152]
 
static int mapbuf1 [9][156]
 
static int mapbuf2 [9][44]
 
static intmap [9][3]
 
static intmapend [9][3]
 
static unsigned int n_slen2 [512]
 
static unsigned int i_slen2 [256]
 
static unsigned char pretab_choice [2][22]
 

Macro Definition Documentation

◆ BITSHIFT

#define BITSHIFT   ((sizeof(MASK_TYPE)-1)*8)

Definition at line 787 of file layer3.c.

◆ CHECK_XRPNT

#define CHECK_XRPNT
Value:
if(xrpnt >= &xr[SBLIMIT][0]) \
{ \
if(NOQUIET) \
error2("attempted xrpnt overflow (%p !< %p)", (void*) xrpnt, (void*) &xr[SBLIMIT][0]); \
return 1; \
}
#define SBLIMIT
#define NOQUIET

◆ DCT12_PART1

#define DCT12_PART1
Value:
in5 = in[5*3]; \
in5 += (in4 = in[4*3]); \
in4 += (in3 = in[3*3]); \
in3 += (in2 = in[2*3]); \
in2 += (in1 = in[1*3]); \
in1 += (in0 = in[0*3]); \
\
in5 += in3; in3 += in1; \
\
in2 = REAL_MUL(in2, COS6_1); \
in3 = REAL_MUL(in3, COS6_1);
GLuint in
Definition: glext.h:9616
static real COS6_1
#define REAL_MUL(x, y)

◆ DCT12_PART2

#define DCT12_PART2
Value:
in0 += REAL_MUL(in4, COS6_2); \
\
in4 = in0 + in2; \
in0 -= in2; \
\
in1 += REAL_MUL(in5, COS6_2); \
\
in5 = REAL_MUL((in1 + in3), tfcos12[0]); \
in1 = REAL_MUL((in1 - in3), tfcos12[2]); \
\
in3 = in4 + in5; \
in4 -= in5; \
\
in2 = in0 + in1; \
in0 -= in1;
static real COS6_2
static real tfcos12[3]

◆ MACRO

#define MACRO (   v)
Value:
{ \
real tmpval; \
tmpval = tmp[(v)] + tmp[17-(v)]; \
out2[9+(v)] = REAL_MUL(tmpval, w[27+(v)]); \
out2[8-(v)] = REAL_MUL(tmpval, w[26-(v)]); \
tmpval = tmp[(v)] - tmp[17-(v)]; \
ts[SBLIMIT*(8-(v))] = out1[8-(v)] + REAL_MUL(tmpval, w[8-(v)]); \
ts[SBLIMIT*(9+(v))] = out1[9+(v)] + REAL_MUL(tmpval, w[9+(v)]); }
const GLdouble * v
Definition: gl.h:2040
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define real

◆ MASK_STYPE

#define MASK_STYPE   int32_t

Definition at line 782 of file layer3.c.

◆ MASK_TYPE

#define MASK_TYPE   MASK_UTYPE

Definition at line 784 of file layer3.c.

◆ MASK_UTYPE

#define MASK_UTYPE   uint32_t

Definition at line 783 of file layer3.c.

◆ MSB_MASK

#define MSB_MASK   ((MASK_UTYPE)mask & (MASK_UTYPE)1<<(sizeof(MASK_TYPE)*8-1))

Definition at line 785 of file layer3.c.

◆ NEW_DCT9

#define NEW_DCT9

◆ REFRESH_MASK

#define REFRESH_MASK
Value:
while(num < BITSHIFT) { \
num += 8; \
part2remain -= 8; }
#define getbyte(fr)
Definition: getbits.h:28
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint GLuint num
Definition: glext.h:9618
#define BITSHIFT
Definition: layer3.c:787
#define MASK_UTYPE
Definition: layer3.c:783

Definition at line 788 of file layer3.c.

Function Documentation

◆ ALIGNED()

static ALIGNED ( 16  )
static

Definition at line 40 of file layer3.c.

57{
58 int scfsi;
59 unsigned part2_3_length;
60 unsigned big_values;
61 unsigned scalefac_compress;
62 unsigned block_type;
63 unsigned mixed_block_flag;
64 unsigned table_select[3];
65 /* Making those two signed int as workaround for open64/pathscale/sun compilers, and also for consistency, since they're worked on together with other signed variables. */
66 int maxband[3];
67 int maxbandl;
68 unsigned maxb;
69 unsigned region1start;
70 unsigned region2start;
71 unsigned preflag;
72 unsigned scalefac_scale;
73 unsigned count1table_select;
74 real *full_gain[3];
75 real *pow2gain;
76};

◆ dct12()

static void dct12 ( real in,
real rawout1,
real rawout2,
register real wi,
register real ts 
)
static

Definition at line 1838 of file layer3.c.

1839{
1840#define DCT12_PART1 \
1841 in5 = in[5*3]; \
1842 in5 += (in4 = in[4*3]); \
1843 in4 += (in3 = in[3*3]); \
1844 in3 += (in2 = in[2*3]); \
1845 in2 += (in1 = in[1*3]); \
1846 in1 += (in0 = in[0*3]); \
1847 \
1848 in5 += in3; in3 += in1; \
1849 \
1850 in2 = REAL_MUL(in2, COS6_1); \
1851 in3 = REAL_MUL(in3, COS6_1);
1852
1853#define DCT12_PART2 \
1854 in0 += REAL_MUL(in4, COS6_2); \
1855 \
1856 in4 = in0 + in2; \
1857 in0 -= in2; \
1858 \
1859 in1 += REAL_MUL(in5, COS6_2); \
1860 \
1861 in5 = REAL_MUL((in1 + in3), tfcos12[0]); \
1862 in1 = REAL_MUL((in1 - in3), tfcos12[2]); \
1863 \
1864 in3 = in4 + in5; \
1865 in4 -= in5; \
1866 \
1867 in2 = in0 + in1; \
1868 in0 -= in1;
1869
1870 {
1871 real in0,in1,in2,in3,in4,in5;
1872 register real *out1 = rawout1;
1873 ts[SBLIMIT*0] = out1[0]; ts[SBLIMIT*1] = out1[1]; ts[SBLIMIT*2] = out1[2];
1874 ts[SBLIMIT*3] = out1[3]; ts[SBLIMIT*4] = out1[4]; ts[SBLIMIT*5] = out1[5];
1875
1877
1878 {
1879 real tmp0,tmp1 = (in0 - in4);
1880 {
1881 real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]);
1882 tmp0 = tmp1 + tmp2;
1883 tmp1 -= tmp2;
1884 }
1885 ts[(17-1)*SBLIMIT] = out1[17-1] + REAL_MUL(tmp0, wi[11-1]);
1886 ts[(12+1)*SBLIMIT] = out1[12+1] + REAL_MUL(tmp0, wi[6+1]);
1887 ts[(6 +1)*SBLIMIT] = out1[6 +1] + REAL_MUL(tmp1, wi[1]);
1888 ts[(11-1)*SBLIMIT] = out1[11-1] + REAL_MUL(tmp1, wi[5-1]);
1889 }
1890
1892
1893 ts[(17-0)*SBLIMIT] = out1[17-0] + REAL_MUL(in2, wi[11-0]);
1894 ts[(12+0)*SBLIMIT] = out1[12+0] + REAL_MUL(in2, wi[6+0]);
1895 ts[(12+2)*SBLIMIT] = out1[12+2] + REAL_MUL(in3, wi[6+2]);
1896 ts[(17-2)*SBLIMIT] = out1[17-2] + REAL_MUL(in3, wi[11-2]);
1897
1898 ts[(6 +0)*SBLIMIT] = out1[6+0] + REAL_MUL(in0, wi[0]);
1899 ts[(11-0)*SBLIMIT] = out1[11-0] + REAL_MUL(in0, wi[5-0]);
1900 ts[(6 +2)*SBLIMIT] = out1[6+2] + REAL_MUL(in4, wi[2]);
1901 ts[(11-2)*SBLIMIT] = out1[11-2] + REAL_MUL(in4, wi[5-2]);
1902 }
1903
1904 in++;
1905
1906 {
1907 real in0,in1,in2,in3,in4,in5;
1908 register real *out2 = rawout2;
1909
1911
1912 {
1913 real tmp0,tmp1 = (in0 - in4);
1914 {
1915 real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]);
1916 tmp0 = tmp1 + tmp2;
1917 tmp1 -= tmp2;
1918 }
1919 out2[5-1] = REAL_MUL(tmp0, wi[11-1]);
1920 out2[0+1] = REAL_MUL(tmp0, wi[6+1]);
1921 ts[(12+1)*SBLIMIT] += REAL_MUL(tmp1, wi[1]);
1922 ts[(17-1)*SBLIMIT] += REAL_MUL(tmp1, wi[5-1]);
1923 }
1924
1926
1927 out2[5-0] = REAL_MUL(in2, wi[11-0]);
1928 out2[0+0] = REAL_MUL(in2, wi[6+0]);
1929 out2[0+2] = REAL_MUL(in3, wi[6+2]);
1930 out2[5-2] = REAL_MUL(in3, wi[11-2]);
1931
1932 ts[(12+0)*SBLIMIT] += REAL_MUL(in0, wi[0]);
1933 ts[(17-0)*SBLIMIT] += REAL_MUL(in0, wi[5-0]);
1934 ts[(12+2)*SBLIMIT] += REAL_MUL(in4, wi[2]);
1935 ts[(17-2)*SBLIMIT] += REAL_MUL(in4, wi[5-2]);
1936 }
1937
1938 in++;
1939
1940 {
1941 real in0,in1,in2,in3,in4,in5;
1942 register real *out2 = rawout2;
1943 out2[12]=out2[13]=out2[14]=out2[15]=out2[16]=out2[17]=0.0;
1944
1946
1947 {
1948 real tmp0,tmp1 = (in0 - in4);
1949 {
1950 real tmp2 = REAL_MUL((in1 - in5), tfcos12[1]);
1951 tmp0 = tmp1 + tmp2;
1952 tmp1 -= tmp2;
1953 }
1954 out2[11-1] = REAL_MUL(tmp0, wi[11-1]);
1955 out2[6 +1] = REAL_MUL(tmp0, wi[6+1]);
1956 out2[0+1] += REAL_MUL(tmp1, wi[1]);
1957 out2[5-1] += REAL_MUL(tmp1, wi[5-1]);
1958 }
1959
1961
1962 out2[11-0] = REAL_MUL(in2, wi[11-0]);
1963 out2[6 +0] = REAL_MUL(in2, wi[6+0]);
1964 out2[6 +2] = REAL_MUL(in3, wi[6+2]);
1965 out2[11-2] = REAL_MUL(in3, wi[11-2]);
1966
1967 out2[0+0] += REAL_MUL(in0, wi[0]);
1968 out2[5-0] += REAL_MUL(in0, wi[5-0]);
1969 out2[0+2] += REAL_MUL(in4, wi[2]);
1970 out2[5-2] += REAL_MUL(in4, wi[5-2]);
1971 }
1972}
#define DCT12_PART1
#define DCT12_PART2

Referenced by III_hybrid().

◆ dct36()

void dct36 ( real inbuf,
real o1,
real o2,
real wintab,
real tsbuf 
)

Definition at line 1554 of file layer3.c.

1555{
1556#ifdef NEW_DCT9
1557 real tmp[18];
1558#endif
1559
1560 {
1561 register real *in = inbuf;
1562
1563 in[17]+=in[16]; in[16]+=in[15]; in[15]+=in[14];
1564 in[14]+=in[13]; in[13]+=in[12]; in[12]+=in[11];
1565 in[11]+=in[10]; in[10]+=in[9]; in[9] +=in[8];
1566 in[8] +=in[7]; in[7] +=in[6]; in[6] +=in[5];
1567 in[5] +=in[4]; in[4] +=in[3]; in[3] +=in[2];
1568 in[2] +=in[1]; in[1] +=in[0];
1569
1570 in[17]+=in[15]; in[15]+=in[13]; in[13]+=in[11]; in[11]+=in[9];
1571 in[9] +=in[7]; in[7] +=in[5]; in[5] +=in[3]; in[3] +=in[1];
1572
1573
1574#ifdef NEW_DCT9
1575#if 1
1576 {
1577 real t3;
1578 {
1579 real t0, t1, t2;
1580
1581 t0 = REAL_MUL(COS6_2, (in[8] + in[16] - in[4]));
1582 t1 = REAL_MUL(COS6_2, in[12]);
1583
1584 t3 = in[0];
1585 t2 = t3 - t1 - t1;
1586 tmp[1] = tmp[7] = t2 - t0;
1587 tmp[4] = t2 + t0 + t0;
1588 t3 += t1;
1589
1590 t2 = REAL_MUL(COS6_1, (in[10] + in[14] - in[2]));
1591 tmp[1] -= t2;
1592 tmp[7] += t2;
1593 }
1594 {
1595 real t0, t1, t2;
1596
1597 t0 = REAL_MUL(cos9[0], (in[4] + in[8] ));
1598 t1 = REAL_MUL(cos9[1], (in[8] - in[16]));
1599 t2 = REAL_MUL(cos9[2], (in[4] + in[16]));
1600
1601 tmp[2] = tmp[6] = t3 - t0 - t2;
1602 tmp[0] = tmp[8] = t3 + t0 + t1;
1603 tmp[3] = tmp[5] = t3 - t1 + t2;
1604 }
1605 }
1606 {
1607 real t1, t2, t3;
1608
1609 t1 = REAL_MUL(cos18[0], (in[2] + in[10]));
1610 t2 = REAL_MUL(cos18[1], (in[10] - in[14]));
1611 t3 = REAL_MUL(COS6_1, in[6]);
1612
1613 {
1614 real t0 = t1 + t2 + t3;
1615 tmp[0] += t0;
1616 tmp[8] -= t0;
1617 }
1618
1619 t2 -= t3;
1620 t1 -= t3;
1621
1622 t3 = REAL_MUL(cos18[2], (in[2] + in[14]));
1623
1624 t1 += t3;
1625 tmp[3] += t1;
1626 tmp[5] -= t1;
1627
1628 t2 -= t3;
1629 tmp[2] += t2;
1630 tmp[6] -= t2;
1631 }
1632
1633#else
1634 {
1635 real t0, t1, t2, t3, t4, t5, t6, t7;
1636
1637 t1 = REAL_MUL(COS6_2, in[12]);
1638 t2 = REAL_MUL(COS6_2, (in[8] + in[16] - in[4]));
1639
1640 t3 = in[0] + t1;
1641 t4 = in[0] - t1 - t1;
1642 t5 = t4 - t2;
1643 tmp[4] = t4 + t2 + t2;
1644
1645 t0 = REAL_MUL(cos9[0], (in[4] + in[8]));
1646 t1 = REAL_MUL(cos9[1], (in[8] - in[16]));
1647
1648 t2 = REAL_MUL(cos9[2], (in[4] + in[16]));
1649
1650 t6 = t3 - t0 - t2;
1651 t0 += t3 + t1;
1652 t3 += t2 - t1;
1653
1654 t2 = REAL_MUL(cos18[0], (in[2] + in[10]));
1655 t4 = REAL_MUL(cos18[1], (in[10] - in[14]));
1656 t7 = REAL_MUL(COS6_1, in[6]);
1657
1658 t1 = t2 + t4 + t7;
1659 tmp[0] = t0 + t1;
1660 tmp[8] = t0 - t1;
1661 t1 = REAL_MUL(cos18[2], (in[2] + in[14]));
1662 t2 += t1 - t7;
1663
1664 tmp[3] = t3 + t2;
1665 t0 = REAL_MUL(COS6_1, (in[10] + in[14] - in[2]));
1666 tmp[5] = t3 - t2;
1667
1668 t4 -= t1 + t7;
1669
1670 tmp[1] = t5 - t0;
1671 tmp[7] = t5 + t0;
1672 tmp[2] = t6 + t4;
1673 tmp[6] = t6 - t4;
1674 }
1675#endif
1676
1677 {
1678 real t0, t1, t2, t3, t4, t5, t6, t7;
1679
1680 t1 = REAL_MUL(COS6_2, in[13]);
1681 t2 = REAL_MUL(COS6_2, (in[9] + in[17] - in[5]));
1682
1683 t3 = in[1] + t1;
1684 t4 = in[1] - t1 - t1;
1685 t5 = t4 - t2;
1686
1687 t0 = REAL_MUL(cos9[0], (in[5] + in[9]));
1688 t1 = REAL_MUL(cos9[1], (in[9] - in[17]));
1689
1690 tmp[13] = REAL_MUL((t4 + t2 + t2), tfcos36[17-13]);
1691 t2 = REAL_MUL(cos9[2], (in[5] + in[17]));
1692
1693 t6 = t3 - t0 - t2;
1694 t0 += t3 + t1;
1695 t3 += t2 - t1;
1696
1697 t2 = REAL_MUL(cos18[0], (in[3] + in[11]));
1698 t4 = REAL_MUL(cos18[1], (in[11] - in[15]));
1699 t7 = REAL_MUL(COS6_1, in[7]);
1700
1701 t1 = t2 + t4 + t7;
1702 tmp[17] = REAL_MUL((t0 + t1), tfcos36[17-17]);
1703 tmp[9] = REAL_MUL((t0 - t1), tfcos36[17-9]);
1704 t1 = REAL_MUL(cos18[2], (in[3] + in[15]));
1705 t2 += t1 - t7;
1706
1707 tmp[14] = REAL_MUL((t3 + t2), tfcos36[17-14]);
1708 t0 = REAL_MUL(COS6_1, (in[11] + in[15] - in[3]));
1709 tmp[12] = REAL_MUL((t3 - t2), tfcos36[17-12]);
1710
1711 t4 -= t1 + t7;
1712
1713 tmp[16] = REAL_MUL((t5 - t0), tfcos36[17-16]);
1714 tmp[10] = REAL_MUL((t5 + t0), tfcos36[17-10]);
1715 tmp[15] = REAL_MUL((t6 + t4), tfcos36[17-15]);
1716 tmp[11] = REAL_MUL((t6 - t4), tfcos36[17-11]);
1717 }
1718
1719#define MACRO(v) { \
1720 real tmpval; \
1721 tmpval = tmp[(v)] + tmp[17-(v)]; \
1722 out2[9+(v)] = REAL_MUL(tmpval, w[27+(v)]); \
1723 out2[8-(v)] = REAL_MUL(tmpval, w[26-(v)]); \
1724 tmpval = tmp[(v)] - tmp[17-(v)]; \
1725 ts[SBLIMIT*(8-(v))] = out1[8-(v)] + REAL_MUL(tmpval, w[8-(v)]); \
1726 ts[SBLIMIT*(9+(v))] = out1[9+(v)] + REAL_MUL(tmpval, w[9+(v)]); }
1727
1728 {
1729 register real *out2 = o2;
1730 register real *w = wintab;
1731 register real *out1 = o1;
1732 register real *ts = tsbuf;
1733
1734 MACRO(0);
1735 MACRO(1);
1736 MACRO(2);
1737 MACRO(3);
1738 MACRO(4);
1739 MACRO(5);
1740 MACRO(6);
1741 MACRO(7);
1742 MACRO(8);
1743 }
1744
1745#else
1746
1747 {
1748
1749#define MACRO0(v) { \
1750 real tmp; \
1751 out2[9+(v)] = REAL_MUL((tmp = sum0 + sum1), w[27+(v)]); \
1752 out2[8-(v)] = REAL_MUL(tmp, w[26-(v)]); } \
1753 sum0 -= sum1; \
1754 ts[SBLIMIT*(8-(v))] = out1[8-(v)] + REAL_MUL(sum0, w[8-(v)]); \
1755 ts[SBLIMIT*(9+(v))] = out1[9+(v)] + REAL_MUL(sum0, w[9+(v)]);
1756#define MACRO1(v) { \
1757 real sum0,sum1; \
1758 sum0 = tmp1a + tmp2a; \
1759 sum1 = REAL_MUL((tmp1b + tmp2b), tfcos36[(v)]); \
1760 MACRO0(v); }
1761#define MACRO2(v) { \
1762 real sum0,sum1; \
1763 sum0 = tmp2a - tmp1a; \
1764 sum1 = REAL_MUL((tmp2b - tmp1b), tfcos36[(v)]); \
1765 MACRO0(v); }
1766
1767 register const real *c = COS9;
1768 register real *out2 = o2;
1769 register real *w = wintab;
1770 register real *out1 = o1;
1771 register real *ts = tsbuf;
1772
1773 real ta33,ta66,tb33,tb66;
1774
1775 ta33 = REAL_MUL(in[2*3+0], c[3]);
1776 ta66 = REAL_MUL(in[2*6+0], c[6]);
1777 tb33 = REAL_MUL(in[2*3+1], c[3]);
1778 tb66 = REAL_MUL(in[2*6+1], c[6]);
1779
1780 {
1781 real tmp1a,tmp2a,tmp1b,tmp2b;
1782 tmp1a = REAL_MUL(in[2*1+0], c[1]) + ta33 + REAL_MUL(in[2*5+0], c[5]) + REAL_MUL(in[2*7+0], c[7]);
1783 tmp1b = REAL_MUL(in[2*1+1], c[1]) + tb33 + REAL_MUL(in[2*5+1], c[5]) + REAL_MUL(in[2*7+1], c[7]);
1784 tmp2a = REAL_MUL(in[2*2+0], c[2]) + REAL_MUL(in[2*4+0], c[4]) + ta66 + REAL_MUL(in[2*8+0], c[8]);
1785 tmp2b = REAL_MUL(in[2*2+1], c[2]) + REAL_MUL(in[2*4+1], c[4]) + tb66 + REAL_MUL(in[2*8+1], c[8]);
1786
1787 MACRO1(0);
1788 MACRO2(8);
1789 }
1790
1791 {
1792 real tmp1a,tmp2a,tmp1b,tmp2b;
1793 tmp1a = REAL_MUL(( in[2*1+0] - in[2*5+0] - in[2*7+0] ), c[3]);
1794 tmp1b = REAL_MUL(( in[2*1+1] - in[2*5+1] - in[2*7+1] ), c[3]);
1795 tmp2a = REAL_MUL(( in[2*2+0] - in[2*4+0] - in[2*8+0] ), c[6]) - in[2*6+0] + in[2*0+0];
1796 tmp2b = REAL_MUL(( in[2*2+1] - in[2*4+1] - in[2*8+1] ), c[6]) - in[2*6+1] + in[2*0+1];
1797
1798 MACRO1(1);
1799 MACRO2(7);
1800 }
1801
1802 {
1803 real tmp1a,tmp2a,tmp1b,tmp2b;
1804 tmp1a = REAL_MUL(in[2*1+0], c[5]) - ta33 - REAL_MUL(in[2*5+0], c[7]) + REAL_MUL(in[2*7+0], c[1]);
1805 tmp1b = REAL_MUL(in[2*1+1], c[5]) - tb33 - REAL_MUL(in[2*5+1], c[7]) + REAL_MUL(in[2*7+1], c[1]);
1806 tmp2a = - REAL_MUL(in[2*2+0], c[8]) - REAL_MUL(in[2*4+0], c[2]) + ta66 + REAL_MUL(in[2*8+0], c[4]);
1807 tmp2b = - REAL_MUL(in[2*2+1], c[8]) - REAL_MUL(in[2*4+1], c[2]) + tb66 + REAL_MUL(in[2*8+1], c[4]);
1808
1809 MACRO1(2);
1810 MACRO2(6);
1811 }
1812
1813 {
1814 real tmp1a,tmp2a,tmp1b,tmp2b;
1815 tmp1a = REAL_MUL(in[2*1+0], c[7]) - ta33 + REAL_MUL(in[2*5+0], c[1]) - REAL_MUL(in[2*7+0], c[5]);
1816 tmp1b = REAL_MUL(in[2*1+1], c[7]) - tb33 + REAL_MUL(in[2*5+1], c[1]) - REAL_MUL(in[2*7+1], c[5]);
1817 tmp2a = - REAL_MUL(in[2*2+0], c[4]) + REAL_MUL(in[2*4+0], c[8]) + ta66 - REAL_MUL(in[2*8+0], c[2]);
1818 tmp2b = - REAL_MUL(in[2*2+1], c[4]) + REAL_MUL(in[2*4+1], c[8]) + tb66 - REAL_MUL(in[2*8+1], c[2]);
1819
1820 MACRO1(3);
1821 MACRO2(5);
1822 }
1823
1824 {
1825 real sum0,sum1;
1826 sum0 = in[2*0+0] - in[2*2+0] + in[2*4+0] - in[2*6+0] + in[2*8+0];
1827 sum1 = REAL_MUL((in[2*0+1] - in[2*2+1] + in[2*4+1] - in[2*6+1] + in[2*8+1] ), tfcos36[4]);
1828 MACRO0(4);
1829 }
1830 }
1831#endif
1832
1833 }
1834}
static int inbuf
Definition: adnsresfilter.c:73
const GLubyte * c
Definition: glext.h:8905
#define tfcos36
Definition: intsym.h:7
#define COS9
Definition: intsym.h:6
#define MACRO(v)

◆ do_layer3()

int do_layer3 ( mpg123_handle fr)

Definition at line 2099 of file layer3.c.

2100{
2101 int gr, ch, ss,clip=0;
2102 int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */
2103 struct III_sideinfo sideinfo;
2104 int stereo = fr->stereo;
2105 int single = fr->single;
2106 int ms_stereo,i_stereo;
2107 int sfreq = fr->sampling_frequency;
2108 int stereo1,granules;
2109
2110 if(stereo == 1)
2111 { /* stream is mono */
2112 stereo1 = 1;
2114 }
2115 else if(single != SINGLE_STEREO) /* stream is stereo, but force to mono */
2116 stereo1 = 1;
2117 else
2118 stereo1 = 2;
2119
2120 if(fr->mode == MPG_MD_JOINT_STEREO)
2121 {
2122 ms_stereo = (fr->mode_ext & 0x2)>>1;
2123 i_stereo = fr->mode_ext & 0x1;
2124 }
2125 else ms_stereo = i_stereo = 0;
2126
2127 granules = fr->lsf ? 1 : 2;
2128
2129 /* quick hack to keep the music playing */
2130 /* after having seen this nasty test file... */
2131 if(III_get_side_info(fr, &sideinfo,stereo,ms_stereo,sfreq,single))
2132 {
2133 if(NOQUIET) error("bad frame - unable to get valid sideinfo");
2134 return clip;
2135 }
2136
2137 set_pointer(fr, 1, sideinfo.main_data_begin);
2138#ifndef NO_MOREINFO
2139 if(fr->pinfo)
2140 {
2141 fr->pinfo->maindata = sideinfo.main_data_begin;
2142 fr->pinfo->padding = fr->padding;
2143 }
2144#endif
2145 for(gr=0;gr<granules;gr++)
2146 {
2147 /* hybridIn[2][SBLIMIT][SSLIMIT] */
2148 real (*hybridIn)[SBLIMIT][SSLIMIT] = fr->layer3.hybrid_in;
2149 /* hybridOut[2][SSLIMIT][SBLIMIT] */
2150 real (*hybridOut)[SSLIMIT][SBLIMIT] = fr->layer3.hybrid_out;
2151
2152 {
2153 struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]);
2154 long part2bits;
2155 if(gr_info->part2_3_length > fr->bits_avail)
2156 {
2157 if(NOQUIET)
2158 error2(
2159 "part2_3_length (%u) too large for available bit count (%li)"
2160 , gr_info->part2_3_length, fr->bits_avail );
2161 return clip;
2162 }
2163 if(fr->lsf)
2164 part2bits = III_get_scale_factors_2(fr, scalefacs[0],gr_info,0);
2165 else
2166 part2bits = III_get_scale_factors_1(fr, scalefacs[0],gr_info,0,gr);
2167
2168 if(part2bits < 0)
2169 {
2170 if(VERBOSE2)
2171 error("not enough bits for scale factors");
2172 return clip;
2173 }
2174
2175#ifndef NO_MOREINFO
2176 if(fr->pinfo)
2177 {
2178 int i;
2179 fr->pinfo->sfbits[gr][0] = part2bits;
2180 for(i=0; i<39; ++i)
2181 fr->pinfo->sfb_s[gr][0][i] = scalefacs[0][i];
2182 }
2183#endif
2184
2185 if(III_dequantize_sample(fr, hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits))
2186 {
2187 if(NOQUIET)
2188 error("dequantization failed!");
2189 return clip;
2190 }
2191 if(fr->bits_avail < 0)
2192 {
2193 if(NOQUIET)
2194 error("bit deficit after dequant");
2195 return clip;
2196 }
2197 }
2198
2199 if(stereo == 2)
2200 {
2201 struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]);
2202 long part2bits;
2203 if(fr->lsf)
2204 part2bits = III_get_scale_factors_2(fr, scalefacs[1],gr_info,i_stereo);
2205 else
2206 part2bits = III_get_scale_factors_1(fr, scalefacs[1],gr_info,1,gr);
2207
2208 if(part2bits < 0)
2209 {
2210 if(VERBOSE2)
2211 error("not enough bits for scale factors");
2212 return clip;
2213 }
2214
2215#ifndef NO_MOREINFO
2216 if(fr->pinfo)
2217 {
2218 int i;
2219 fr->pinfo->sfbits[gr][1] = part2bits;
2220 for(i=0; i<39; ++i)
2221 fr->pinfo->sfb_s[gr][1][i] = scalefacs[1][i];
2222 }
2223#endif
2224
2225 if(III_dequantize_sample(fr, hybridIn[1],scalefacs[1],gr_info,sfreq,part2bits))
2226 {
2227 if(NOQUIET)
2228 error("dequantization failed!");
2229 return clip;
2230 }
2231 if(fr->bits_avail < 0)
2232 {
2233 if(NOQUIET)
2234 error("bit deficit after dequant");
2235 return clip;
2236 }
2237
2238 if(ms_stereo)
2239 {
2240 int i;
2241 unsigned int maxb = sideinfo.ch[0].gr[gr].maxb;
2242 if(sideinfo.ch[1].gr[gr].maxb > maxb) maxb = sideinfo.ch[1].gr[gr].maxb;
2243
2244 for(i=0;i<SSLIMIT*(int)maxb;i++)
2245 {
2246 real tmp0 = ((real *)hybridIn[0])[i];
2247 real tmp1 = ((real *)hybridIn[1])[i];
2248 ((real *)hybridIn[0])[i] = tmp0 + tmp1;
2249 ((real *)hybridIn[1])[i] = tmp0 - tmp1;
2250 }
2251 }
2252
2253 if(i_stereo) III_i_stereo(hybridIn,scalefacs[1],gr_info,sfreq,ms_stereo,fr->lsf);
2254
2255 if(ms_stereo || i_stereo || (single == SINGLE_MIX) )
2256 {
2257 if(gr_info->maxb > sideinfo.ch[0].gr[gr].maxb)
2258 sideinfo.ch[0].gr[gr].maxb = gr_info->maxb;
2259 else
2260 gr_info->maxb = sideinfo.ch[0].gr[gr].maxb;
2261 }
2262
2263 switch(single)
2264 {
2265 case SINGLE_MIX:
2266 {
2267 register int i;
2268 register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1];
2269 for(i=0;i<SSLIMIT*(int)gr_info->maxb;i++,in0++)
2270 *in0 = (*in0 + *in1++); /* *0.5 done by pow-scale */
2271 }
2272 break;
2273 case SINGLE_RIGHT:
2274 {
2275 register int i;
2276 register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1];
2277 for(i=0;i<SSLIMIT*(int)gr_info->maxb;i++)
2278 *in0++ = *in1++;
2279 }
2280 break;
2281 }
2282 }
2283
2284#ifndef NO_MOREINFO
2285 if(fr->pinfo)
2286 fill_pinfo_side(fr, &sideinfo, gr, stereo1);
2287#endif
2288
2289 for(ch=0;ch<stereo1;ch++)
2290 {
2291 struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]);
2292 III_antialias(hybridIn[ch],gr_info);
2293 III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info, fr);
2294 }
2295
2296#ifdef OPT_I486
2297 if(single != SINGLE_STEREO || fr->af.encoding != MPG123_ENC_SIGNED_16 || fr->down_sample != 0)
2298 {
2299#endif
2300 for(ss=0;ss<SSLIMIT;ss++)
2301 {
2302 if(single != SINGLE_STEREO)
2303 clip += (fr->synth_mono)(hybridOut[0][ss], fr);
2304 else
2305 clip += (fr->synth_stereo)(hybridOut[0][ss], hybridOut[1][ss], fr);
2306
2307 }
2308#ifdef OPT_I486
2309 } else
2310 {
2311 /* Only stereo, 16 bits benefit from the 486 optimization. */
2312 ss=0;
2313 while(ss < SSLIMIT)
2314 {
2315 int n;
2316 n=(fr->buffer.size - fr->buffer.fill) / (2*2*32);
2317 if(n > (SSLIMIT-ss)) n=SSLIMIT-ss;
2318
2319 /* Clip counting makes no sense with this function. */
2320 absynth_1to1_i486(hybridOut[0][ss], 0, fr, n);
2321 absynth_1to1_i486(hybridOut[1][ss], 1, fr, n);
2322 ss+=n;
2323 fr->buffer.fill+=(2*2*32)*n;
2324 }
2325 }
2326#endif
2327 }
2328
2329 return clip;
2330}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define SINGLE_LEFT
Definition: frame.h:189
#define SINGLE_STEREO
Definition: frame.h:188
#define SINGLE_RIGHT
Definition: frame.h:190
#define SINGLE_MIX
Definition: frame.h:191
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ MPG123_ENC_SIGNED_16
Definition: fmt123.h:58
#define ss
Definition: i386-dis.c:441
#define set_pointer
Definition: intsym.h:242
#define absynth_1to1_i486
Definition: intsym.h:54
static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT], real tsOut[SSLIMIT][SBLIMIT], int ch, struct gr_info_s *gr_info, mpg123_handle *fr)
Definition: layer3.c:1975
static int III_get_scale_factors_2(mpg123_handle *fr, int *scf, struct gr_info_s *gr_info, int i_stereo)
Definition: layer3.c:684
static int III_dequantize_sample(mpg123_handle *fr, real xr[SBLIMIT][SSLIMIT], int *scf, struct gr_info_s *gr_info, int sfreq, int part2bits)
Definition: layer3.c:795
static void III_antialias(real xr[SBLIMIT][SSLIMIT], struct gr_info_s *gr_info)
Definition: layer3.c:1482
static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT], int *scalefac, struct gr_info_s *gr_info, int sfreq, int ms_stereo, int lsf)
Definition: layer3.c:1310
static void fill_pinfo_side(mpg123_handle *fr, struct III_sideinfo *si, int gr, int stereo1)
Definition: layer3.c:2031
static int III_get_scale_factors_1(mpg123_handle *fr, int *scf, struct gr_info_s *gr_info, int ch, int gr)
Definition: layer3.c:585
static int III_get_side_info(mpg123_handle *fr, struct III_sideinfo *si, int stereo, int ms_stereo, long sfreq, int single)
Definition: layer3.c:405
#define error(str)
Definition: mkdosfs.c:1605
#define VERBOSE2
#define MPG_MD_JOINT_STEREO
#define SSLIMIT
float single
Definition: msinkaut.idl:29
#define error2(s, a, b)
Definition: debug.h:126
struct gr_info_s gr[2]
Definition: layer3.c:83
func_synth_mono synth_mono
Definition: frame.h:182
int sampling_frequency
Definition: frame.h:205
struct mpg123_moreinfo * pinfo
Definition: frame.h:343
func_synth_stereo synth_stereo
Definition: frame.h:181
struct mpg123_handle_struct::@3461 layer3
struct audioformat af
Definition: frame.h:268
struct outbuffer buffer
Definition: frame.h:267

◆ fill_pinfo_side()

static void fill_pinfo_side ( mpg123_handle fr,
struct III_sideinfo si,
int  gr,
int  stereo1 
)
static

Definition at line 2031 of file layer3.c.

2032{
2033 int i, sb;
2034 float ifqstep; /* Why not double? */
2035 int ch, ss;;
2036
2037 for(ch = 0; ch < stereo1; ++ch)
2038 {
2039 struct gr_info_s *gr_infos = &(si->ch[ch].gr[gr]);
2040 fr->pinfo->big_values[gr][ch] = gr_infos->big_values;
2041 fr->pinfo->scalefac_scale[gr][ch] = gr_infos->scalefac_scale;
2042 fr->pinfo->mixed[gr][ch] = gr_infos->mixed_block_flag;
2043 fr->pinfo->blocktype[gr][ch] = gr_infos->block_type;
2044 fr->pinfo->mainbits[gr][ch] = gr_infos->part2_3_length;
2045 fr->pinfo->preflag[gr][ch] = gr_infos->preflag;
2046 if(gr == 1)
2047 fr->pinfo->scfsi[ch] = gr_infos->scfsi;
2048 }
2049
2050 for(ch = 0; ch < stereo1; ++ch)
2051 {
2052 struct gr_info_s *gr_infos = &(si->ch[ch].gr[gr]);
2053 ifqstep = (fr->pinfo->scalefac_scale[gr][ch] == 0) ? .5 : 1.0;
2054 if(2 == gr_infos->block_type)
2055 {
2056 for(i = 0; i < 3; ++i)
2057 {
2058 for(sb = 0; sb < 12; ++sb)
2059 {
2060 int j = 3 * sb + i;
2061 /*
2062 is_p = scalefac[sfb*3+lwin-gr_infos->mixed_block_flag];
2063 */
2064 /* scalefac was copied into pinfo->sfb_s[] before */
2065 fr->pinfo->sfb_s[gr][ch][j] = -ifqstep *
2066 fr->pinfo->sfb_s[gr][ch][j - gr_infos->mixed_block_flag];
2067 fr->pinfo->sfb_s[gr][ch][j] -= 2 *
2068 (fr->pinfo->sub_gain[gr][ch][i]);
2069 }
2070 fr->pinfo->sfb_s[gr][ch][3 * sb + i] =
2071 -2 * (fr->pinfo->sub_gain[gr][ch][i]);
2072 }
2073 } else
2074 {
2075 for(sb = 0; sb < 21; ++sb)
2076 {
2077 /* scalefac was copied into pinfo->sfb[] before */
2078 fr->pinfo->sfb[gr][ch][sb] = fr->pinfo->sfb_s[gr][ch][sb];
2079 if (gr_infos->preflag)
2080 fr->pinfo->sfb[gr][ch][sb] += pretab_choice[1][sb];
2081 fr->pinfo->sfb[gr][ch][sb] *= -ifqstep;
2082 }
2083 fr->pinfo->sfb[gr][ch][21] = 0;
2084 }
2085 }
2086
2087
2088 for(ch = 0; ch < stereo1; ++ch)
2089 {
2090 int j = 0;
2091 for(sb = 0; sb < SBLIMIT; ++sb)
2092 for (ss = 0; ss < SSLIMIT; ++ss, ++j)
2093 fr->pinfo->xr[gr][ch][j] = fr->layer3.hybrid_in[ch][sb][ss];
2094 }
2095}
superblock * sb
Definition: btrfs.c:4261
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static unsigned char pretab_choice[2][22]
Definition: layer3.c:758
struct III_sideinfo::@4257 ch[2]

Referenced by do_layer3().

◆ III_antialias()

static void III_antialias ( real  xr[SBLIMIT][SSLIMIT],
struct gr_info_s *  gr_info 
)
static

Definition at line 1482 of file layer3.c.

1483{
1484 int sblim;
1485
1486 if(gr_info->block_type == 2)
1487 {
1488 if(!gr_info->mixed_block_flag) return;
1489
1490 sblim = 1;
1491 }
1492 else sblim = gr_info->maxb-1;
1493
1494 /* 31 alias-reduction operations between each pair of sub-bands */
1495 /* with 8 butterflies between each pair */
1496
1497 {
1498 int sb;
1499 real *xr1=(real *) xr[1];
1500
1501 for(sb=sblim; sb; sb--,xr1+=10)
1502 {
1503 int ss;
1504 real *cs=aa_cs,*ca=aa_ca;
1505 real *xr2 = xr1;
1506
1507 for(ss=7;ss>=0;ss--)
1508 { /* upper and lower butterfly inputs */
1509 register real bu = *--xr2,bd = *xr1;
1510 *xr2 = REAL_MUL(bu, *cs) - REAL_MUL(bd, *ca);
1511 *xr1++ = REAL_MUL(bd, *cs++) + REAL_MUL(bu, *ca++);
1512 }
1513 }
1514 }
1515}
static const WCHAR ca[]
Definition: main.c:455
#define cs
Definition: i386-dis.c:442
static real aa_cs[8]
Definition: layer3.c:39
static real aa_ca[8]
Definition: layer3.c:39

Referenced by do_layer3().

◆ III_dequantize_sample()

static int III_dequantize_sample ( mpg123_handle fr,
real  xr[SBLIMIT][SSLIMIT],
int scf,
struct gr_info_s *  gr_info,
int  sfreq,
int  part2bits 
)
static

Definition at line 795 of file layer3.c.

796{
797 int shift = 1 + gr_info->scalefac_scale;
798 real *xrpnt = (real *) xr;
799 int l[3],l3;
800 int part2remain = gr_info->part2_3_length - part2bits;
801 int *me;
802#ifdef REAL_IS_FIXED
803 int gainpow2_scale_idx = 378;
804#endif
805
806 /* Assumption: If there is some part2_3_length at all, there should be
807 enough of it to work with properly. In case of zero length we silently
808 zero things. */
809 if(gr_info->part2_3_length > 0)
810 {
811
812 /* mhipp tree has this split up a bit... */
813 int num=getbitoffset(fr);
815 /* We must split this, because for num==0 the shift is undefined if you do it in one step. */
816 mask = ((MASK_UTYPE) getbits(fr, num))<<BITSHIFT;
817 mask <<= 8-num;
818 part2remain -= num;
819
820 /* Bitindex is zero now, we are allowed to use getbyte(). */
821
822 {
823 int bv = gr_info->big_values;
824 int region1 = gr_info->region1start;
825 int region2 = gr_info->region2start;
826 l3 = ((576>>1)-bv)>>1;
827
828 /* we may lose the 'odd' bit here !! check this later again */
829 if(bv <= region1)
830 {
831 l[0] = bv;
832 l[1] = 0;
833 l[2] = 0;
834 }
835 else
836 {
837 l[0] = region1;
838 if(bv <= region2)
839 {
840 l[1] = bv - l[0];
841 l[2] = 0;
842 }
843 else
844 {
845 l[1] = region2 - l[0];
846 l[2] = bv - region2;
847 }
848 }
849 }
850
851#define CHECK_XRPNT if(xrpnt >= &xr[SBLIMIT][0]) \
852{ \
853 if(NOQUIET) \
854 error2("attempted xrpnt overflow (%p !< %p)", (void*) xrpnt, (void*) &xr[SBLIMIT][0]); \
855 return 1; \
856}
857
858 if(gr_info->block_type == 2)
859 {
860 /* decoding with short or mixed mode BandIndex table */
861 int i,max[4];
862 int step=0,lwin=3,cb=0;
863 register real v = 0.0;
864 register int *m,mc;
865
866 if(gr_info->mixed_block_flag)
867 {
868 max[3] = -1;
869 max[0] = max[1] = max[2] = 2;
870 m = map[sfreq][0];
871 me = mapend[sfreq][0];
872 }
873 else
874 {
875 max[0] = max[1] = max[2] = max[3] = -1;
876 /* max[3] not really needed in this case */
877 m = map[sfreq][1];
878 me = mapend[sfreq][1];
879 }
880
881 mc = 0;
882 for(i=0;i<2;i++)
883 {
884 int lp = l[i];
885 const struct newhuff *h = ht+gr_info->table_select[i];
886 for(;lp;lp--,mc--)
887 {
888 register MASK_STYPE x,y;
889 if( (!mc) )
890 {
891 mc = *m++;
892//fprintf(stderr, "%i setting xrpnt = xr + %i (%ld)\n", __LINE__, *m, xrpnt-(real*)xr);
893 xrpnt = ((real *) xr) + (*m++);
894 lwin = *m++;
895 cb = *m++;
896 if(lwin == 3)
897 {
898#ifdef REAL_IS_FIXED
899 gainpow2_scale_idx = (int)(gr_info->pow2gain + (*scf << shift) - fr->gainpow2);
900#endif
901 v = gr_info->pow2gain[(*scf++) << shift];
902 step = 1;
903 }
904 else
905 {
906#ifdef REAL_IS_FIXED
907 gainpow2_scale_idx = (int)(gr_info->full_gain[lwin] + (*scf << shift) - fr->gainpow2);
908#endif
909 v = gr_info->full_gain[lwin][(*scf++) << shift];
910 step = 3;
911 }
912 }
913 {
914 const short *val = h->table;
916#ifdef USE_NEW_HUFFTABLE
917 while((y=val[(MASK_UTYPE)mask>>(BITSHIFT+4)])<0)
918 {
919 val -= y;
920 num -= 4;
921 mask <<= 4;
922 }
923 num -= (y >> 8);
924 mask <<= (y >> 8);
925 x = (y >> 4) & 0xf;
926 y &= 0xf;
927#else
928 while((y=*val++)<0)
929 {
930 if (MSB_MASK) val -= y;
931
932 num--;
933 mask <<= 1;
934 }
935 x = y >> 4;
936 y &= 0xf;
937#endif
938 }
940 if(x == 15 && h->linbits)
941 {
942 max[lwin] = cb;
944 x += ((MASK_UTYPE) mask) >> (BITSHIFT+8-h->linbits);
945 num -= h->linbits+1;
946 mask <<= h->linbits;
947 if(MSB_MASK) *xrpnt = REAL_MUL_SCALE_LAYER3(-ispow[x], v, gainpow2_scale_idx);
948 else *xrpnt = REAL_MUL_SCALE_LAYER3( ispow[x], v, gainpow2_scale_idx);
949
950 mask <<= 1;
951 }
952 else if(x)
953 {
954 max[lwin] = cb;
955 if(MSB_MASK) *xrpnt = REAL_MUL_SCALE_LAYER3(-ispow[x], v, gainpow2_scale_idx);
956 else *xrpnt = REAL_MUL_SCALE_LAYER3( ispow[x], v, gainpow2_scale_idx);
957
958 num--;
959 mask <<= 1;
960 }
961 else *xrpnt = DOUBLE_TO_REAL(0.0);
962
963 xrpnt += step;
965 if(y == 15 && h->linbits)
966 {
967 max[lwin] = cb;
969 y += ((MASK_UTYPE) mask) >> (BITSHIFT+8-h->linbits);
970 num -= h->linbits+1;
971 mask <<= h->linbits;
972 if(MSB_MASK) *xrpnt = REAL_MUL_SCALE_LAYER3(-ispow[y], v, gainpow2_scale_idx);
973 else *xrpnt = REAL_MUL_SCALE_LAYER3( ispow[y], v, gainpow2_scale_idx);
974
975 mask <<= 1;
976 }
977 else if(y)
978 {
979 max[lwin] = cb;
980 if(MSB_MASK) *xrpnt = REAL_MUL_SCALE_LAYER3(-ispow[y], v, gainpow2_scale_idx);
981 else *xrpnt = REAL_MUL_SCALE_LAYER3( ispow[y], v, gainpow2_scale_idx);
982
983 num--;
984 mask <<= 1;
985 }
986 else *xrpnt = DOUBLE_TO_REAL(0.0);
987
988 xrpnt += step;
989 }
990 }
991
992 for(;l3 && (part2remain+num > 0);l3--)
993 {
994 const struct newhuff* h;
995 const short* val;
996 register short a;
997
998 h = htc+gr_info->count1table_select;
999 val = h->table;
1000
1002 while((a=*val++)<0)
1003 {
1004 if(MSB_MASK) val -= a;
1005
1006 num--;
1007 mask <<= 1;
1008 }
1009 if(part2remain+num <= 0)
1010 {
1011 num -= part2remain+num;
1012 break;
1013 }
1014
1015 for(i=0;i<4;i++)
1016 {
1017 if(!(i & 1))
1018 {
1019 if(!mc)
1020 {
1021 mc = *m++;
1022//fprintf(stderr, "%i setting xrpnt = xr + %i (%ld)\n", __LINE__, *m, xrpnt-(real*)xr);
1023 xrpnt = ((real *) xr) + (*m++);
1024 lwin = *m++;
1025 cb = *m++;
1026 if(lwin == 3)
1027 {
1028#ifdef REAL_IS_FIXED
1029 gainpow2_scale_idx = (int)(gr_info->pow2gain + (*scf << shift) - fr->gainpow2);
1030#endif
1031 v = gr_info->pow2gain[(*scf++) << shift];
1032 step = 1;
1033 }
1034 else
1035 {
1036#ifdef REAL_IS_FIXED
1037 gainpow2_scale_idx = (int)(gr_info->full_gain[lwin] + (*scf << shift) - fr->gainpow2);
1038#endif
1039 v = gr_info->full_gain[lwin][(*scf++) << shift];
1040 step = 3;
1041 }
1042 }
1043 mc--;
1044 }
1046 if( (a & (0x8>>i)) )
1047 {
1048 max[lwin] = cb;
1049 if(part2remain+num <= 0)
1050 break;
1051
1052 if(MSB_MASK) *xrpnt = -REAL_SCALE_LAYER3(v, gainpow2_scale_idx);
1053 else *xrpnt = REAL_SCALE_LAYER3(v, gainpow2_scale_idx);
1054
1055 num--;
1056 mask <<= 1;
1057 }
1058 else *xrpnt = DOUBLE_TO_REAL(0.0);
1059
1060 xrpnt += step;
1061 }
1062 }
1063
1064 if(lwin < 3)
1065 { /* short band? */
1066 while(1)
1067 {
1068 for(;mc > 0;mc--)
1069 {
1071 *xrpnt = DOUBLE_TO_REAL(0.0); xrpnt += 3; /* short band -> step=3 */
1072 *xrpnt = DOUBLE_TO_REAL(0.0); xrpnt += 3;
1073 }
1074 if(m >= me)
1075 break;
1076
1077 mc = *m++;
1078 xrpnt = ((real *) xr) + *m++;
1079 if(*m++ == 0)
1080 break; /* optimize: field will be set to zero at the end of the function */
1081
1082 m++; /* cb */
1083 }
1084 }
1085
1086 gr_info->maxband[0] = max[0]+1;
1087 gr_info->maxband[1] = max[1]+1;
1088 gr_info->maxband[2] = max[2]+1;
1089 gr_info->maxbandl = max[3]+1;
1090
1091 {
1092 int rmax = max[0] > max[1] ? max[0] : max[1];
1093 rmax = (rmax > max[2] ? rmax : max[2]) + 1;
1094 gr_info->maxb = rmax ? fr->shortLimit[sfreq][rmax] : fr->longLimit[sfreq][max[3]+1];
1095 }
1096
1097 }
1098 else
1099 {
1100 /* decoding with 'long' BandIndex table (block_type != 2) */
1101 const unsigned char *pretab = pretab_choice[gr_info->preflag];
1102 int i,max = -1;
1103 int cb = 0;
1104 int *m = map[sfreq][2];
1105 register real v = 0.0;
1106 int mc = 0;
1107
1108 /* long hash table values */
1109 for(i=0;i<3;i++)
1110 {
1111 int lp = l[i];
1112 const struct newhuff *h = ht+gr_info->table_select[i];
1113
1114 for(;lp;lp--,mc--)
1115 {
1116 MASK_STYPE x,y;
1117 if(!mc)
1118 {
1119 mc = *m++;
1120 cb = *m++;
1121#ifdef CUT_SFB21
1122 if(cb == 21)
1123 v = 0.0;
1124 else
1125#endif
1126 {
1127#ifdef REAL_IS_FIXED
1128 gainpow2_scale_idx = (int)(gr_info->pow2gain + (*scf << shift) - fr->gainpow2);
1129#endif
1130 v = gr_info->pow2gain[(*(scf++) + (*pretab++)) << shift];
1131 }
1132 }
1133 {
1134 const short *val = h->table;
1136#ifdef USE_NEW_HUFFTABLE
1137 while((y=val[(MASK_UTYPE)mask>>(BITSHIFT+4)])<0)
1138 {
1139 val -= y;
1140 num -= 4;
1141 mask <<= 4;
1142 }
1143 num -= (y >> 8);
1144 mask <<= (y >> 8);
1145 x = (y >> 4) & 0xf;
1146 y &= 0xf;
1147#else
1148 while((y=*val++)<0)
1149 {
1150 if (MSB_MASK) val -= y;
1151
1152 num--;
1153 mask <<= 1;
1154 }
1155 x = y >> 4;
1156 y &= 0xf;
1157#endif
1158 }
1159
1161 if(x == 15 && h->linbits)
1162 {
1163 max = cb;
1165 x += ((MASK_UTYPE) mask) >> (BITSHIFT+8-h->linbits);
1166 num -= h->linbits+1;
1167 mask <<= h->linbits;
1168 if(MSB_MASK) *xrpnt++ = REAL_MUL_SCALE_LAYER3(-ispow[x], v, gainpow2_scale_idx);
1169 else *xrpnt++ = REAL_MUL_SCALE_LAYER3( ispow[x], v, gainpow2_scale_idx);
1170
1171 mask <<= 1;
1172 }
1173 else if(x)
1174 {
1175 max = cb;
1176 if(MSB_MASK) *xrpnt++ = REAL_MUL_SCALE_LAYER3(-ispow[x], v, gainpow2_scale_idx);
1177 else *xrpnt++ = REAL_MUL_SCALE_LAYER3( ispow[x], v, gainpow2_scale_idx);
1178 num--;
1179
1180 mask <<= 1;
1181 }
1182 else *xrpnt++ = DOUBLE_TO_REAL(0.0);
1183
1185 if(y == 15 && h->linbits)
1186 {
1187 max = cb;
1189 y += ((MASK_UTYPE) mask) >> (BITSHIFT+8-h->linbits);
1190 num -= h->linbits+1;
1191 mask <<= h->linbits;
1192 if(MSB_MASK) *xrpnt++ = REAL_MUL_SCALE_LAYER3(-ispow[y], v, gainpow2_scale_idx);
1193 else *xrpnt++ = REAL_MUL_SCALE_LAYER3( ispow[y], v, gainpow2_scale_idx);
1194
1195 mask <<= 1;
1196 }
1197 else if(y)
1198 {
1199 max = cb;
1200 if(MSB_MASK) *xrpnt++ = REAL_MUL_SCALE_LAYER3(-ispow[y], v, gainpow2_scale_idx);
1201 else *xrpnt++ = REAL_MUL_SCALE_LAYER3( ispow[y], v, gainpow2_scale_idx);
1202
1203 num--;
1204 mask <<= 1;
1205 }
1206 else *xrpnt++ = DOUBLE_TO_REAL(0.0);
1207 }
1208 }
1209
1210 /* short (count1table) values */
1211 for(;l3 && (part2remain+num > 0);l3--)
1212 {
1213 const struct newhuff *h = htc+gr_info->count1table_select;
1214 const short *val = h->table;
1215 register short a;
1216
1218 while((a=*val++)<0)
1219 {
1220 if (MSB_MASK) val -= a;
1221
1222 num--;
1223 mask <<= 1;
1224 }
1225 if(part2remain+num <= 0)
1226 {
1227 num -= part2remain+num;
1228 break;
1229 }
1230
1231 for(i=0;i<4;i++)
1232 {
1233 if(!(i & 1))
1234 {
1235 if(!mc)
1236 {
1237 mc = *m++;
1238 cb = *m++;
1239#ifdef CUT_SFB21
1240 if(cb == 21)
1241 v = 0.0;
1242 else
1243#endif
1244 {
1245#ifdef REAL_IS_FIXED
1246 gainpow2_scale_idx = (int)(gr_info->pow2gain + (*scf << shift) - fr->gainpow2);
1247#endif
1248 v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
1249 }
1250 }
1251 mc--;
1252 }
1254 if( (a & (0x8>>i)) )
1255 {
1256 max = cb;
1257 if(part2remain+num <= 0)
1258 break;
1259
1260 if(MSB_MASK) *xrpnt++ = -REAL_SCALE_LAYER3(v, gainpow2_scale_idx);
1261 else *xrpnt++ = REAL_SCALE_LAYER3(v, gainpow2_scale_idx);
1262
1263 num--;
1264 mask <<= 1;
1265 }
1266 else *xrpnt++ = DOUBLE_TO_REAL(0.0);
1267 }
1268 }
1269
1270 gr_info->maxbandl = max+1;
1271 gr_info->maxb = fr->longLimit[sfreq][gr_info->maxbandl];
1272 }
1273
1274 part2remain += num;
1275 backbits(fr, num);
1276 num = 0;
1277
1278 }
1279 else
1280 {
1281 part2remain = 0;
1282 /* Not entirely sure what good values are, must be > 0. */
1283 gr_info->maxband[0] =
1284 gr_info->maxband[1] =
1285 gr_info->maxband[2] =
1286 gr_info->maxbandl = 1; /* sfb=maxband[lwin]*3 + lwin - mixed_block_flag must be >= 0 */
1287 gr_info->maxb = 1;
1288 }
1289
1290 while(xrpnt < &xr[SBLIMIT][0])
1291 *xrpnt++ = DOUBLE_TO_REAL(0.0);
1292
1293 while( part2remain > 16 )
1294 {
1295 skipbits(fr, 16); /* Dismiss stuffing Bits */
1296 part2remain -= 16;
1297 }
1298 if(part2remain > 0) skipbits(fr, part2remain);
1299 else if(part2remain < 0)
1300 {
1301 if(VERBOSE2)
1302 error1("Can't rewind stream by %d bits!",-part2remain);
1303 return 1; /* -> error */
1304 }
1305 return 0;
1306}
r l[0]
Definition: byte_order.h:168
Definition: _map.h:48
#define backbits(fr, nob)
Definition: getbits.h:18
static unsigned int getbits(mpg123_handle *fr, int number_of_bits)
Definition: getbits.h:32
#define getbitoffset(fr)
Definition: getbits.h:24
#define skipbits(fr, nob)
Definition: getbits.h:82
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLfloat * val
Definition: glext.h:7180
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
const GLfloat * m
Definition: glext.h:10848
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
static const struct newhuff htc[]
Definition: huffman.h:333
static const struct newhuff ht[]
Definition: huffman.h:296
#define a
Definition: ke_i.h:78
#define MASK_TYPE
Definition: layer3.c:784
static int * mapend[9][3]
Definition: layer3.c:157
#define REFRESH_MASK
Definition: layer3.c:788
#define MASK_STYPE
Definition: layer3.c:782
#define MSB_MASK
Definition: layer3.c:785
static real ispow[8207]
Definition: layer3.c:38
#define CHECK_XRPNT
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define shift
Definition: input.c:1755
#define REAL_SCALE_LAYER3(x, y)
#define DOUBLE_TO_REAL(x)
#define REAL_MUL_SCALE_LAYER3(x, y, z)
#define error1(s, a)
Definition: debug.h:125
int longLimit[9][23]
Definition: frame.h:140
int shortLimit[9][14]
Definition: frame.h:141
real gainpow2[256+118+4]
Definition: frame.h:142
#define max(a, b)
Definition: svc.c:63

Referenced by do_layer3().

◆ III_get_scale_factors_1()

static int III_get_scale_factors_1 ( mpg123_handle fr,
int scf,
struct gr_info_s *  gr_info,
int  ch,
int  gr 
)
static

Definition at line 585 of file layer3.c.

586{
587 const unsigned char slen[2][16] =
588 {
589 {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
590 {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}
591 };
592 int numbits;
593 int num0 = slen[0][gr_info->scalefac_compress];
594 int num1 = slen[1][gr_info->scalefac_compress];
595
596 if(gr_info->part2_3_length == 0)
597 {
598 int i;
599 for(i=0;i<39;i++)
600 *scf++ = 0;
601 return 0;
602 }
603
604 if(gr_info->block_type == 2)
605 {
606 int i=18;
607 numbits = (num0 + num1) * 18 /* num0 * (17+1?) + num1 * 18 */
608 - (gr_info->mixed_block_flag ? num0 : 0);
609 if(numbits > gr_info->part2_3_length)
610 return -1;
611
612 if(gr_info->mixed_block_flag)
613 {
614 for (i=8;i;i--)
615 *scf++ = getbits_fast(fr, num0);
616
617 i = 9;
618 }
619
620 for(;i;i--) *scf++ = getbits_fast(fr, num0);
621
622 for(i = 18; i; i--) *scf++ = getbits_fast(fr, num1);
623
624 *scf++ = 0; *scf++ = 0; *scf++ = 0; /* short[13][0..2] = 0 */
625 }
626 else
627 {
628 int i;
629 int scfsi = gr_info->scfsi;
630
631 if(scfsi < 0)
632 { /* scfsi < 0 => granule == 0 */
633 numbits = (num0 + num1) * 10 + num0;
634 if(numbits > gr_info->part2_3_length)
635 return -1;
636
637 for(i=11;i;i--) *scf++ = getbits_fast(fr, num0);
638
639 for(i=10;i;i--) *scf++ = getbits_fast(fr, num1);
640
641 *scf++ = 0;
642 }
643 else
644 {
645 numbits = !(scfsi & 0x8) * num0 * 6
646 + !(scfsi & 0x4) * num0 * 5
647 + !(scfsi & 0x2) * num1 * 5
648 + !(scfsi & 0x1) * num1 * 5;
649 if(numbits > gr_info->part2_3_length)
650 return -1;
651
652 if(!(scfsi & 0x8))
653 {
654 for (i=0;i<6;i++) *scf++ = getbits_fast(fr, num0);
655 }
656 else scf += 6;
657
658 if(!(scfsi & 0x4))
659 {
660 for (i=0;i<5;i++) *scf++ = getbits_fast(fr, num0);
661 }
662 else scf += 5;
663
664 if(!(scfsi & 0x2))
665 {
666 for(i=0;i<5;i++) *scf++ = getbits_fast(fr, num1);
667 }
668 else scf += 5;
669
670 if(!(scfsi & 0x1))
671 {
672 for (i=0;i<5;i++) *scf++ = getbits_fast(fr, num1);
673 }
674 else scf += 5;
675
676 *scf++ = 0; /* no l[21] in original sources */
677 }
678 }
679
680 return numbits;
681}
#define getbits_fast(fr, nob)
Definition: getbits.h:89

Referenced by do_layer3().

◆ III_get_scale_factors_2()

static int III_get_scale_factors_2 ( mpg123_handle fr,
int scf,
struct gr_info_s *  gr_info,
int  i_stereo 
)
static

Definition at line 684 of file layer3.c.

685{
686 const unsigned char *pnt;
687 int i,j,n=0,numbits=0;
688 unsigned int slen, slen2;
689
690 const unsigned char stab[3][6][4] =
691 {
692 {
693 { 6, 5, 5,5 } , { 6, 5, 7,3 } , { 11,10,0,0},
694 { 7, 7, 7,0 } , { 6, 6, 6,3 } , { 8, 8,5,0}
695 },
696 {
697 { 9, 9, 9,9 } , { 9, 9,12,6 } , { 18,18,0,0},
698 {12,12,12,0 } , {12, 9, 9,6 } , { 15,12,9,0}
699 },
700 {
701 { 6, 9, 9,9 } , { 6, 9,12,6 } , { 15,18,0,0},
702 { 6,15,12,0 } , { 6,12, 9,6 } , { 6,18,9,0}
703 }
704 };
705
706 if(i_stereo) /* i_stereo AND second channel -> do_layer3() checks this */
707 slen = i_slen2[gr_info->scalefac_compress>>1];
708 else
709 slen = n_slen2[gr_info->scalefac_compress];
710
711 gr_info->preflag = (slen>>15) & 0x1;
712
713 n = 0;
714 if( gr_info->block_type == 2 )
715 {
716 n++;
717 if(gr_info->mixed_block_flag) n++;
718 }
719
720 pnt = stab[n][(slen>>12)&0x7];
721
722 if(gr_info->part2_3_length == 0)
723 {
724 for(i=0;i<39;i++)
725 *scf++ = 0;
726 return 0;
727 }
728
729 slen2 = slen;
730 for(i=0;i<4;i++)
731 {
732 int num = slen2 & 0x7;
733 slen2 >>= 3;
734 if(num)
735 numbits += pnt[i] * num;
736 }
737 if(numbits > gr_info->part2_3_length)
738 return -1;
739
740 for(i=0;i<4;i++)
741 {
742 int num = slen & 0x7;
743 slen >>= 3;
744 if(num)
745 {
746 for(j=0;j<(int)(pnt[i]);j++) *scf++ = getbits_fast(fr, num);
747 }
748 else
749 for(j=0;j<(int)(pnt[i]);j++) *scf++ = 0;
750 }
751
752 n = (n << 1) + 1;
753 for(i=0;i<n;i++) *scf++ = 0;
754
755 return numbits;
756}
static unsigned int i_slen2[256]
Definition: layer3.c:160
static unsigned int n_slen2[512]
Definition: layer3.c:159

Referenced by do_layer3().

◆ III_get_side_info()

static int III_get_side_info ( mpg123_handle fr,
struct III_sideinfo si,
int  stereo,
int  ms_stereo,
long  sfreq,
int  single 
)
static

Definition at line 405 of file layer3.c.

406{
407 int ch, gr;
408 int powdiff = (single == SINGLE_MIX) ? 4 : 0;
409
410 const int tabs[2][5] = { { 2,9,5,3,4 } , { 1,8,1,2,9 } };
411 const int *tab = tabs[fr->lsf];
412
413 { /* First ensure we got enough bits available. */
414 unsigned int needbits = 0;
415 needbits += tab[1]; /* main_data_begin */
416 needbits += stereo == 1 ? tab[2] : tab[3]; /* private */
417 if(!fr->lsf)
418 needbits += stereo*4; /* scfsi */
419 /* For each granule for each channel ... */
420 needbits += tab[0]*stereo*(29+tab[4]+1+22+(!fr->lsf?1:0)+2);
421 if(fr->bits_avail < needbits) \
422 {
423 if(NOQUIET)
424 error2( "%u bits for side info needed, only %li available"
425 , needbits, fr->bits_avail );
426 return 1;
427 }
428 }
429
430 si->main_data_begin = getbits(fr, tab[1]);
431
432 if(si->main_data_begin > fr->bitreservoir)
433 {
434 if(!fr->to_ignore && VERBOSE2) fprintf(stderr, "Note: missing %d bytes in bit reservoir for frame %li\n", (int)(si->main_data_begin - fr->bitreservoir), (long)fr->num);
435
436 /* overwrite main_data_begin for the really available bit reservoir */
437 backbits(fr, tab[1]);
438 if(fr->lsf == 0)
439 {
440 fr->wordpointer[0] = (unsigned char) (fr->bitreservoir >> 1);
441 fr->wordpointer[1] = (unsigned char) ((fr->bitreservoir & 1) << 7);
442 }
443 else fr->wordpointer[0] = (unsigned char) fr->bitreservoir;
444
445 /* zero "side-info" data for a silence-frame
446 without touching audio data used as bit reservoir for following frame */
447 memset(fr->wordpointer+2, 0, fr->ssize-2);
448
449 /* reread the new bit reservoir offset */
450 si->main_data_begin = getbits(fr, tab[1]);
451 }
452
453 /* Keep track of the available data bytes for the bit reservoir.
454 CRC is included in ssize already. */
455 fr->bitreservoir = fr->bitreservoir + fr->framesize - fr->ssize;
456
457 /* Limit the reservoir to the max for MPEG 1.0 or 2.x . */
458 if(fr->bitreservoir > (unsigned int) (fr->lsf == 0 ? 511 : 255))
459 fr->bitreservoir = (fr->lsf == 0 ? 511 : 255);
460
461 /* Now back into less commented territory. It's code. It works. */
462
463 if (stereo == 1)
464 si->private_bits = getbits(fr, tab[2]);
465 else
466 si->private_bits = getbits(fr, tab[3]);
467
468 if(!fr->lsf) for(ch=0; ch<stereo; ch++)
469 {
470 si->ch[ch].gr[0].scfsi = -1;
471 si->ch[ch].gr[1].scfsi = getbits(fr, 4);
472 }
473
474 for (gr=0; gr<tab[0]; gr++)
475 for (ch=0; ch<stereo; ch++)
476 {
477 register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
478 unsigned int qss;
479 gr_info->part2_3_length = getbits(fr, 12);
480 gr_info->big_values = getbits(fr, 9);
481 if(gr_info->big_values > 288)
482 {
483 if(NOQUIET) error("big_values too large!");
484 gr_info->big_values = 288;
485 }
486 qss = getbits_fast(fr, 8);
487 gr_info->pow2gain = fr->gainpow2+256 - qss + powdiff;
488 if(ms_stereo)
489 gr_info->pow2gain += 2;
490#ifndef NO_MOREINFO
491 if(fr->pinfo)
492 fr->pinfo->qss[gr][ch] = qss;
493#endif
494 gr_info->scalefac_compress = getbits(fr, tab[4]);
495 if(gr_info->part2_3_length == 0)
496 {
497 if(gr_info->scalefac_compress > 0 && VERBOSE2)
498 error1( "scalefac_compress should be zero instead of %i"
499 , gr_info->scalefac_compress );
500 gr_info->scalefac_compress = 0;
501 }
502
503 /* 22 bits for if/else block */
504 if(getbits(fr,1))
505 { /* window switch flag */
506 int i;
507 gr_info->block_type = getbits_fast(fr, 2);
508 gr_info->mixed_block_flag = get1bit(fr);
509 gr_info->table_select[0] = getbits_fast(fr, 5);
510 gr_info->table_select[1] = getbits_fast(fr, 5);
511 /*
512 table_select[2] not needed, because there is no region2,
513 but to satisfy some verification tools we set it either.
514 */
515 gr_info->table_select[2] = 0;
516 for(i=0;i<3;i++)
517 {
518 unsigned int sbg = (getbits_fast(fr, 3)<<3);
519 gr_info->full_gain[i] = gr_info->pow2gain + sbg;
520#ifndef NO_MOREINFO
521 if(fr->pinfo)
522 fr->pinfo->sub_gain[gr][ch][i] = sbg / 8;
523#endif
524 }
525
526 if(gr_info->block_type == 0)
527 {
528 if(NOQUIET) error("Blocktype == 0 and window-switching == 1 not allowed.");
529 return 1;
530 }
531
532 /* region_count/start parameters are implicit in this case. */
533 if( (!fr->lsf || (gr_info->block_type == 2)) && !fr->mpeg25)
534 {
535 gr_info->region1start = 36>>1;
536 gr_info->region2start = 576>>1;
537 }
538 else
539 {
540 if(fr->mpeg25)
541 {
542 int r0c,r1c;
543 if((gr_info->block_type == 2) && (!gr_info->mixed_block_flag) ) r0c = 5;
544 else r0c = 7;
545
546 /* r0c+1+r1c+1 == 22, always. */
547 r1c = 20 - r0c;
548 gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ;
549 gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1;
550 }
551 else
552 {
553 gr_info->region1start = 54>>1;
554 gr_info->region2start = 576>>1;
555 }
556 }
557 }
558 else
559 {
560 int i,r0c,r1c;
561 for (i=0; i<3; i++)
562 gr_info->table_select[i] = getbits_fast(fr, 5);
563
564 r0c = getbits_fast(fr, 4); /* 0 .. 15 */
565 r1c = getbits_fast(fr, 3); /* 0 .. 7 */
566 gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ;
567
568 /* max(r0c+r1c+2) = 15+7+2 = 24 */
569 if(r0c+1+r1c+1 > 22) gr_info->region2start = 576>>1;
570 else gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1;
571
572 gr_info->block_type = 0;
573 gr_info->mixed_block_flag = 0;
574 }
575 if(!fr->lsf) gr_info->preflag = get1bit(fr);
576
577 gr_info->scalefac_scale = get1bit(fr);
578 gr_info->count1table_select = get1bit(fr);
579 }
580 return 0;
581}
unsigned char
Definition: typeof.h:29
#define get1bit(fr)
Definition: getbits.h:97
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static const struct bandInfoStruct bandInfo[9]
Definition: layer3.c:95
#define memset(x, y, z)
Definition: compat.h:39
unsigned main_data_begin
Definition: layer3.c:80
unsigned private_bits
Definition: layer3.c:81
unsigned int bitreservoir
Definition: frame.h:252
unsigned char * wordpointer
Definition: frame.h:229

Referenced by do_layer3().

◆ III_hybrid()

static void III_hybrid ( real  fsIn[SBLIMIT][SSLIMIT],
real  tsOut[SSLIMIT][SBLIMIT],
int  ch,
struct gr_info_s *  gr_info,
mpg123_handle fr 
)
static

Definition at line 1975 of file layer3.c.

1976{
1977 real (*block)[2][SBLIMIT*SSLIMIT] = fr->hybrid_block;
1978 int *blc = fr->hybrid_blc;
1979
1980 real *tspnt = (real *) tsOut;
1981 real *rawout1,*rawout2;
1982 int bt = 0;
1983 size_t sb = 0;
1984
1985 {
1986 int b = blc[ch];
1987 rawout1=block[b][ch];
1988 b=-b+1;
1989 rawout2=block[b][ch];
1990 blc[ch] = b;
1991 }
1992
1993 if(gr_info->mixed_block_flag)
1994 {
1995 sb = 2;
1996 opt_dct36(fr)(fsIn[0],rawout1,rawout2,win[0],tspnt);
1997 opt_dct36(fr)(fsIn[1],rawout1+18,rawout2+18,win1[0],tspnt+1);
1998 rawout1 += 36; rawout2 += 36; tspnt += 2;
1999 }
2000
2001 bt = gr_info->block_type;
2002 if(bt == 2)
2003 {
2004 for(; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36)
2005 {
2006 dct12(fsIn[sb] ,rawout1 ,rawout2 ,win[2] ,tspnt);
2007 dct12(fsIn[sb+1],rawout1+18,rawout2+18,win1[2],tspnt+1);
2008 }
2009 }
2010 else
2011 {
2012 for(; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36)
2013 {
2014 opt_dct36(fr)(fsIn[sb],rawout1,rawout2,win[bt],tspnt);
2015 opt_dct36(fr)(fsIn[sb+1],rawout1+18,rawout2+18,win1[bt],tspnt+1);
2016 }
2017 }
2018
2019 for(;sb<SBLIMIT;sb++,tspnt++)
2020 {
2021 int i;
2022 for(i=0;i<SSLIMIT;i++)
2023 {
2024 tspnt[i*SBLIMIT] = *rawout1++;
2025 *rawout2++ = DOUBLE_TO_REAL(0.0);
2026 }
2027 }
2028}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
static real win1[4][36]
static real win[4][36]
static void dct12(real *in, real *rawout1, real *rawout2, register real *wi, register real *ts)
Definition: layer3.c:1838
#define opt_dct36(fr)
Definition: optimize.h:391
int hybrid_blc[2]
Definition: frame.h:103
real hybrid_block[2][2][SBLIMIT *SSLIMIT]
Definition: frame.h:102
static unsigned int block
Definition: xmlmemory.c:101

Referenced by do_layer3().

◆ III_i_stereo()

static void III_i_stereo ( real  xr_buf[2][SBLIMIT][SSLIMIT],
int scalefac,
struct gr_info_s *  gr_info,
int  sfreq,
int  ms_stereo,
int  lsf 
)
static

Definition at line 1310 of file layer3.c.

1311{
1312 real (*xr)[SBLIMIT*SSLIMIT] = (real (*)[SBLIMIT*SSLIMIT] ) xr_buf;
1313 const struct bandInfoStruct *bi = &bandInfo[sfreq];
1314
1315 const real *tab1,*tab2;
1316
1317#if 1
1318 int tab;
1319/* TODO: optimize as static */
1320 const real *tabs[3][2][2] =
1321 {
1322 { { tan1_1,tan2_1 } , { tan1_2,tan2_2 } },
1323 { { pow1_1[0],pow2_1[0] } , { pow1_2[0],pow2_2[0] } },
1324 { { pow1_1[1],pow2_1[1] } , { pow1_2[1],pow2_2[1] } }
1325 };
1326
1327 tab = lsf + (gr_info->scalefac_compress & lsf);
1328 tab1 = tabs[tab][ms_stereo][0];
1329 tab2 = tabs[tab][ms_stereo][1];
1330#else
1331 if(lsf)
1332 {
1333 int p = gr_info->scalefac_compress & 0x1;
1334 if(ms_stereo)
1335 {
1336 tab1 = pow1_2[p];
1337 tab2 = pow2_2[p];
1338 }
1339 else
1340 {
1341 tab1 = pow1_1[p];
1342 tab2 = pow2_1[p];
1343 }
1344 }
1345 else
1346 {
1347 if(ms_stereo)
1348 {
1349 tab1 = tan1_2;
1350 tab2 = tan2_2;
1351 }
1352 else
1353 {
1354 tab1 = tan1_1;
1355 tab2 = tan2_1;
1356 }
1357 }
1358#endif
1359
1360 if(gr_info->block_type == 2)
1361 {
1362 int lwin,do_l = 0;
1363 if( gr_info->mixed_block_flag ) do_l = 1;
1364
1365 for(lwin=0;lwin<3;lwin++)
1366 { /* process each window */
1367 /* get first band with zero values */
1368 int is_p,sb,idx,sfb = gr_info->maxband[lwin]; /* sfb is minimal 3 for mixed mode */
1369 if(sfb > 3) do_l = 0;
1370
1371 for(;sfb<12;sfb++)
1372 {
1373 is_p = scalefac[sfb*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */
1374 if(is_p != 7)
1375 {
1376 real t1,t2;
1377 sb = bi->shortDiff[sfb];
1378 idx = bi->shortIdx[sfb] + lwin;
1379 t1 = tab1[is_p]; t2 = tab2[is_p];
1380 for (; sb > 0; sb--,idx+=3)
1381 {
1382 real v = xr[0][idx];
1383 xr[0][idx] = REAL_MUL_15(v, t1);
1384 xr[1][idx] = REAL_MUL_15(v, t2);
1385 }
1386 }
1387 }
1388
1389#if 1
1390/* in the original: copy 10 to 11 , here: copy 11 to 12
1391maybe still wrong??? (copy 12 to 13?) */
1392 is_p = scalefac[11*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */
1393 sb = bi->shortDiff[12];
1394 idx = bi->shortIdx[12] + lwin;
1395#else
1396 is_p = scalefac[10*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */
1397 sb = bi->shortDiff[11];
1398 idx = bi->shortIdx[11] + lwin;
1399#endif
1400 if(is_p != 7)
1401 {
1402 real t1,t2;
1403 t1 = tab1[is_p]; t2 = tab2[is_p];
1404 for( ; sb > 0; sb--,idx+=3 )
1405 {
1406 real v = xr[0][idx];
1407 xr[0][idx] = REAL_MUL_15(v, t1);
1408 xr[1][idx] = REAL_MUL_15(v, t2);
1409 }
1410 }
1411 } /* end for(lwin; .. ; . ) */
1412
1413 /* also check l-part, if ALL bands in the three windows are 'empty' and mode = mixed_mode */
1414 if(do_l)
1415 {
1416 int sfb = gr_info->maxbandl;
1417 int idx;
1418 if(sfb > 21) return; /* similarity fix related to CVE-2006-1655 */
1419
1420 idx = bi->longIdx[sfb];
1421 for( ; sfb<8; sfb++ )
1422 {
1423 int sb = bi->longDiff[sfb];
1424 int is_p = scalefac[sfb]; /* scale: 0-15 */
1425 if(is_p != 7)
1426 {
1427 real t1,t2;
1428 t1 = tab1[is_p]; t2 = tab2[is_p];
1429 for( ; sb > 0; sb--,idx++)
1430 {
1431 real v = xr[0][idx];
1432 xr[0][idx] = REAL_MUL_15(v, t1);
1433 xr[1][idx] = REAL_MUL_15(v, t2);
1434 }
1435 }
1436 else idx += sb;
1437 }
1438 }
1439 }
1440 else
1441 { /* ((gr_info->block_type != 2)) */
1442 int sfb = gr_info->maxbandl;
1443 int is_p,idx;
1444 if(sfb > 21) return; /* tightened fix for CVE-2006-1655 */
1445
1446 idx = bi->longIdx[sfb];
1447 for ( ; sfb<21; sfb++)
1448 {
1449 int sb = bi->longDiff[sfb];
1450 is_p = scalefac[sfb]; /* scale: 0-15 */
1451 if(is_p != 7)
1452 {
1453 real t1,t2;
1454 t1 = tab1[is_p]; t2 = tab2[is_p];
1455 for( ; sb > 0; sb--,idx++)
1456 {
1457 real v = xr[0][idx];
1458 xr[0][idx] = REAL_MUL_15(v, t1);
1459 xr[1][idx] = REAL_MUL_15(v, t2);
1460 }
1461 }
1462 else idx += sb;
1463 }
1464
1465 is_p = scalefac[20];
1466 if(is_p != 7)
1467 { /* copy l-band 20 to l-band 21 */
1468 int sb;
1469 real t1 = tab1[is_p],t2 = tab2[is_p];
1470
1471 for( sb = bi->longDiff[21]; sb > 0; sb--,idx++ )
1472 {
1473 real v = xr[0][idx];
1474 xr[0][idx] = REAL_MUL_15(v, t1);
1475 xr[1][idx] = REAL_MUL_15(v, t2);
1476 }
1477 }
1478 }
1479}
unsigned int idx
Definition: utils.c:41
GLfloat GLfloat p
Definition: glext.h:8902
static const short tab2[]
Definition: huffman.h:32
static const short tab1[]
Definition: huffman.h:27
#define REAL_MUL_15(x, y)
unsigned char longDiff[22]
Definition: layer3.c:89
unsigned short shortIdx[14]
Definition: layer3.c:90
unsigned char shortDiff[13]
Definition: layer3.c:91
unsigned short longIdx[23]
Definition: layer3.c:88

Referenced by do_layer3().

◆ init_layer3()

void init_layer3 ( void  )

Definition at line 183 of file layer3.c.

184{
185 int i,j,k,l;
186
187#if !defined(REAL_IS_FIXED) || !defined(PRECALC_TABLES)
188 for(i=0;i<8207;i++)
189 ispow[i] = DOUBLE_TO_REAL_POW43(pow((double)i,(double)4.0/3.0));
190
191 for(i=0;i<8;i++)
192 {
193 const double Ci[8] = {-0.6,-0.535,-0.33,-0.185,-0.095,-0.041,-0.0142,-0.0037};
194 double sq = sqrt(1.0+Ci[i]*Ci[i]);
195 aa_cs[i] = DOUBLE_TO_REAL(1.0/sq);
196 aa_ca[i] = DOUBLE_TO_REAL(Ci[i]/sq);
197 }
198
199 for(i=0;i<18;i++)
200 {
201 win[0][i] = win[1][i] =
202 DOUBLE_TO_REAL( 0.5*sin(M_PI/72.0 * (double)(2*(i+0) +1)) / cos(M_PI * (double)(2*(i+0) +19) / 72.0) );
203 win[0][i+18] = win[3][i+18] =
204 DOUBLE_TO_REAL( 0.5*sin(M_PI/72.0 * (double)(2*(i+18)+1)) / cos(M_PI * (double)(2*(i+18)+19) / 72.0) );
205 }
206 for(i=0;i<6;i++)
207 {
208 win[1][i+18] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 ));
209 win[3][i+12] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (2*(i+12)+19) / 72.0 ));
210 win[1][i+24] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+13) ) / cos ( M_PI * (double) (2*(i+24)+19) / 72.0 ));
211 win[1][i+30] = win[3][i] = DOUBLE_TO_REAL(0.0);
212 win[3][i+6 ] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+1 ) ) / cos ( M_PI * (double) (2*(i+6 )+19) / 72.0 ));
213 }
214
215 for(i=0;i<9;i++)
216 COS9[i] = DOUBLE_TO_REAL(cos( M_PI / 18.0 * (double) i));
217
218 for(i=0;i<9;i++)
219 tfcos36[i] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (i*2+1) / 36.0 ));
220
221 for(i=0;i<3;i++)
222 tfcos12[i] = DOUBLE_TO_REAL(0.5 / cos ( M_PI * (double) (i*2+1) / 12.0 ));
223
224 COS6_1 = DOUBLE_TO_REAL(cos( M_PI / 6.0 * (double) 1));
225 COS6_2 = DOUBLE_TO_REAL(cos( M_PI / 6.0 * (double) 2));
226
227#ifdef NEW_DCT9
228 cos9[0] = DOUBLE_TO_REAL(cos(1.0*M_PI/9.0));
229 cos9[1] = DOUBLE_TO_REAL(cos(5.0*M_PI/9.0));
230 cos9[2] = DOUBLE_TO_REAL(cos(7.0*M_PI/9.0));
231 cos18[0] = DOUBLE_TO_REAL(cos(1.0*M_PI/18.0));
232 cos18[1] = DOUBLE_TO_REAL(cos(11.0*M_PI/18.0));
233 cos18[2] = DOUBLE_TO_REAL(cos(13.0*M_PI/18.0));
234#endif
235
236 for(i=0;i<12;i++)
237 {
238 win[2][i] = DOUBLE_TO_REAL(0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*i+7) / 24.0 ));
239 }
240
241 for(i=0;i<16;i++)
242 {
243 double t = tan( (double) i * M_PI / 12.0 );
244 tan1_1[i] = DOUBLE_TO_REAL_15(t / (1.0+t));
245 tan2_1[i] = DOUBLE_TO_REAL_15(1.0 / (1.0 + t));
246 tan1_2[i] = DOUBLE_TO_REAL_15(M_SQRT2 * t / (1.0+t));
247 tan2_2[i] = DOUBLE_TO_REAL_15(M_SQRT2 / (1.0 + t));
248 }
249
250 for(i=0;i<32;i++)
251 {
252 for(j=0;j<2;j++)
253 {
254 double base = pow(2.0,-0.25*(j+1.0));
255 double p1=1.0,p2=1.0;
256 if(i > 0)
257 {
258 if( i & 1 ) p1 = pow(base,(i+1.0)*0.5);
259 else p2 = pow(base,i*0.5);
260 }
261 pow1_1[j][i] = DOUBLE_TO_REAL_15(p1);
262 pow2_1[j][i] = DOUBLE_TO_REAL_15(p2);
263 pow1_2[j][i] = DOUBLE_TO_REAL_15(M_SQRT2 * p1);
264 pow2_2[j][i] = DOUBLE_TO_REAL_15(M_SQRT2 * p2);
265 }
266 }
267#endif
268
269 for(j=0;j<4;j++)
270 {
271 const int len[4] = { 36,36,12,36 };
272 for(i=0;i<len[j];i+=2) win1[j][i] = + win[j][i];
273
274 for(i=1;i<len[j];i+=2) win1[j][i] = - win[j][i];
275 }
276
277 for(j=0;j<9;j++)
278 {
279 const struct bandInfoStruct *bi = &bandInfo[j];
280 int *mp;
281 int cb,lwin;
282 const unsigned char *bdf;
283 int switch_idx;
284
285 mp = map[j][0] = mapbuf0[j];
286 bdf = bi->longDiff;
287 switch_idx = (j < 3) ? 8 : 6;
288 for(i=0,cb = 0; cb < switch_idx ; cb++,i+=*bdf++)
289 {
290 *mp++ = (*bdf) >> 1;
291 *mp++ = i;
292 *mp++ = 3;
293 *mp++ = cb;
294 }
295 bdf = bi->shortDiff+3;
296 for(cb=3;cb<13;cb++)
297 {
298 int l = (*bdf++) >> 1;
299 for(lwin=0;lwin<3;lwin++)
300 {
301 *mp++ = l;
302 *mp++ = i + lwin;
303 *mp++ = lwin;
304 *mp++ = cb;
305 }
306 i += 6*l;
307 }
308 mapend[j][0] = mp;
309
310 mp = map[j][1] = mapbuf1[j];
311 bdf = bi->shortDiff+0;
312 for(i=0,cb=0;cb<13;cb++)
313 {
314 int l = (*bdf++) >> 1;
315 for(lwin=0;lwin<3;lwin++)
316 {
317 *mp++ = l;
318 *mp++ = i + lwin;
319 *mp++ = lwin;
320 *mp++ = cb;
321 }
322 i += 6*l;
323 }
324 mapend[j][1] = mp;
325
326 mp = map[j][2] = mapbuf2[j];
327 bdf = bi->longDiff;
328 for(cb = 0; cb < 22 ; cb++)
329 {
330 *mp++ = (*bdf++) >> 1;
331 *mp++ = cb;
332 }
333 mapend[j][2] = mp;
334 }
335
336 /* Now for some serious loopings! */
337 for(i=0;i<5;i++)
338 for(j=0;j<6;j++)
339 for(k=0;k<6;k++)
340 {
341 int n = k + j * 6 + i * 36;
342 i_slen2[n] = i|(j<<3)|(k<<6)|(3<<12);
343 }
344 for(i=0;i<4;i++)
345 for(j=0;j<4;j++)
346 for(k=0;k<4;k++)
347 {
348 int n = k + j * 4 + i * 16;
349 i_slen2[n+180] = i|(j<<3)|(k<<6)|(4<<12);
350 }
351 for(i=0;i<4;i++)
352 for(j=0;j<3;j++)
353 {
354 int n = j + i * 3;
355 i_slen2[n+244] = i|(j<<3) | (5<<12);
356 n_slen2[n+500] = i|(j<<3) | (2<<12) | (1<<15);
357 }
358 for(i=0;i<5;i++)
359 for(j=0;j<5;j++)
360 for(k=0;k<4;k++)
361 for(l=0;l<4;l++)
362 {
363 int n = l + k * 4 + j * 16 + i * 80;
364 n_slen2[n] = i|(j<<3)|(k<<6)|(l<<9)|(0<<12);
365 }
366 for(i=0;i<5;i++)
367 for(j=0;j<5;j++)
368 for(k=0;k<4;k++)
369 {
370 int n = k + j * 4 + i * 20;
371 n_slen2[n+400] = i|(j<<3)|(k<<6)|(1<<12);
372 }
373}
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL tan(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
double pow(double x, double y)
Definition: freeldr.c:113
GLdouble GLdouble t
Definition: gl.h:2047
GLenum GLsizei len
Definition: glext.h:6722
static int mapbuf0[9][152]
Definition: layer3.c:153
static int mapbuf1[9][156]
Definition: layer3.c:154
static int mapbuf2[9][44]
Definition: layer3.c:155
#define M_PI
Definition: macros.h:263
#define DOUBLE_TO_REAL_15(x)
#define DOUBLE_TO_REAL_POW43(x)
#define M_SQRT2
int k
Definition: mpi.c:3369

◆ init_layer3_gainpow2()

real init_layer3_gainpow2 ( mpg123_handle fr,
int  i 
)

Definition at line 172 of file layer3.c.

173{
174#if defined(REAL_IS_FIXED) && defined(PRECALC_TABLES)
175 return gainpow2[i+256];
176#else
177 return DOUBLE_TO_REAL_SCALE_LAYER3(pow((double)2.0,-0.25 * (double) (i+210)),i+256);
178#endif
179}
#define DOUBLE_TO_REAL_SCALE_LAYER3(x, y)

◆ init_layer3_stuff()

void init_layer3_stuff ( mpg123_handle fr,
real(*)(mpg123_handle *fr, int i gainpow2 
)

Definition at line 376 of file layer3.c.

377{
378 int i,j;
379
380 for(i=-256;i<118+4;i++) fr->gainpow2[i+256] = gainpow2(fr,i);
381
382 for(j=0;j<9;j++)
383 {
384 for(i=0;i<23;i++)
385 {
386 fr->longLimit[j][i] = (bandInfo[j].longIdx[i] - 1 + 8) / 18 + 1;
387 if(fr->longLimit[j][i] > (fr->down_sample_sblimit) )
388 fr->longLimit[j][i] = fr->down_sample_sblimit;
389 }
390 for(i=0;i<14;i++)
391 {
392 fr->shortLimit[j][i] = (bandInfo[j].shortIdx[i] - 1) / 18 + 1;
393 if(fr->shortLimit[j][i] > (fr->down_sample_sblimit) )
394 fr->shortLimit[j][i] = fr->down_sample_sblimit;
395 }
396 }
397}
int down_sample_sblimit
Definition: frame.h:194

Variable Documentation

◆ aa_ca

real aa_ca[8]
static

Definition at line 39 of file layer3.c.

Referenced by III_antialias(), and init_layer3().

◆ aa_cs

real aa_cs[8]
static

Definition at line 39 of file layer3.c.

Referenced by III_antialias(), and init_layer3().

◆ bandInfo

◆ i_slen2

unsigned int i_slen2[256]
static

Definition at line 160 of file layer3.c.

Referenced by III_get_scale_factors_2(), and init_layer3().

◆ ispow

real ispow[8207]
static

Definition at line 38 of file layer3.c.

Referenced by III_dequantize_sample(), and init_layer3().

◆ map

int* map[9][3]
static

Definition at line 156 of file layer3.c.

◆ mapbuf0

int mapbuf0[9][152]
static

Definition at line 153 of file layer3.c.

Referenced by init_layer3().

◆ mapbuf1

int mapbuf1[9][156]
static

Definition at line 154 of file layer3.c.

Referenced by init_layer3().

◆ mapbuf2

int mapbuf2[9][44]
static

Definition at line 155 of file layer3.c.

Referenced by init_layer3().

◆ mapend

int* mapend[9][3]
static

Definition at line 157 of file layer3.c.

Referenced by III_dequantize_sample(), and init_layer3().

◆ n_slen2

unsigned int n_slen2[512]
static

Definition at line 159 of file layer3.c.

Referenced by III_get_scale_factors_2(), and init_layer3().

◆ pretab_choice

unsigned char pretab_choice[2][22]
static
Initial value:
=
{
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0}
}

Definition at line 758 of file layer3.c.

Referenced by fill_pinfo_side(), and III_dequantize_sample().