diff options
author | Maxim Poliakovski <max_pole@gmx.de> | 2008-05-22 19:16:28 +0000 |
---|---|---|
committer | Benjamin Larsson <banan@ludd.ltu.se> | 2008-05-22 19:16:28 +0000 |
commit | 9d278d8859c08faece7f192ef4609f4240611d2e (patch) | |
tree | 574b8c32aafb8345431010b9195396e53fdfff32 /libavcodec/atrac3.c | |
parent | 6f04eb1e8aa45d05b138af37b26c13622660bc9b (diff) | |
download | ffmpeg-streaming-9d278d8859c08faece7f192ef4609f4240611d2e.zip ffmpeg-streaming-9d278d8859c08faece7f192ef4609f4240611d2e.tar.gz |
Fix decoding of 01-Untitled(1).oma, patch by Maxim Poliakovski
Originally committed as revision 13238 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/atrac3.c')
-rw-r--r-- | libavcodec/atrac3.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index cfbaf7a..02a465a 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -468,7 +468,7 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent pComponent[component_count].numCoefs = coded_values; /* inverse quant */ - pCoef = pComponent[k].coef; + pCoef = pComponent[component_count].coef; for (cnt = 0; cnt < coded_values; cnt++) pCoef[cnt] = mantissa[cnt] * scalefactor; @@ -577,24 +577,28 @@ static void gainCompensateAndOverlap (float *pIn, float *pPrev, float *pOut, gai /** * Combine the tonal band spectrum and regular band spectrum + * Return position of the last tonal coefficient * * @param pSpectrum output spectrum buffer * @param numComponents amount of tonal components * @param pComponent tonal components for this band */ -static void addTonalComponents (float *pSpectrum, int numComponents, tonal_component *pComponent) +static int addTonalComponents (float *pSpectrum, int numComponents, tonal_component *pComponent) { - int cnt, i; + int cnt, i, lastPos = -1; float *pIn, *pOut; for (cnt = 0; cnt < numComponents; cnt++){ + lastPos = FFMAX(pComponent[cnt].pos + pComponent[cnt].numCoefs, lastPos); pIn = pComponent[cnt].coef; pOut = &(pSpectrum[pComponent[cnt].pos]); for (i=0 ; i<pComponent[cnt].numCoefs ; i++) pOut[i] += pIn[i]; } + + return lastPos; } @@ -714,7 +718,7 @@ static void channelWeighting (float *su1, float *su2, int *p3) static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_unit *pSnd, float *pOut, int channelNum, int codingMode) { - int band, result=0, numSubbands, numBands; + int band, result=0, numSubbands, lastTonal, numBands; if (codingMode == JOINT_STEREO && channelNum == 1) { if (get_bits(gb,2) != 3) { @@ -740,11 +744,13 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_ numSubbands = decodeSpectrum (gb, pSnd->spectrum); /* Merge the decoded spectrum and tonal components. */ - addTonalComponents (pSnd->spectrum, pSnd->numComponents, pSnd->components); + lastTonal = addTonalComponents (pSnd->spectrum, pSnd->numComponents, pSnd->components); - /* Convert number of subbands into number of MLT/QMF bands */ + /* calculate number of used MLT/QMF bands according to the amount of coded spectral lines */ numBands = (subbandTab[numSubbands] - 1) >> 8; + if (lastTonal >= 0) + numBands = FFMAX((lastTonal + 256) >> 8, numBands); /* Reconstruct time domain samples. */ |