Permalink
Browse files

fix remapping - downmixing algorithm. Didn't work for 7 ch -> 2 ch, e…

…ach channel taking more than 4 sources (e.g. FR = FR+ SR+ BC+ LFE+ FC)
  • Loading branch information...
1 parent 3aa82b8 commit 582c88af61b2adb46599f5dd192b65197a293d9b Voyager-xbmc committed Sep 8, 2012
Showing with 10 additions and 7 deletions.
  1. +10 −7 xbmc/cores/AudioEngine/Utils/AERemap.cpp
@@ -344,21 +344,24 @@ void CAERemap::Remap(float * const in, float * const out, const unsigned int fra
/* the compiler has a better chance of optimizing this if it is done in parallel */
int i = 0;
+ float f1 = 0.0, f2 = 0.0, f3 = 0.0, f4 = 0.0;
for (; i < blocks; i += 4)
{
- *outOffset += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level, i++;
- *outOffset += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level, i++;
- *outOffset += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level, i++;
- *outOffset += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level, i++;
+ f1 += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level;
+ f2 += inOffset[info->srcIndex[i+1].index] * info->srcIndex[i+1].level;
+ f3 += inOffset[info->srcIndex[i+2].index] * info->srcIndex[i+2].level;
+ f4 += inOffset[info->srcIndex[i+3].index] * info->srcIndex[i+3].level;
}
/* unrolled loop for higher performance */
switch (info->srcCount & 0x3)
{
- case 3: *outOffset += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level, i++;
- case 2: *outOffset += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level, i++;
- case 1: *outOffset += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level;
+ case 3: f3 += inOffset[info->srcIndex[i+2].index] * info->srcIndex[i+2].level;
+ case 2: f2 += inOffset[info->srcIndex[i+1].index] * info->srcIndex[i+1].level;
+ case 1: f1 += inOffset[info->srcIndex[i].index] * info->srcIndex[i].level;
}
+
+ *outOffset += (f1+f2+f3+f4);
}
}
}

1 comment on commit 582c88a

Member

gnif commented on 582c88a Sep 27, 2012

wow, that was a pretty obvious bug, thanks for catching it :)

Please sign in to comment.