Commit ecc77697 authored by banan's avatar banan

Fix decoding of 01-Untitled(1).oma, patch by Maxim Poliakovski

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@13238 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 62b6b82e
...@@ -468,7 +468,7 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent ...@@ -468,7 +468,7 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
pComponent[component_count].numCoefs = coded_values; pComponent[component_count].numCoefs = coded_values;
/* inverse quant */ /* inverse quant */
pCoef = pComponent[k].coef; pCoef = pComponent[component_count].coef;
for (cnt = 0; cnt < coded_values; cnt++) for (cnt = 0; cnt < coded_values; cnt++)
pCoef[cnt] = mantissa[cnt] * scalefactor; pCoef[cnt] = mantissa[cnt] * scalefactor;
...@@ -577,24 +577,28 @@ static void gainCompensateAndOverlap (float *pIn, float *pPrev, float *pOut, gai ...@@ -577,24 +577,28 @@ static void gainCompensateAndOverlap (float *pIn, float *pPrev, float *pOut, gai
/** /**
* Combine the tonal band spectrum and regular band spectrum * Combine the tonal band spectrum and regular band spectrum
* Return position of the last tonal coefficient
* *
* @param pSpectrum output spectrum buffer * @param pSpectrum output spectrum buffer
* @param numComponents amount of tonal components * @param numComponents amount of tonal components
* @param pComponent tonal components for this band * @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; float *pIn, *pOut;
for (cnt = 0; cnt < numComponents; cnt++){ for (cnt = 0; cnt < numComponents; cnt++){
lastPos = FFMAX(pComponent[cnt].pos + pComponent[cnt].numCoefs, lastPos);
pIn = pComponent[cnt].coef; pIn = pComponent[cnt].coef;
pOut = &(pSpectrum[pComponent[cnt].pos]); pOut = &(pSpectrum[pComponent[cnt].pos]);
for (i=0 ; i<pComponent[cnt].numCoefs ; i++) for (i=0 ; i<pComponent[cnt].numCoefs ; i++)
pOut[i] += pIn[i]; pOut[i] += pIn[i];
} }
return lastPos;
} }
...@@ -714,7 +718,7 @@ static void channelWeighting (float *su1, float *su2, int *p3) ...@@ -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) 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 (codingMode == JOINT_STEREO && channelNum == 1) {
if (get_bits(gb,2) != 3) { if (get_bits(gb,2) != 3) {
...@@ -740,11 +744,13 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_ ...@@ -740,11 +744,13 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_
numSubbands = decodeSpectrum (gb, pSnd->spectrum); numSubbands = decodeSpectrum (gb, pSnd->spectrum);
/* Merge the decoded spectrum and tonal components. */ /* 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; numBands = (subbandTab[numSubbands] - 1) >> 8;
if (lastTonal >= 0)
numBands = FFMAX((lastTonal + 256) >> 8, numBands);
/* Reconstruct time domain samples. */ /* Reconstruct time domain samples. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment