diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2010-02-15 13:00:02 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2010-02-15 13:00:02 +0000 |
commit | 57461d7c4f612bed0e8cd9644a0689dbfe56d684 (patch) | |
tree | f3d574b7f7b9433d3aef18b828c5687993a9ea0f /apps/codecs/libatrac/atrac3.c | |
parent | 651b55488ef2c35c0b0a17781a466bf14cc1f71a (diff) | |
download | rockbox-57461d7c4f612bed0e8cd9644a0689dbfe56d684.tar.gz rockbox-57461d7c4f612bed0e8cd9644a0689dbfe56d684.zip |
Work on atrac Joint Stereo mode. Correct calculation in getChannelWeights(), introduce lookup table and remove obsolete code. Optimize interpolation macro.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24665 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libatrac/atrac3.c')
-rw-r--r-- | apps/codecs/libatrac/atrac3.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c index 467f42f161..5ff3a8587b 100644 --- a/apps/codecs/libatrac/atrac3.c +++ b/apps/codecs/libatrac/atrac3.c | |||
@@ -628,8 +628,21 @@ static int addTonalComponents (int32_t *pSpectrum, int numComponents, tonal_comp | |||
628 | return lastPos; | 628 | return lastPos; |
629 | } | 629 | } |
630 | 630 | ||
631 | 631 | /** | |
632 | #define INTERPOLATE(old,new,nsample) ((old*ONE_16) + fixmul16(((nsample*ONE_16)>>3), (((new) - (old))*ONE_16))) | 632 | * Linear equidistant interpolation between two points x and y. 7 interpolation |
633 | * points can be calculated. Result is scaled by <<16. | ||
634 | * Result for s=0 is x*ONE_16 | ||
635 | * Result for s=8 is y*ONE_16 | ||
636 | * | ||
637 | * @param x first input point | ||
638 | * @param y second input point | ||
639 | * @param s index of interpolation point (0..7) | ||
640 | */ | ||
641 | |||
642 | /* | ||
643 | #define INTERPOLATE(x, y, s) ((x*ONE_16) + fixmul16(((s*ONE_16)>>3), (((x) - (y))*ONE_16))) | ||
644 | */ | ||
645 | #define INTERPOLATE(x, y, s) ((((x)<<3) + s*((y)-(x)))<<13) | ||
633 | 646 | ||
634 | static void reverseMatrixing(int32_t *su1, int32_t *su2, int *pPrevCode, int *pCurrCode) | 647 | static void reverseMatrixing(int32_t *su1, int32_t *su2, int *pPrevCode, int *pCurrCode) |
635 | { | 648 | { |
@@ -695,14 +708,14 @@ static void reverseMatrixing(int32_t *su1, int32_t *su2, int *pPrevCode, int *pC | |||
695 | } | 708 | } |
696 | 709 | ||
697 | static void getChannelWeights (int indx, int flag, int32_t ch[2]){ | 710 | static void getChannelWeights (int indx, int flag, int32_t ch[2]){ |
698 | if (indx == 7) { | 711 | /* Read channel weights from table */ |
699 | ch[0] = ONE_16; | 712 | if (flag) { |
700 | ch[1] = ONE_16; | 713 | /* Swap channel weights */ |
714 | ch[1] = channelWeights0[indx&7]; | ||
715 | ch[0] = channelWeights1[indx&7]; | ||
701 | } else { | 716 | } else { |
702 | ch[0] = fixdiv16(((indx & 7)*ONE_16), 7*ONE_16); | 717 | ch[0] = channelWeights0[indx&7]; |
703 | ch[1] = fastSqrt((ONE_16 << 1) - fixmul16(ch[0], ch[0])); | 718 | ch[1] = channelWeights1[indx&7]; |
704 | if(flag) | ||
705 | FFSWAP(int32_t, ch[0], ch[1]); | ||
706 | } | 719 | } |
707 | } | 720 | } |
708 | 721 | ||