author | erik <erik> | 2007-02-08 01:45:16 (UTC) |
---|---|---|
committer | erik <erik> | 2007-02-08 01:45:16 (UTC) |
commit | 2e497f7cae45184184e2416114887095735958f5 (patch) (unidiff) | |
tree | a6b399d9bce5854dc7ad6c985b48965cf20680b0 /core | |
parent | 853b61f97e718359bef95147ab3c7beb0705acda (diff) | |
download | opie-2e497f7cae45184184e2416114887095735958f5.zip opie-2e497f7cae45184184e2416114887095735958f5.tar.gz opie-2e497f7cae45184184e2416114887095735958f5.tar.bz2 |
Each file in this commit has a problem where it is possible to dereference
a pointer without that pointer being valid. This commit fixes each instance
of that.
-rw-r--r-- | core/multimedia/opieplayer/modplug/sndfile.cpp | 5 | ||||
-rw-r--r-- | core/multimedia/opieplayer/vorbis/tremor/block.c | 6 | ||||
-rw-r--r-- | core/multimedia/opieplayer/vorbis/tremor/info.c | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/modplug/sndfile.cpp b/core/multimedia/opieplayer/modplug/sndfile.cpp index 1d0d610..799555c 100644 --- a/core/multimedia/opieplayer/modplug/sndfile.cpp +++ b/core/multimedia/opieplayer/modplug/sndfile.cpp | |||
@@ -1646,193 +1646,196 @@ DWORD CSoundFile::TransposeToFrequency(int transp, int ftune) | |||
1646 | fscale | 1646 | fscale |
1647 | fstp st(1) | 1647 | fstp st(1) |
1648 | fmul st(1), st(0) | 1648 | fmul st(1), st(0) |
1649 | faddp st(1), st(0) | 1649 | faddp st(1), st(0) |
1650 | fistp freq | 1650 | fistp freq |
1651 | } | 1651 | } |
1652 | UINT derr = freq % 11025; | 1652 | UINT derr = freq % 11025; |
1653 | if (derr <= 8) freq -= derr; | 1653 | if (derr <= 8) freq -= derr; |
1654 | if (derr >= 11015) freq += 11025-derr; | 1654 | if (derr >= 11015) freq += 11025-derr; |
1655 | derr = freq % 1000; | 1655 | derr = freq % 1000; |
1656 | if (derr <= 5) freq -= derr; | 1656 | if (derr <= 5) freq -= derr; |
1657 | if (derr >= 995) freq += 1000-derr; | 1657 | if (derr >= 995) freq += 1000-derr; |
1658 | return freq; | 1658 | return freq; |
1659 | #endif | 1659 | #endif |
1660 | } | 1660 | } |
1661 | 1661 | ||
1662 | 1662 | ||
1663 | // returns 12*128*log2(freq/8363) | 1663 | // returns 12*128*log2(freq/8363) |
1664 | int CSoundFile::FrequencyToTranspose(DWORD freq) | 1664 | int CSoundFile::FrequencyToTranspose(DWORD freq) |
1665 | //---------------------------------------------- | 1665 | //---------------------------------------------- |
1666 | { | 1666 | { |
1667 | //---GCCFIX: Removed assembly. | 1667 | //---GCCFIX: Removed assembly. |
1668 | return int(1536*(log(freq/8363)/log(2))); | 1668 | return int(1536*(log(freq/8363)/log(2))); |
1669 | 1669 | ||
1670 | #ifdef WIN32 | 1670 | #ifdef WIN32 |
1671 | const float _f1_8363 = 1.0f / 8363.0f; | 1671 | const float _f1_8363 = 1.0f / 8363.0f; |
1672 | const float _factor = 128 * 12; | 1672 | const float _factor = 128 * 12; |
1673 | LONG result; | 1673 | LONG result; |
1674 | 1674 | ||
1675 | if (!freq) return 0; | 1675 | if (!freq) return 0; |
1676 | _asm { | 1676 | _asm { |
1677 | fld _factor | 1677 | fld _factor |
1678 | fild freq | 1678 | fild freq |
1679 | fld _f1_8363 | 1679 | fld _f1_8363 |
1680 | fmulp st(1), st(0) | 1680 | fmulp st(1), st(0) |
1681 | fyl2x | 1681 | fyl2x |
1682 | fistp result | 1682 | fistp result |
1683 | } | 1683 | } |
1684 | return result; | 1684 | return result; |
1685 | #endif | 1685 | #endif |
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | 1688 | ||
1689 | void CSoundFile::FrequencyToTranspose(MODINSTRUMENT *psmp) | 1689 | void CSoundFile::FrequencyToTranspose(MODINSTRUMENT *psmp) |
1690 | //-------------------------------------------------------- | 1690 | //-------------------------------------------------------- |
1691 | { | 1691 | { |
1692 | int f2t = FrequencyToTranspose(psmp->nC4Speed); | 1692 | int f2t = FrequencyToTranspose(psmp->nC4Speed); |
1693 | int transp = f2t >> 7; | 1693 | int transp = f2t >> 7; |
1694 | int ftune = f2t & 0x7F; | 1694 | int ftune = f2t & 0x7F; |
1695 | if (ftune > 80) | 1695 | if (ftune > 80) |
1696 | { | 1696 | { |
1697 | transp++; | 1697 | transp++; |
1698 | ftune -= 128; | 1698 | ftune -= 128; |
1699 | } | 1699 | } |
1700 | if (transp > 127) transp = 127; | 1700 | if (transp > 127) transp = 127; |
1701 | if (transp < -127) transp = -127; | 1701 | if (transp < -127) transp = -127; |
1702 | psmp->RelativeTone = transp; | 1702 | psmp->RelativeTone = transp; |
1703 | psmp->nFineTune = ftune; | 1703 | psmp->nFineTune = ftune; |
1704 | } | 1704 | } |
1705 | 1705 | ||
1706 | 1706 | ||
1707 | void CSoundFile::CheckCPUUsage(UINT nCPU) | 1707 | void CSoundFile::CheckCPUUsage(UINT nCPU) |
1708 | //--------------------------------------- | 1708 | //--------------------------------------- |
1709 | { | 1709 | { |
1710 | if (nCPU > 100) nCPU = 100; | 1710 | if (nCPU > 100) nCPU = 100; |
1711 | gnCPUUsage = nCPU; | 1711 | gnCPUUsage = nCPU; |
1712 | if (nCPU < 90) | 1712 | if (nCPU < 90) |
1713 | { | 1713 | { |
1714 | m_dwSongFlags &= ~SONG_CPUVERYHIGH; | 1714 | m_dwSongFlags &= ~SONG_CPUVERYHIGH; |
1715 | } else | 1715 | } else |
1716 | if ((m_dwSongFlags & SONG_CPUVERYHIGH) && (nCPU >= 94)) | 1716 | if ((m_dwSongFlags & SONG_CPUVERYHIGH) && (nCPU >= 94)) |
1717 | { | 1717 | { |
1718 | UINT i=MAX_CHANNELS; | 1718 | UINT i=MAX_CHANNELS; |
1719 | while (i >= 8) | 1719 | while (i >= 8) |
1720 | { | 1720 | { |
1721 | i--; | 1721 | i--; |
1722 | if (Chn[i].nLength) | 1722 | if (Chn[i].nLength) |
1723 | { | 1723 | { |
1724 | Chn[i].nLength = Chn[i].nPos = 0; | 1724 | Chn[i].nLength = Chn[i].nPos = 0; |
1725 | nCPU -= 2; | 1725 | nCPU -= 2; |
1726 | if (nCPU < 94) break; | 1726 | if (nCPU < 94) break; |
1727 | } | 1727 | } |
1728 | } | 1728 | } |
1729 | } else | 1729 | } else |
1730 | if (nCPU > 90) | 1730 | if (nCPU > 90) |
1731 | { | 1731 | { |
1732 | m_dwSongFlags |= SONG_CPUVERYHIGH; | 1732 | m_dwSongFlags |= SONG_CPUVERYHIGH; |
1733 | } | 1733 | } |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | 1736 | ||
1737 | BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName) | 1737 | BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName) |
1738 | //--------------------------------------------------------- | 1738 | //--------------------------------------------------------- |
1739 | { | 1739 | { |
1740 | char szName[MAX_PATTERNNAME] = ""; // changed from CHAR | 1740 | char szName[MAX_PATTERNNAME] = ""; // changed from CHAR |
1741 | if (nPat >= MAX_PATTERNS) return FALSE; | 1741 | if (nPat >= MAX_PATTERNS) return FALSE; |
1742 | if (lpszName) lstrcpyn(szName, lpszName, MAX_PATTERNNAME); | 1742 | if (lpszName) |
1743 | lstrcpyn(szName, lpszName, MAX_PATTERNNAME); | ||
1744 | else | ||
1745 | return FALSE; | ||
1743 | szName[MAX_PATTERNNAME-1] = 0; | 1746 | szName[MAX_PATTERNNAME-1] = 0; |
1744 | if (!m_lpszPatternNames) m_nPatternNames = 0; | 1747 | if (!m_lpszPatternNames) m_nPatternNames = 0; |
1745 | if (nPat >= m_nPatternNames) | 1748 | if (nPat >= m_nPatternNames) |
1746 | { | 1749 | { |
1747 | if (!lpszName[0]) return TRUE; | 1750 | if (!lpszName[0]) return TRUE; |
1748 | UINT len = (nPat+1)*MAX_PATTERNNAME; | 1751 | UINT len = (nPat+1)*MAX_PATTERNNAME; |
1749 | char *p = new char[len]; // changed from CHAR | 1752 | char *p = new char[len]; // changed from CHAR |
1750 | if (!p) return FALSE; | 1753 | if (!p) return FALSE; |
1751 | memset(p, 0, len); | 1754 | memset(p, 0, len); |
1752 | if (m_lpszPatternNames) | 1755 | if (m_lpszPatternNames) |
1753 | { | 1756 | { |
1754 | memcpy(p, m_lpszPatternNames, m_nPatternNames * MAX_PATTERNNAME); | 1757 | memcpy(p, m_lpszPatternNames, m_nPatternNames * MAX_PATTERNNAME); |
1755 | delete m_lpszPatternNames; | 1758 | delete m_lpszPatternNames; |
1756 | m_lpszPatternNames = NULL; | 1759 | m_lpszPatternNames = NULL; |
1757 | } | 1760 | } |
1758 | m_lpszPatternNames = p; | 1761 | m_lpszPatternNames = p; |
1759 | m_nPatternNames = nPat + 1; | 1762 | m_nPatternNames = nPat + 1; |
1760 | } | 1763 | } |
1761 | memcpy(m_lpszPatternNames + nPat * MAX_PATTERNNAME, szName, MAX_PATTERNNAME); | 1764 | memcpy(m_lpszPatternNames + nPat * MAX_PATTERNNAME, szName, MAX_PATTERNNAME); |
1762 | return TRUE; | 1765 | return TRUE; |
1763 | } | 1766 | } |
1764 | 1767 | ||
1765 | 1768 | ||
1766 | BOOL CSoundFile::GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize) const | 1769 | BOOL CSoundFile::GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize) const |
1767 | //--------------------------------------------------------------------------- | 1770 | //--------------------------------------------------------------------------- |
1768 | { | 1771 | { |
1769 | if ((!lpszName) || (!cbSize)) return FALSE; | 1772 | if ((!lpszName) || (!cbSize)) return FALSE; |
1770 | lpszName[0] = 0; | 1773 | lpszName[0] = 0; |
1771 | if (cbSize > MAX_PATTERNNAME) cbSize = MAX_PATTERNNAME; | 1774 | if (cbSize > MAX_PATTERNNAME) cbSize = MAX_PATTERNNAME; |
1772 | if ((m_lpszPatternNames) && (nPat < m_nPatternNames)) | 1775 | if ((m_lpszPatternNames) && (nPat < m_nPatternNames)) |
1773 | { | 1776 | { |
1774 | memcpy(lpszName, m_lpszPatternNames + nPat * MAX_PATTERNNAME, cbSize); | 1777 | memcpy(lpszName, m_lpszPatternNames + nPat * MAX_PATTERNNAME, cbSize); |
1775 | lpszName[cbSize-1] = 0; | 1778 | lpszName[cbSize-1] = 0; |
1776 | return TRUE; | 1779 | return TRUE; |
1777 | } | 1780 | } |
1778 | return FALSE; | 1781 | return FALSE; |
1779 | } | 1782 | } |
1780 | 1783 | ||
1781 | 1784 | ||
1782 | #ifndef FASTSOUNDLIB | 1785 | #ifndef FASTSOUNDLIB |
1783 | 1786 | ||
1784 | UINT CSoundFile::DetectUnusedSamples(BOOL *pbIns) | 1787 | UINT CSoundFile::DetectUnusedSamples(BOOL *pbIns) |
1785 | //----------------------------------------------- | 1788 | //----------------------------------------------- |
1786 | { | 1789 | { |
1787 | UINT nExt = 0; | 1790 | UINT nExt = 0; |
1788 | 1791 | ||
1789 | if (!pbIns) return 0; | 1792 | if (!pbIns) return 0; |
1790 | if (m_nInstruments) | 1793 | if (m_nInstruments) |
1791 | { | 1794 | { |
1792 | memset(pbIns, 0, MAX_SAMPLES * sizeof(BOOL)); | 1795 | memset(pbIns, 0, MAX_SAMPLES * sizeof(BOOL)); |
1793 | for (UINT ipat=0; ipat<MAX_PATTERNS; ipat++) | 1796 | for (UINT ipat=0; ipat<MAX_PATTERNS; ipat++) |
1794 | { | 1797 | { |
1795 | MODCOMMAND *p = Patterns[ipat]; | 1798 | MODCOMMAND *p = Patterns[ipat]; |
1796 | if (p) | 1799 | if (p) |
1797 | { | 1800 | { |
1798 | UINT jmax = PatternSize[ipat] * m_nChannels; | 1801 | UINT jmax = PatternSize[ipat] * m_nChannels; |
1799 | for (UINT j=0; j<jmax; j++, p++) | 1802 | for (UINT j=0; j<jmax; j++, p++) |
1800 | { | 1803 | { |
1801 | if ((p->note) && (p->note <= 120)) | 1804 | if ((p->note) && (p->note <= 120)) |
1802 | { | 1805 | { |
1803 | if ((p->instr) && (p->instr < MAX_INSTRUMENTS)) | 1806 | if ((p->instr) && (p->instr < MAX_INSTRUMENTS)) |
1804 | { | 1807 | { |
1805 | INSTRUMENTHEADER *penv = Headers[p->instr]; | 1808 | INSTRUMENTHEADER *penv = Headers[p->instr]; |
1806 | if (penv) | 1809 | if (penv) |
1807 | { | 1810 | { |
1808 | UINT n = penv->Keyboard[p->note-1]; | 1811 | UINT n = penv->Keyboard[p->note-1]; |
1809 | if (n < MAX_SAMPLES) pbIns[n] = TRUE; | 1812 | if (n < MAX_SAMPLES) pbIns[n] = TRUE; |
1810 | } | 1813 | } |
1811 | } else | 1814 | } else |
1812 | { | 1815 | { |
1813 | for (UINT k=1; k<=m_nInstruments; k++) | 1816 | for (UINT k=1; k<=m_nInstruments; k++) |
1814 | { | 1817 | { |
1815 | INSTRUMENTHEADER *penv = Headers[k]; | 1818 | INSTRUMENTHEADER *penv = Headers[k]; |
1816 | if (penv) | 1819 | if (penv) |
1817 | { | 1820 | { |
1818 | UINT n = penv->Keyboard[p->note-1]; | 1821 | UINT n = penv->Keyboard[p->note-1]; |
1819 | if (n < MAX_SAMPLES) pbIns[n] = TRUE; | 1822 | if (n < MAX_SAMPLES) pbIns[n] = TRUE; |
1820 | } | 1823 | } |
1821 | } | 1824 | } |
1822 | } | 1825 | } |
1823 | } | 1826 | } |
1824 | } | 1827 | } |
1825 | } | 1828 | } |
1826 | } | 1829 | } |
1827 | for (UINT ichk=1; ichk<=m_nSamples; ichk++) | 1830 | for (UINT ichk=1; ichk<=m_nSamples; ichk++) |
1828 | { | 1831 | { |
1829 | if ((!pbIns[ichk]) && (Ins[ichk].pSample)) nExt++; | 1832 | if ((!pbIns[ichk]) && (Ins[ichk].pSample)) nExt++; |
1830 | } | 1833 | } |
1831 | } | 1834 | } |
1832 | return nExt; | 1835 | return nExt; |
1833 | } | 1836 | } |
1834 | 1837 | ||
1835 | 1838 | ||
1836 | BOOL CSoundFile::RemoveSelectedSamples(BOOL *pbIns) | 1839 | BOOL CSoundFile::RemoveSelectedSamples(BOOL *pbIns) |
1837 | //------------------------------------------------- | 1840 | //------------------------------------------------- |
1838 | { | 1841 | { |
diff --git a/core/multimedia/opieplayer/vorbis/tremor/block.c b/core/multimedia/opieplayer/vorbis/tremor/block.c index 8949253..7b5531b 100644 --- a/core/multimedia/opieplayer/vorbis/tremor/block.c +++ b/core/multimedia/opieplayer/vorbis/tremor/block.c | |||
@@ -133,194 +133,196 @@ void _vorbis_block_ripcord(vorbis_block *vb){ | |||
133 | /* pull the ripcord */ | 133 | /* pull the ripcord */ |
134 | vb->localtop=0; | 134 | vb->localtop=0; |
135 | vb->reap=NULL; | 135 | vb->reap=NULL; |
136 | } | 136 | } |
137 | 137 | ||
138 | int vorbis_block_clear(vorbis_block *vb){ | 138 | int vorbis_block_clear(vorbis_block *vb){ |
139 | _vorbis_block_ripcord(vb); | 139 | _vorbis_block_ripcord(vb); |
140 | if(vb->localstore)_ogg_free(vb->localstore); | 140 | if(vb->localstore)_ogg_free(vb->localstore); |
141 | 141 | ||
142 | memset(vb,0,sizeof(*vb)); | 142 | memset(vb,0,sizeof(*vb)); |
143 | return(0); | 143 | return(0); |
144 | } | 144 | } |
145 | 145 | ||
146 | static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ | 146 | static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ |
147 | int i; | 147 | int i; |
148 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | 148 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; |
149 | private_state *b=NULL; | 149 | private_state *b=NULL; |
150 | 150 | ||
151 | memset(v,0,sizeof(*v)); | 151 | memset(v,0,sizeof(*v)); |
152 | b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b))); | 152 | b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b))); |
153 | 153 | ||
154 | v->vi=vi; | 154 | v->vi=vi; |
155 | b->modebits=ilog(ci->modes); | 155 | b->modebits=ilog(ci->modes); |
156 | 156 | ||
157 | /* Vorbis I uses only window type 0 */ | 157 | /* Vorbis I uses only window type 0 */ |
158 | b->window[0]=_vorbis_window(0,ci->blocksizes[0]/2); | 158 | b->window[0]=_vorbis_window(0,ci->blocksizes[0]/2); |
159 | b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2); | 159 | b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2); |
160 | 160 | ||
161 | /* finish the codebooks */ | 161 | /* finish the codebooks */ |
162 | if(!ci->fullbooks){ | 162 | if(!ci->fullbooks){ |
163 | ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); | 163 | ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); |
164 | for(i=0;i<ci->books;i++){ | 164 | for(i=0;i<ci->books;i++){ |
165 | vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]); | 165 | vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]); |
166 | /* decode codebooks are now standalone after init */ | 166 | /* decode codebooks are now standalone after init */ |
167 | vorbis_staticbook_destroy(ci->book_param[i]); | 167 | vorbis_staticbook_destroy(ci->book_param[i]); |
168 | ci->book_param[i]=NULL; | 168 | ci->book_param[i]=NULL; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | v->pcm_storage=ci->blocksizes[1]; | 172 | v->pcm_storage=ci->blocksizes[1]; |
173 | v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm)); | 173 | v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm)); |
174 | v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret)); | 174 | v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret)); |
175 | for(i=0;i<vi->channels;i++) | 175 | for(i=0;i<vi->channels;i++) |
176 | v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); | 176 | v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); |
177 | 177 | ||
178 | /* all 1 (large block) or 0 (small block) */ | 178 | /* all 1 (large block) or 0 (small block) */ |
179 | /* explicitly set for the sake of clarity */ | 179 | /* explicitly set for the sake of clarity */ |
180 | v->lW=0; /* previous window size */ | 180 | v->lW=0; /* previous window size */ |
181 | v->W=0; /* current window size */ | 181 | v->W=0; /* current window size */ |
182 | 182 | ||
183 | /* initialize all the mapping/backend lookups */ | 183 | /* initialize all the mapping/backend lookups */ |
184 | b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); | 184 | b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); |
185 | for(i=0;i<ci->modes;i++){ | 185 | for(i=0;i<ci->modes;i++){ |
186 | int mapnum=ci->mode_param[i]->mapping; | 186 | int mapnum=ci->mode_param[i]->mapping; |
187 | int maptype=ci->map_type[mapnum]; | 187 | int maptype=ci->map_type[mapnum]; |
188 | b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], | 188 | b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], |
189 | ci->map_param[mapnum]); | 189 | ci->map_param[mapnum]); |
190 | } | 190 | } |
191 | return(0); | 191 | return(0); |
192 | } | 192 | } |
193 | 193 | ||
194 | int vorbis_synthesis_restart(vorbis_dsp_state *v){ | 194 | int vorbis_synthesis_restart(vorbis_dsp_state *v){ |
195 | vorbis_info *vi=v->vi; | 195 | vorbis_info *vi=v->vi; |
196 | codec_setup_info *ci; | 196 | codec_setup_info *ci; |
197 | 197 | ||
198 | if(!v->backend_state)return -1; | 198 | if(!v->backend_state)return -1; |
199 | if(!vi)return -1; | 199 | if(!vi)return -1; |
200 | ci=vi->codec_setup; | 200 | ci=vi->codec_setup; |
201 | if(!ci)return -1; | 201 | if(!ci)return -1; |
202 | 202 | ||
203 | v->centerW=ci->blocksizes[1]/2; | 203 | v->centerW=ci->blocksizes[1]/2; |
204 | v->pcm_current=v->centerW; | 204 | v->pcm_current=v->centerW; |
205 | 205 | ||
206 | v->pcm_returned=-1; | 206 | v->pcm_returned=-1; |
207 | v->granulepos=-1; | 207 | v->granulepos=-1; |
208 | v->sequence=-1; | 208 | v->sequence=-1; |
209 | ((private_state *)(v->backend_state))->sample_count=-1; | 209 | ((private_state *)(v->backend_state))->sample_count=-1; |
210 | 210 | ||
211 | return(0); | 211 | return(0); |
212 | } | 212 | } |
213 | 213 | ||
214 | int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ | 214 | int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ |
215 | _vds_init(v,vi); | 215 | _vds_init(v,vi); |
216 | vorbis_synthesis_restart(v); | 216 | vorbis_synthesis_restart(v); |
217 | 217 | ||
218 | return(0); | 218 | return(0); |
219 | } | 219 | } |
220 | 220 | ||
221 | void vorbis_dsp_clear(vorbis_dsp_state *v){ | 221 | void vorbis_dsp_clear(vorbis_dsp_state *v){ |
222 | int i; | 222 | int i; |
223 | if(v){ | 223 | if(v){ |
224 | vorbis_info *vi=v->vi; | 224 | vorbis_info *vi=v->vi; |
225 | codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); | 225 | codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); |
226 | private_state *b=(private_state *)v->backend_state; | 226 | private_state *b=(private_state *)v->backend_state; |
227 | 227 | ||
228 | if(v->pcm){ | 228 | if(v->pcm){ |
229 | for(i=0;i<vi->channels;i++) | 229 | if (vi) { |
230 | if(v->pcm[i])_ogg_free(v->pcm[i]); | 230 | for(i=0;i<vi->channels;i++) |
231 | if(v->pcm[i])_ogg_free(v->pcm[i]); | ||
232 | } | ||
231 | _ogg_free(v->pcm); | 233 | _ogg_free(v->pcm); |
232 | if(v->pcmret)_ogg_free(v->pcmret); | 234 | if(v->pcmret)_ogg_free(v->pcmret); |
233 | } | 235 | } |
234 | 236 | ||
235 | /* free mode lookups; these are actually vorbis_look_mapping structs */ | 237 | /* free mode lookups; these are actually vorbis_look_mapping structs */ |
236 | if(ci){ | 238 | if(ci){ |
237 | for(i=0;i<ci->modes;i++){ | 239 | for(i=0;i<ci->modes;i++){ |
238 | int mapnum=ci->mode_param[i]->mapping; | 240 | int mapnum=ci->mode_param[i]->mapping; |
239 | int maptype=ci->map_type[mapnum]; | 241 | int maptype=ci->map_type[mapnum]; |
240 | if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); | 242 | if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); |
241 | } | 243 | } |
242 | } | 244 | } |
243 | 245 | ||
244 | if(b){ | 246 | if(b){ |
245 | if(b->mode)_ogg_free(b->mode); | 247 | if(b->mode)_ogg_free(b->mode); |
246 | _ogg_free(b); | 248 | _ogg_free(b); |
247 | } | 249 | } |
248 | 250 | ||
249 | memset(v,0,sizeof(*v)); | 251 | memset(v,0,sizeof(*v)); |
250 | } | 252 | } |
251 | } | 253 | } |
252 | 254 | ||
253 | /* Unlike in analysis, the window is only partially applied for each | 255 | /* Unlike in analysis, the window is only partially applied for each |
254 | block. The time domain envelope is not yet handled at the point of | 256 | block. The time domain envelope is not yet handled at the point of |
255 | calling (as it relies on the previous block). */ | 257 | calling (as it relies on the previous block). */ |
256 | 258 | ||
257 | int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | 259 | int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ |
258 | vorbis_info *vi=v->vi; | 260 | vorbis_info *vi=v->vi; |
259 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | 261 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; |
260 | private_state *b=v->backend_state; | 262 | private_state *b=v->backend_state; |
261 | int i,j; | 263 | int i,j; |
262 | 264 | ||
263 | if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); | 265 | if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); |
264 | 266 | ||
265 | v->lW=v->W; | 267 | v->lW=v->W; |
266 | v->W=vb->W; | 268 | v->W=vb->W; |
267 | v->nW=-1; | 269 | v->nW=-1; |
268 | 270 | ||
269 | if((v->sequence==-1)|| | 271 | if((v->sequence==-1)|| |
270 | (v->sequence+1 != vb->sequence)){ | 272 | (v->sequence+1 != vb->sequence)){ |
271 | v->granulepos=-1; /* out of sequence; lose count */ | 273 | v->granulepos=-1; /* out of sequence; lose count */ |
272 | b->sample_count=-1; | 274 | b->sample_count=-1; |
273 | } | 275 | } |
274 | 276 | ||
275 | v->sequence=vb->sequence; | 277 | v->sequence=vb->sequence; |
276 | 278 | ||
277 | if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly | 279 | if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly |
278 | was called on block */ | 280 | was called on block */ |
279 | int n=ci->blocksizes[v->W]/2; | 281 | int n=ci->blocksizes[v->W]/2; |
280 | int n0=ci->blocksizes[0]/2; | 282 | int n0=ci->blocksizes[0]/2; |
281 | int n1=ci->blocksizes[1]/2; | 283 | int n1=ci->blocksizes[1]/2; |
282 | 284 | ||
283 | int thisCenter; | 285 | int thisCenter; |
284 | int prevCenter; | 286 | int prevCenter; |
285 | 287 | ||
286 | if(v->centerW){ | 288 | if(v->centerW){ |
287 | thisCenter=n1; | 289 | thisCenter=n1; |
288 | prevCenter=0; | 290 | prevCenter=0; |
289 | }else{ | 291 | }else{ |
290 | thisCenter=0; | 292 | thisCenter=0; |
291 | prevCenter=n1; | 293 | prevCenter=n1; |
292 | } | 294 | } |
293 | 295 | ||
294 | /* v->pcm is now used like a two-stage double buffer. We don't want | 296 | /* v->pcm is now used like a two-stage double buffer. We don't want |
295 | to have to constantly shift *or* adjust memory usage. Don't | 297 | to have to constantly shift *or* adjust memory usage. Don't |
296 | accept a new block until the old is shifted out */ | 298 | accept a new block until the old is shifted out */ |
297 | 299 | ||
298 | /* overlap/add PCM */ | 300 | /* overlap/add PCM */ |
299 | 301 | ||
300 | for(j=0;j<vi->channels;j++){ | 302 | for(j=0;j<vi->channels;j++){ |
301 | /* the overlap/add section */ | 303 | /* the overlap/add section */ |
302 | if(v->lW){ | 304 | if(v->lW){ |
303 | if(v->W){ | 305 | if(v->W){ |
304 | /* large/large */ | 306 | /* large/large */ |
305 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; | 307 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; |
306 | ogg_int32_t *p=vb->pcm[j]; | 308 | ogg_int32_t *p=vb->pcm[j]; |
307 | for(i=0;i<n1;i++) | 309 | for(i=0;i<n1;i++) |
308 | pcm[i]+=p[i]; | 310 | pcm[i]+=p[i]; |
309 | }else{ | 311 | }else{ |
310 | /* large/small */ | 312 | /* large/small */ |
311 | ogg_int32_t *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; | 313 | ogg_int32_t *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; |
312 | ogg_int32_t *p=vb->pcm[j]; | 314 | ogg_int32_t *p=vb->pcm[j]; |
313 | for(i=0;i<n0;i++) | 315 | for(i=0;i<n0;i++) |
314 | pcm[i]+=p[i]; | 316 | pcm[i]+=p[i]; |
315 | } | 317 | } |
316 | }else{ | 318 | }else{ |
317 | if(v->W){ | 319 | if(v->W){ |
318 | /* small/large */ | 320 | /* small/large */ |
319 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; | 321 | ogg_int32_t *pcm=v->pcm[j]+prevCenter; |
320 | ogg_int32_t *p=vb->pcm[j]+n1/2-n0/2; | 322 | ogg_int32_t *p=vb->pcm[j]+n1/2-n0/2; |
321 | for(i=0;i<n0;i++) | 323 | for(i=0;i<n0;i++) |
322 | pcm[i]+=p[i]; | 324 | pcm[i]+=p[i]; |
323 | for(;i<n1/2+n0/2;i++) | 325 | for(;i<n1/2+n0/2;i++) |
324 | pcm[i]=p[i]; | 326 | pcm[i]=p[i]; |
325 | }else{ | 327 | }else{ |
326 | /* small/small */ | 328 | /* small/small */ |
diff --git a/core/multimedia/opieplayer/vorbis/tremor/info.c b/core/multimedia/opieplayer/vorbis/tremor/info.c index 941695e..3499ae4 100644 --- a/core/multimedia/opieplayer/vorbis/tremor/info.c +++ b/core/multimedia/opieplayer/vorbis/tremor/info.c | |||
@@ -4,194 +4,194 @@ | |||
4 | * * | 4 | * * |
5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
8 | * * | 8 | * * |
9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * | 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * |
10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * | 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * |
11 | * * | 11 | * * |
12 | ******************************************************************** | 12 | ******************************************************************** |
13 | 13 | ||
14 | function: maintain the info structure, info <-> header packets | 14 | function: maintain the info structure, info <-> header packets |
15 | 15 | ||
16 | ********************************************************************/ | 16 | ********************************************************************/ |
17 | 17 | ||
18 | /* general handling of the header and the vorbis_info structure (and | 18 | /* general handling of the header and the vorbis_info structure (and |
19 | substructures) */ | 19 | substructures) */ |
20 | 20 | ||
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <string.h> | 22 | #include <string.h> |
23 | #include <ctype.h> | 23 | #include <ctype.h> |
24 | #include "ogg.h" | 24 | #include "ogg.h" |
25 | #include "ivorbiscodec.h" | 25 | #include "ivorbiscodec.h" |
26 | #include "codec_internal.h" | 26 | #include "codec_internal.h" |
27 | #include "codebook.h" | 27 | #include "codebook.h" |
28 | #include "registry.h" | 28 | #include "registry.h" |
29 | #include "window.h" | 29 | #include "window.h" |
30 | #include "misc.h" | 30 | #include "misc.h" |
31 | #include "os.h" | 31 | #include "os.h" |
32 | 32 | ||
33 | /* helpers */ | 33 | /* helpers */ |
34 | static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){ | 34 | static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){ |
35 | while(bytes--){ | 35 | while(bytes--){ |
36 | *buf++=oggpack_read(o,8); | 36 | *buf++=oggpack_read(o,8); |
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | void vorbis_comment_init(vorbis_comment *vc){ | 40 | void vorbis_comment_init(vorbis_comment *vc){ |
41 | memset(vc,0,sizeof(*vc)); | 41 | memset(vc,0,sizeof(*vc)); |
42 | } | 42 | } |
43 | 43 | ||
44 | /* This is more or less the same as strncasecmp - but that doesn't exist | 44 | /* This is more or less the same as strncasecmp - but that doesn't exist |
45 | * everywhere, and this is a fairly trivial function, so we include it */ | 45 | * everywhere, and this is a fairly trivial function, so we include it */ |
46 | static int tagcompare(const char *s1, const char *s2, int n){ | 46 | static int tagcompare(const char *s1, const char *s2, int n){ |
47 | int c=0; | 47 | int c=0; |
48 | while(c < n){ | 48 | while(c < n){ |
49 | if(toupper(s1[c]) != toupper(s2[c])) | 49 | if(toupper(s1[c]) != toupper(s2[c])) |
50 | return !0; | 50 | return !0; |
51 | c++; | 51 | c++; |
52 | } | 52 | } |
53 | return 0; | 53 | return 0; |
54 | } | 54 | } |
55 | 55 | ||
56 | char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ | 56 | char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ |
57 | long i; | 57 | long i; |
58 | int found = 0; | 58 | int found = 0; |
59 | int taglen = strlen(tag)+1; /* +1 for the = we append */ | 59 | int taglen = strlen(tag)+1; /* +1 for the = we append */ |
60 | char *fulltag = (char *)alloca(taglen+ 1); | 60 | char *fulltag = (char *)alloca(taglen+ 1); |
61 | 61 | ||
62 | strcpy(fulltag, tag); | 62 | strcpy(fulltag, tag); |
63 | strcat(fulltag, "="); | 63 | strcat(fulltag, "="); |
64 | 64 | ||
65 | for(i=0;i<vc->comments;i++){ | 65 | for(i=0;i<vc->comments;i++){ |
66 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ | 66 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ |
67 | if(count == found) | 67 | if(count == found) |
68 | /* We return a pointer to the data, not a copy */ | 68 | /* We return a pointer to the data, not a copy */ |
69 | return vc->user_comments[i] + taglen; | 69 | return vc->user_comments[i] + taglen; |
70 | else | 70 | else |
71 | found++; | 71 | found++; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | return NULL; /* didn't find anything */ | 74 | return NULL; /* didn't find anything */ |
75 | } | 75 | } |
76 | 76 | ||
77 | int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ | 77 | int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ |
78 | int i,count=0; | 78 | int i,count=0; |
79 | int taglen = strlen(tag)+1; /* +1 for the = we append */ | 79 | int taglen = strlen(tag)+1; /* +1 for the = we append */ |
80 | char *fulltag = (char *)alloca(taglen+1); | 80 | char *fulltag = (char *)alloca(taglen+1); |
81 | strcpy(fulltag,tag); | 81 | strcpy(fulltag,tag); |
82 | strcat(fulltag, "="); | 82 | strcat(fulltag, "="); |
83 | 83 | ||
84 | for(i=0;i<vc->comments;i++){ | 84 | for(i=0;i<vc->comments;i++){ |
85 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)) | 85 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)) |
86 | count++; | 86 | count++; |
87 | } | 87 | } |
88 | 88 | ||
89 | return count; | 89 | return count; |
90 | } | 90 | } |
91 | 91 | ||
92 | void vorbis_comment_clear(vorbis_comment *vc){ | 92 | void vorbis_comment_clear(vorbis_comment *vc){ |
93 | if(vc){ | 93 | if(vc){ |
94 | long i; | 94 | long i; |
95 | for(i=0;i<vc->comments;i++) | 95 | for(i=0;i<vc->comments;i++) |
96 | if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); | 96 | if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); |
97 | if(vc->user_comments)_ogg_free(vc->user_comments); | 97 | if(vc->user_comments)_ogg_free(vc->user_comments); |
98 | if(vc->comment_lengths)_ogg_free(vc->comment_lengths); | 98 | if(vc->comment_lengths)_ogg_free(vc->comment_lengths); |
99 | if(vc->vendor)_ogg_free(vc->vendor); | 99 | if(vc->vendor)_ogg_free(vc->vendor); |
100 | memset(vc,0,sizeof(*vc)); | ||
100 | } | 101 | } |
101 | memset(vc,0,sizeof(*vc)); | ||
102 | } | 102 | } |
103 | 103 | ||
104 | /* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. | 104 | /* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. |
105 | They may be equal, but short will never ge greater than long */ | 105 | They may be equal, but short will never ge greater than long */ |
106 | int vorbis_info_blocksize(vorbis_info *vi,int zo){ | 106 | int vorbis_info_blocksize(vorbis_info *vi,int zo){ |
107 | codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; | 107 | codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; |
108 | return ci ? ci->blocksizes[zo] : -1; | 108 | return ci ? ci->blocksizes[zo] : -1; |
109 | } | 109 | } |
110 | 110 | ||
111 | /* used by synthesis, which has a full, alloced vi */ | 111 | /* used by synthesis, which has a full, alloced vi */ |
112 | void vorbis_info_init(vorbis_info *vi){ | 112 | void vorbis_info_init(vorbis_info *vi){ |
113 | memset(vi,0,sizeof(*vi)); | 113 | memset(vi,0,sizeof(*vi)); |
114 | vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); | 114 | vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); |
115 | } | 115 | } |
116 | 116 | ||
117 | void vorbis_info_clear(vorbis_info *vi){ | 117 | void vorbis_info_clear(vorbis_info *vi){ |
118 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | 118 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; |
119 | int i; | 119 | int i; |
120 | 120 | ||
121 | if(ci){ | 121 | if(ci){ |
122 | 122 | ||
123 | for(i=0;i<ci->modes;i++) | 123 | for(i=0;i<ci->modes;i++) |
124 | if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); | 124 | if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); |
125 | 125 | ||
126 | for(i=0;i<ci->maps;i++) /* unpack does the range checking */ | 126 | for(i=0;i<ci->maps;i++) /* unpack does the range checking */ |
127 | _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); | 127 | _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); |
128 | 128 | ||
129 | for(i=0;i<ci->floors;i++) /* unpack does the range checking */ | 129 | for(i=0;i<ci->floors;i++) /* unpack does the range checking */ |
130 | _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); | 130 | _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); |
131 | 131 | ||
132 | for(i=0;i<ci->residues;i++) /* unpack does the range checking */ | 132 | for(i=0;i<ci->residues;i++) /* unpack does the range checking */ |
133 | _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); | 133 | _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); |
134 | 134 | ||
135 | for(i=0;i<ci->books;i++){ | 135 | for(i=0;i<ci->books;i++){ |
136 | if(ci->book_param[i]){ | 136 | if(ci->book_param[i]){ |
137 | /* knows if the book was not alloced */ | 137 | /* knows if the book was not alloced */ |
138 | vorbis_staticbook_destroy(ci->book_param[i]); | 138 | vorbis_staticbook_destroy(ci->book_param[i]); |
139 | } | 139 | } |
140 | if(ci->fullbooks) | 140 | if(ci->fullbooks) |
141 | vorbis_book_clear(ci->fullbooks+i); | 141 | vorbis_book_clear(ci->fullbooks+i); |
142 | } | 142 | } |
143 | if(ci->fullbooks) | 143 | if(ci->fullbooks) |
144 | _ogg_free(ci->fullbooks); | 144 | _ogg_free(ci->fullbooks); |
145 | 145 | ||
146 | _ogg_free(ci); | 146 | _ogg_free(ci); |
147 | } | 147 | } |
148 | 148 | ||
149 | memset(vi,0,sizeof(*vi)); | 149 | memset(vi,0,sizeof(*vi)); |
150 | } | 150 | } |
151 | 151 | ||
152 | /* Header packing/unpacking ********************************************/ | 152 | /* Header packing/unpacking ********************************************/ |
153 | 153 | ||
154 | static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ | 154 | static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ |
155 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | 155 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; |
156 | if(!ci)return(OV_EFAULT); | 156 | if(!ci)return(OV_EFAULT); |
157 | 157 | ||
158 | vi->version=oggpack_read(opb,32); | 158 | vi->version=oggpack_read(opb,32); |
159 | if(vi->version!=0)return(OV_EVERSION); | 159 | if(vi->version!=0)return(OV_EVERSION); |
160 | 160 | ||
161 | vi->channels=oggpack_read(opb,8); | 161 | vi->channels=oggpack_read(opb,8); |
162 | vi->rate=oggpack_read(opb,32); | 162 | vi->rate=oggpack_read(opb,32); |
163 | 163 | ||
164 | vi->bitrate_upper=oggpack_read(opb,32); | 164 | vi->bitrate_upper=oggpack_read(opb,32); |
165 | vi->bitrate_nominal=oggpack_read(opb,32); | 165 | vi->bitrate_nominal=oggpack_read(opb,32); |
166 | vi->bitrate_lower=oggpack_read(opb,32); | 166 | vi->bitrate_lower=oggpack_read(opb,32); |
167 | 167 | ||
168 | ci->blocksizes[0]=1<<oggpack_read(opb,4); | 168 | ci->blocksizes[0]=1<<oggpack_read(opb,4); |
169 | ci->blocksizes[1]=1<<oggpack_read(opb,4); | 169 | ci->blocksizes[1]=1<<oggpack_read(opb,4); |
170 | 170 | ||
171 | if(vi->rate<1)goto err_out; | 171 | if(vi->rate<1)goto err_out; |
172 | if(vi->channels<1)goto err_out; | 172 | if(vi->channels<1)goto err_out; |
173 | if(ci->blocksizes[0]<64)goto err_out; | 173 | if(ci->blocksizes[0]<64)goto err_out; |
174 | if(ci->blocksizes[1]<ci->blocksizes[0])goto err_out; | 174 | if(ci->blocksizes[1]<ci->blocksizes[0])goto err_out; |
175 | if(ci->blocksizes[1]>8192)goto err_out; | 175 | if(ci->blocksizes[1]>8192)goto err_out; |
176 | 176 | ||
177 | if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ | 177 | if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ |
178 | 178 | ||
179 | return(0); | 179 | return(0); |
180 | err_out: | 180 | err_out: |
181 | vorbis_info_clear(vi); | 181 | vorbis_info_clear(vi); |
182 | return(OV_EBADHEADER); | 182 | return(OV_EBADHEADER); |
183 | } | 183 | } |
184 | 184 | ||
185 | static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){ | 185 | static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){ |
186 | int i; | 186 | int i; |
187 | int vendorlen=oggpack_read(opb,32); | 187 | int vendorlen=oggpack_read(opb,32); |
188 | if(vendorlen<0)goto err_out; | 188 | if(vendorlen<0)goto err_out; |
189 | vc->vendor=(char *)_ogg_calloc(vendorlen+1,1); | 189 | vc->vendor=(char *)_ogg_calloc(vendorlen+1,1); |
190 | _v_readstring(opb,vc->vendor,vendorlen); | 190 | _v_readstring(opb,vc->vendor,vendorlen); |
191 | vc->comments=oggpack_read(opb,32); | 191 | vc->comments=oggpack_read(opb,32); |
192 | if(vc->comments<0)goto err_out; | 192 | if(vc->comments<0)goto err_out; |
193 | vc->user_comments=(char **)_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments)); | 193 | vc->user_comments=(char **)_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments)); |
194 | vc->comment_lengths=(int *)_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths)); | 194 | vc->comment_lengths=(int *)_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths)); |
195 | 195 | ||
196 | for(i=0;i<vc->comments;i++){ | 196 | for(i=0;i<vc->comments;i++){ |
197 | int len=oggpack_read(opb,32); | 197 | int len=oggpack_read(opb,32); |