streo mp3 player see: http://mbed.org/users/okini3939/notebook/I2S_AUDIO

Dependencies:   FatFileSystemCpp I2SSlave TLV320 mbed

Fork of madplayer by Andreas Grün

Committer:
okini3939
Date:
Fri Jul 26 15:02:49 2013 +0000
Revision:
5:50015f4868e2
Parent:
4:30b2cf4a8ee2
fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gruenfrosch 0:7627c79db971 1 /*
Gruenfrosch 0:7627c79db971 2 * libmad - MPEG audio decoder library
Gruenfrosch 0:7627c79db971 3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
Gruenfrosch 0:7627c79db971 4 *
Gruenfrosch 0:7627c79db971 5 * This program is free software; you can redistribute it and/or modify
Gruenfrosch 0:7627c79db971 6 * it under the terms of the GNU General Public License as published by
Gruenfrosch 0:7627c79db971 7 * the Free Software Foundation; either version 2 of the License, or
Gruenfrosch 0:7627c79db971 8 * (at your option) any later version.
Gruenfrosch 0:7627c79db971 9 *
Gruenfrosch 0:7627c79db971 10 * This program is distributed in the hope that it will be useful,
Gruenfrosch 0:7627c79db971 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Gruenfrosch 0:7627c79db971 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Gruenfrosch 0:7627c79db971 13 * GNU General Public License for more details.
Gruenfrosch 0:7627c79db971 14 *
Gruenfrosch 0:7627c79db971 15 * You should have received a copy of the GNU General Public License
Gruenfrosch 0:7627c79db971 16 * along with this program; if not, write to the Free Software
Gruenfrosch 0:7627c79db971 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Gruenfrosch 0:7627c79db971 18 *
Gruenfrosch 0:7627c79db971 19 * $Id: synth.c,v 1.1 2010/11/23 20:12:57 andy Exp $
Gruenfrosch 0:7627c79db971 20 */
Gruenfrosch 0:7627c79db971 21
Gruenfrosch 0:7627c79db971 22 # include "config.h"
Gruenfrosch 0:7627c79db971 23
Gruenfrosch 0:7627c79db971 24 # include "global.h"
Gruenfrosch 0:7627c79db971 25
Gruenfrosch 0:7627c79db971 26 # include "fixed.h"
Gruenfrosch 0:7627c79db971 27 # include "frame.h"
Gruenfrosch 0:7627c79db971 28 # include "synth.h"
Gruenfrosch 0:7627c79db971 29
Gruenfrosch 0:7627c79db971 30 /*
Gruenfrosch 0:7627c79db971 31 * NAME: synth->init()
Gruenfrosch 0:7627c79db971 32 * DESCRIPTION: initialize synth struct
Gruenfrosch 0:7627c79db971 33 */
Gruenfrosch 0:7627c79db971 34 void mad_synth_init(struct mad_synth *synth)
Gruenfrosch 0:7627c79db971 35 {
Gruenfrosch 0:7627c79db971 36 mad_synth_mute(synth);
Gruenfrosch 0:7627c79db971 37
Gruenfrosch 0:7627c79db971 38 synth->phase = 0;
Gruenfrosch 0:7627c79db971 39
Gruenfrosch 0:7627c79db971 40 synth->pcm.samplerate = 0;
Gruenfrosch 0:7627c79db971 41 synth->pcm.channels = 0;
Gruenfrosch 0:7627c79db971 42 synth->pcm.length = 0;
Gruenfrosch 0:7627c79db971 43 }
Gruenfrosch 0:7627c79db971 44
Gruenfrosch 0:7627c79db971 45 /*
Gruenfrosch 0:7627c79db971 46 * NAME: synth->mute()
Gruenfrosch 0:7627c79db971 47 * DESCRIPTION: zero all polyphase filterbank values, resetting synthesis
Gruenfrosch 0:7627c79db971 48 */
Gruenfrosch 0:7627c79db971 49 void mad_synth_mute(struct mad_synth *synth)
Gruenfrosch 0:7627c79db971 50 {
Gruenfrosch 0:7627c79db971 51 unsigned int ch, s, v;
Gruenfrosch 0:7627c79db971 52
Gruenfrosch 0:7627c79db971 53 for (ch = 0; ch < 2; ++ch) {
Gruenfrosch 0:7627c79db971 54 for (s = 0; s < 16; ++s) {
Gruenfrosch 0:7627c79db971 55 for (v = 0; v < 8; ++v) {
Gruenfrosch 0:7627c79db971 56 synth->filter[ch][0][0][s][v] = synth->filter[ch][0][1][s][v] =
Gruenfrosch 0:7627c79db971 57 synth->filter[ch][1][0][s][v] = synth->filter[ch][1][1][s][v] = 0;
Gruenfrosch 0:7627c79db971 58 }
Gruenfrosch 0:7627c79db971 59 }
Gruenfrosch 0:7627c79db971 60 }
Gruenfrosch 0:7627c79db971 61 }
Gruenfrosch 0:7627c79db971 62
Gruenfrosch 0:7627c79db971 63 /*
Gruenfrosch 0:7627c79db971 64 * An optional optimization called here the Subband Synthesis Optimization
Gruenfrosch 0:7627c79db971 65 * (SSO) improves the performance of subband synthesis at the expense of
Gruenfrosch 0:7627c79db971 66 * accuracy.
Gruenfrosch 0:7627c79db971 67 *
Gruenfrosch 0:7627c79db971 68 * The idea is to simplify 32x32->64-bit multiplication to 32x32->32 such
Gruenfrosch 0:7627c79db971 69 * that extra scaling and rounding are not necessary. This often allows the
Gruenfrosch 0:7627c79db971 70 * compiler to use faster 32-bit multiply-accumulate instructions instead of
Gruenfrosch 0:7627c79db971 71 * explicit 64-bit multiply, shift, and add instructions.
Gruenfrosch 0:7627c79db971 72 *
Gruenfrosch 0:7627c79db971 73 * SSO works like this: a full 32x32->64-bit multiply of two mad_fixed_t
Gruenfrosch 0:7627c79db971 74 * values requires the result to be right-shifted 28 bits to be properly
Gruenfrosch 0:7627c79db971 75 * scaled to the same fixed-point format. Right shifts can be applied at any
Gruenfrosch 0:7627c79db971 76 * time to either operand or to the result, so the optimization involves
Gruenfrosch 0:7627c79db971 77 * careful placement of these shifts to minimize the loss of accuracy.
Gruenfrosch 0:7627c79db971 78 *
Gruenfrosch 0:7627c79db971 79 * First, a 14-bit shift is applied with rounding at compile-time to the D[]
Gruenfrosch 0:7627c79db971 80 * table of coefficients for the subband synthesis window. This only loses 2
Gruenfrosch 0:7627c79db971 81 * bits of accuracy because the lower 12 bits are always zero. A second
Gruenfrosch 0:7627c79db971 82 * 12-bit shift occurs after the DCT calculation. This loses 12 bits of
Gruenfrosch 0:7627c79db971 83 * accuracy. Finally, a third 2-bit shift occurs just before the sample is
Gruenfrosch 0:7627c79db971 84 * saved in the PCM buffer. 14 + 12 + 2 == 28 bits.
Gruenfrosch 0:7627c79db971 85 */
Gruenfrosch 0:7627c79db971 86
Gruenfrosch 0:7627c79db971 87 /* FPM_DEFAULT without OPT_SSO will actually lose accuracy and performance */
Gruenfrosch 0:7627c79db971 88
Gruenfrosch 0:7627c79db971 89 # if defined(FPM_DEFAULT) && !defined(OPT_SSO)
Gruenfrosch 0:7627c79db971 90 # define OPT_SSO
Gruenfrosch 0:7627c79db971 91 # endif
Gruenfrosch 0:7627c79db971 92
Gruenfrosch 0:7627c79db971 93 /* second SSO shift, with rounding */
Gruenfrosch 0:7627c79db971 94
Gruenfrosch 0:7627c79db971 95 # if defined(OPT_SSO)
Gruenfrosch 0:7627c79db971 96 # define SHIFT(x) (((x) + (1L << 11)) >> 12)
Gruenfrosch 0:7627c79db971 97 # else
Gruenfrosch 0:7627c79db971 98 # define SHIFT(x) (x)
Gruenfrosch 0:7627c79db971 99 # endif
Gruenfrosch 0:7627c79db971 100
Gruenfrosch 0:7627c79db971 101 /* possible DCT speed optimization */
Gruenfrosch 0:7627c79db971 102
Gruenfrosch 0:7627c79db971 103 # if defined(OPT_SPEED) && defined(MAD_F_MLX)
Gruenfrosch 0:7627c79db971 104 # define OPT_DCTO
Gruenfrosch 0:7627c79db971 105 # define MUL(x, y) \
Gruenfrosch 0:7627c79db971 106 ({ mad_fixed64hi_t hi; \
Gruenfrosch 0:7627c79db971 107 mad_fixed64lo_t lo; \
Gruenfrosch 0:7627c79db971 108 MAD_F_MLX(hi, lo, (x), (y)); \
Gruenfrosch 0:7627c79db971 109 hi << (32 - MAD_F_SCALEBITS - 3); \
Gruenfrosch 0:7627c79db971 110 })
Gruenfrosch 0:7627c79db971 111 # else
Gruenfrosch 0:7627c79db971 112 # undef OPT_DCTO
Gruenfrosch 0:7627c79db971 113 # define MUL(x, y) mad_f_mul((x), (y))
Gruenfrosch 0:7627c79db971 114 # endif
Gruenfrosch 0:7627c79db971 115
Gruenfrosch 0:7627c79db971 116 /*
Gruenfrosch 0:7627c79db971 117 * NAME: dct32()
Gruenfrosch 0:7627c79db971 118 * DESCRIPTION: perform fast in[32]->out[32] DCT
Gruenfrosch 0:7627c79db971 119 */
Gruenfrosch 0:7627c79db971 120 static
Gruenfrosch 0:7627c79db971 121 void dct32(mad_fixed_t const in[32], unsigned int slot,
Gruenfrosch 0:7627c79db971 122 mad_fixed_t lo[16][8], mad_fixed_t hi[16][8])
Gruenfrosch 0:7627c79db971 123 {
Gruenfrosch 0:7627c79db971 124 mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7;
Gruenfrosch 0:7627c79db971 125 mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15;
Gruenfrosch 0:7627c79db971 126 mad_fixed_t t16, t17, t18, t19, t20, t21, t22, t23;
Gruenfrosch 0:7627c79db971 127 mad_fixed_t t24, t25, t26, t27, t28, t29, t30, t31;
Gruenfrosch 0:7627c79db971 128 mad_fixed_t t32, t33, t34, t35, t36, t37, t38, t39;
Gruenfrosch 0:7627c79db971 129 mad_fixed_t t40, t41, t42, t43, t44, t45, t46, t47;
Gruenfrosch 0:7627c79db971 130 mad_fixed_t t48, t49, t50, t51, t52, t53, t54, t55;
Gruenfrosch 0:7627c79db971 131 mad_fixed_t t56, t57, t58, t59, t60, t61, t62, t63;
Gruenfrosch 0:7627c79db971 132 mad_fixed_t t64, t65, t66, t67, t68, t69, t70, t71;
Gruenfrosch 0:7627c79db971 133 mad_fixed_t t72, t73, t74, t75, t76, t77, t78, t79;
Gruenfrosch 0:7627c79db971 134 mad_fixed_t t80, t81, t82, t83, t84, t85, t86, t87;
Gruenfrosch 0:7627c79db971 135 mad_fixed_t t88, t89, t90, t91, t92, t93, t94, t95;
Gruenfrosch 0:7627c79db971 136 mad_fixed_t t96, t97, t98, t99, t100, t101, t102, t103;
Gruenfrosch 0:7627c79db971 137 mad_fixed_t t104, t105, t106, t107, t108, t109, t110, t111;
Gruenfrosch 0:7627c79db971 138 mad_fixed_t t112, t113, t114, t115, t116, t117, t118, t119;
Gruenfrosch 0:7627c79db971 139 mad_fixed_t t120, t121, t122, t123, t124, t125, t126, t127;
Gruenfrosch 0:7627c79db971 140 mad_fixed_t t128, t129, t130, t131, t132, t133, t134, t135;
Gruenfrosch 0:7627c79db971 141 mad_fixed_t t136, t137, t138, t139, t140, t141, t142, t143;
Gruenfrosch 0:7627c79db971 142 mad_fixed_t t144, t145, t146, t147, t148, t149, t150, t151;
Gruenfrosch 0:7627c79db971 143 mad_fixed_t t152, t153, t154, t155, t156, t157, t158, t159;
Gruenfrosch 0:7627c79db971 144 mad_fixed_t t160, t161, t162, t163, t164, t165, t166, t167;
Gruenfrosch 0:7627c79db971 145 mad_fixed_t t168, t169, t170, t171, t172, t173, t174, t175;
Gruenfrosch 0:7627c79db971 146 mad_fixed_t t176;
Gruenfrosch 0:7627c79db971 147
Gruenfrosch 0:7627c79db971 148 /* costab[i] = cos(PI / (2 * 32) * i) */
Gruenfrosch 0:7627c79db971 149
Gruenfrosch 0:7627c79db971 150 # if defined(OPT_DCTO)
Gruenfrosch 0:7627c79db971 151 # define costab1 MAD_F(0x7fd8878e)
Gruenfrosch 0:7627c79db971 152 # define costab2 MAD_F(0x7f62368f)
Gruenfrosch 0:7627c79db971 153 # define costab3 MAD_F(0x7e9d55fc)
Gruenfrosch 0:7627c79db971 154 # define costab4 MAD_F(0x7d8a5f40)
Gruenfrosch 0:7627c79db971 155 # define costab5 MAD_F(0x7c29fbee)
Gruenfrosch 0:7627c79db971 156 # define costab6 MAD_F(0x7a7d055b)
Gruenfrosch 0:7627c79db971 157 # define costab7 MAD_F(0x78848414)
Gruenfrosch 0:7627c79db971 158 # define costab8 MAD_F(0x7641af3d)
Gruenfrosch 0:7627c79db971 159 # define costab9 MAD_F(0x73b5ebd1)
Gruenfrosch 0:7627c79db971 160 # define costab10 MAD_F(0x70e2cbc6)
Gruenfrosch 0:7627c79db971 161 # define costab11 MAD_F(0x6dca0d14)
Gruenfrosch 0:7627c79db971 162 # define costab12 MAD_F(0x6a6d98a4)
Gruenfrosch 0:7627c79db971 163 # define costab13 MAD_F(0x66cf8120)
Gruenfrosch 0:7627c79db971 164 # define costab14 MAD_F(0x62f201ac)
Gruenfrosch 0:7627c79db971 165 # define costab15 MAD_F(0x5ed77c8a)
Gruenfrosch 0:7627c79db971 166 # define costab16 MAD_F(0x5a82799a)
Gruenfrosch 0:7627c79db971 167 # define costab17 MAD_F(0x55f5a4d2)
Gruenfrosch 0:7627c79db971 168 # define costab18 MAD_F(0x5133cc94)
Gruenfrosch 0:7627c79db971 169 # define costab19 MAD_F(0x4c3fdff4)
Gruenfrosch 0:7627c79db971 170 # define costab20 MAD_F(0x471cece7)
Gruenfrosch 0:7627c79db971 171 # define costab21 MAD_F(0x41ce1e65)
Gruenfrosch 0:7627c79db971 172 # define costab22 MAD_F(0x3c56ba70)
Gruenfrosch 0:7627c79db971 173 # define costab23 MAD_F(0x36ba2014)
Gruenfrosch 0:7627c79db971 174 # define costab24 MAD_F(0x30fbc54d)
Gruenfrosch 0:7627c79db971 175 # define costab25 MAD_F(0x2b1f34eb)
Gruenfrosch 0:7627c79db971 176 # define costab26 MAD_F(0x25280c5e)
Gruenfrosch 0:7627c79db971 177 # define costab27 MAD_F(0x1f19f97b)
Gruenfrosch 0:7627c79db971 178 # define costab28 MAD_F(0x18f8b83c)
Gruenfrosch 0:7627c79db971 179 # define costab29 MAD_F(0x12c8106f)
Gruenfrosch 0:7627c79db971 180 # define costab30 MAD_F(0x0c8bd35e)
Gruenfrosch 0:7627c79db971 181 # define costab31 MAD_F(0x0647d97c)
Gruenfrosch 0:7627c79db971 182 # else
Gruenfrosch 0:7627c79db971 183 # define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */
Gruenfrosch 0:7627c79db971 184 # define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */
Gruenfrosch 0:7627c79db971 185 # define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */
Gruenfrosch 0:7627c79db971 186 # define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */
Gruenfrosch 0:7627c79db971 187 # define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */
Gruenfrosch 0:7627c79db971 188 # define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */
Gruenfrosch 0:7627c79db971 189 # define costab7 MAD_F(0x0f109082) /* 0.941544065 */
Gruenfrosch 0:7627c79db971 190 # define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */
Gruenfrosch 0:7627c79db971 191 # define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */
Gruenfrosch 0:7627c79db971 192 # define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */
Gruenfrosch 0:7627c79db971 193 # define costab11 MAD_F(0x0db941a3) /* 0.857728610 */
Gruenfrosch 0:7627c79db971 194 # define costab12 MAD_F(0x0d4db315) /* 0.831469612 */
Gruenfrosch 0:7627c79db971 195 # define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */
Gruenfrosch 0:7627c79db971 196 # define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */
Gruenfrosch 0:7627c79db971 197 # define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */
Gruenfrosch 0:7627c79db971 198 # define costab16 MAD_F(0x0b504f33) /* 0.707106781 */
Gruenfrosch 0:7627c79db971 199 # define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */
Gruenfrosch 0:7627c79db971 200 # define costab18 MAD_F(0x0a267993) /* 0.634393284 */
Gruenfrosch 0:7627c79db971 201 # define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */
Gruenfrosch 0:7627c79db971 202 # define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */
Gruenfrosch 0:7627c79db971 203 # define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */
Gruenfrosch 0:7627c79db971 204 # define costab22 MAD_F(0x078ad74e) /* 0.471396737 */
Gruenfrosch 0:7627c79db971 205 # define costab23 MAD_F(0x06d74402) /* 0.427555093 */
Gruenfrosch 0:7627c79db971 206 # define costab24 MAD_F(0x061f78aa) /* 0.382683432 */
Gruenfrosch 0:7627c79db971 207 # define costab25 MAD_F(0x0563e69d) /* 0.336889853 */
Gruenfrosch 0:7627c79db971 208 # define costab26 MAD_F(0x04a5018c) /* 0.290284677 */
Gruenfrosch 0:7627c79db971 209 # define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
Gruenfrosch 0:7627c79db971 210 # define costab28 MAD_F(0x031f1708) /* 0.195090322 */
Gruenfrosch 0:7627c79db971 211 # define costab29 MAD_F(0x0259020e) /* 0.146730474 */
Gruenfrosch 0:7627c79db971 212 # define costab30 MAD_F(0x01917a6c) /* 0.098017140 */
Gruenfrosch 0:7627c79db971 213 # define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
Gruenfrosch 0:7627c79db971 214 # endif
Gruenfrosch 0:7627c79db971 215
Gruenfrosch 0:7627c79db971 216 t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1);
Gruenfrosch 0:7627c79db971 217 t1 = in[15] + in[16]; t17 = MUL(in[15] - in[16], costab31);
Gruenfrosch 0:7627c79db971 218
Gruenfrosch 0:7627c79db971 219 t41 = t16 + t17;
Gruenfrosch 0:7627c79db971 220 t59 = MUL(t16 - t17, costab2);
Gruenfrosch 0:7627c79db971 221 t33 = t0 + t1;
Gruenfrosch 0:7627c79db971 222 t50 = MUL(t0 - t1, costab2);
Gruenfrosch 0:7627c79db971 223
Gruenfrosch 0:7627c79db971 224 t2 = in[7] + in[24]; t18 = MUL(in[7] - in[24], costab15);
Gruenfrosch 0:7627c79db971 225 t3 = in[8] + in[23]; t19 = MUL(in[8] - in[23], costab17);
Gruenfrosch 0:7627c79db971 226
Gruenfrosch 0:7627c79db971 227 t42 = t18 + t19;
Gruenfrosch 0:7627c79db971 228 t60 = MUL(t18 - t19, costab30);
Gruenfrosch 0:7627c79db971 229 t34 = t2 + t3;
Gruenfrosch 0:7627c79db971 230 t51 = MUL(t2 - t3, costab30);
Gruenfrosch 0:7627c79db971 231
Gruenfrosch 0:7627c79db971 232 t4 = in[3] + in[28]; t20 = MUL(in[3] - in[28], costab7);
Gruenfrosch 0:7627c79db971 233 t5 = in[12] + in[19]; t21 = MUL(in[12] - in[19], costab25);
Gruenfrosch 0:7627c79db971 234
Gruenfrosch 0:7627c79db971 235 t43 = t20 + t21;
Gruenfrosch 0:7627c79db971 236 t61 = MUL(t20 - t21, costab14);
Gruenfrosch 0:7627c79db971 237 t35 = t4 + t5;
Gruenfrosch 0:7627c79db971 238 t52 = MUL(t4 - t5, costab14);
Gruenfrosch 0:7627c79db971 239
Gruenfrosch 0:7627c79db971 240 t6 = in[4] + in[27]; t22 = MUL(in[4] - in[27], costab9);
Gruenfrosch 0:7627c79db971 241 t7 = in[11] + in[20]; t23 = MUL(in[11] - in[20], costab23);
Gruenfrosch 0:7627c79db971 242
Gruenfrosch 0:7627c79db971 243 t44 = t22 + t23;
Gruenfrosch 0:7627c79db971 244 t62 = MUL(t22 - t23, costab18);
Gruenfrosch 0:7627c79db971 245 t36 = t6 + t7;
Gruenfrosch 0:7627c79db971 246 t53 = MUL(t6 - t7, costab18);
Gruenfrosch 0:7627c79db971 247
Gruenfrosch 0:7627c79db971 248 t8 = in[1] + in[30]; t24 = MUL(in[1] - in[30], costab3);
Gruenfrosch 0:7627c79db971 249 t9 = in[14] + in[17]; t25 = MUL(in[14] - in[17], costab29);
Gruenfrosch 0:7627c79db971 250
Gruenfrosch 0:7627c79db971 251 t45 = t24 + t25;
Gruenfrosch 0:7627c79db971 252 t63 = MUL(t24 - t25, costab6);
Gruenfrosch 0:7627c79db971 253 t37 = t8 + t9;
Gruenfrosch 0:7627c79db971 254 t54 = MUL(t8 - t9, costab6);
Gruenfrosch 0:7627c79db971 255
Gruenfrosch 0:7627c79db971 256 t10 = in[6] + in[25]; t26 = MUL(in[6] - in[25], costab13);
Gruenfrosch 0:7627c79db971 257 t11 = in[9] + in[22]; t27 = MUL(in[9] - in[22], costab19);
Gruenfrosch 0:7627c79db971 258
Gruenfrosch 0:7627c79db971 259 t46 = t26 + t27;
Gruenfrosch 0:7627c79db971 260 t64 = MUL(t26 - t27, costab26);
Gruenfrosch 0:7627c79db971 261 t38 = t10 + t11;
Gruenfrosch 0:7627c79db971 262 t55 = MUL(t10 - t11, costab26);
Gruenfrosch 0:7627c79db971 263
Gruenfrosch 0:7627c79db971 264 t12 = in[2] + in[29]; t28 = MUL(in[2] - in[29], costab5);
Gruenfrosch 0:7627c79db971 265 t13 = in[13] + in[18]; t29 = MUL(in[13] - in[18], costab27);
Gruenfrosch 0:7627c79db971 266
Gruenfrosch 0:7627c79db971 267 t47 = t28 + t29;
Gruenfrosch 0:7627c79db971 268 t65 = MUL(t28 - t29, costab10);
Gruenfrosch 0:7627c79db971 269 t39 = t12 + t13;
Gruenfrosch 0:7627c79db971 270 t56 = MUL(t12 - t13, costab10);
Gruenfrosch 0:7627c79db971 271
Gruenfrosch 0:7627c79db971 272 t14 = in[5] + in[26]; t30 = MUL(in[5] - in[26], costab11);
Gruenfrosch 0:7627c79db971 273 t15 = in[10] + in[21]; t31 = MUL(in[10] - in[21], costab21);
Gruenfrosch 0:7627c79db971 274
Gruenfrosch 0:7627c79db971 275 t48 = t30 + t31;
Gruenfrosch 0:7627c79db971 276 t66 = MUL(t30 - t31, costab22);
Gruenfrosch 0:7627c79db971 277 t40 = t14 + t15;
Gruenfrosch 0:7627c79db971 278 t57 = MUL(t14 - t15, costab22);
Gruenfrosch 0:7627c79db971 279
Gruenfrosch 0:7627c79db971 280 t69 = t33 + t34; t89 = MUL(t33 - t34, costab4);
Gruenfrosch 0:7627c79db971 281 t70 = t35 + t36; t90 = MUL(t35 - t36, costab28);
Gruenfrosch 0:7627c79db971 282 t71 = t37 + t38; t91 = MUL(t37 - t38, costab12);
Gruenfrosch 0:7627c79db971 283 t72 = t39 + t40; t92 = MUL(t39 - t40, costab20);
Gruenfrosch 0:7627c79db971 284 t73 = t41 + t42; t94 = MUL(t41 - t42, costab4);
Gruenfrosch 0:7627c79db971 285 t74 = t43 + t44; t95 = MUL(t43 - t44, costab28);
Gruenfrosch 0:7627c79db971 286 t75 = t45 + t46; t96 = MUL(t45 - t46, costab12);
Gruenfrosch 0:7627c79db971 287 t76 = t47 + t48; t97 = MUL(t47 - t48, costab20);
Gruenfrosch 0:7627c79db971 288
Gruenfrosch 0:7627c79db971 289 t78 = t50 + t51; t100 = MUL(t50 - t51, costab4);
Gruenfrosch 0:7627c79db971 290 t79 = t52 + t53; t101 = MUL(t52 - t53, costab28);
Gruenfrosch 0:7627c79db971 291 t80 = t54 + t55; t102 = MUL(t54 - t55, costab12);
Gruenfrosch 0:7627c79db971 292 t81 = t56 + t57; t103 = MUL(t56 - t57, costab20);
Gruenfrosch 0:7627c79db971 293
Gruenfrosch 0:7627c79db971 294 t83 = t59 + t60; t106 = MUL(t59 - t60, costab4);
Gruenfrosch 0:7627c79db971 295 t84 = t61 + t62; t107 = MUL(t61 - t62, costab28);
Gruenfrosch 0:7627c79db971 296 t85 = t63 + t64; t108 = MUL(t63 - t64, costab12);
Gruenfrosch 0:7627c79db971 297 t86 = t65 + t66; t109 = MUL(t65 - t66, costab20);
Gruenfrosch 0:7627c79db971 298
Gruenfrosch 0:7627c79db971 299 t113 = t69 + t70;
Gruenfrosch 0:7627c79db971 300 t114 = t71 + t72;
Gruenfrosch 0:7627c79db971 301
Gruenfrosch 0:7627c79db971 302 /* 0 */ hi[15][slot] = SHIFT(t113 + t114);
Gruenfrosch 0:7627c79db971 303 /* 16 */ lo[ 0][slot] = SHIFT(MUL(t113 - t114, costab16));
Gruenfrosch 0:7627c79db971 304
Gruenfrosch 0:7627c79db971 305 t115 = t73 + t74;
Gruenfrosch 0:7627c79db971 306 t116 = t75 + t76;
Gruenfrosch 0:7627c79db971 307
Gruenfrosch 0:7627c79db971 308 t32 = t115 + t116;
Gruenfrosch 0:7627c79db971 309
Gruenfrosch 0:7627c79db971 310 /* 1 */ hi[14][slot] = SHIFT(t32);
Gruenfrosch 0:7627c79db971 311
Gruenfrosch 0:7627c79db971 312 t118 = t78 + t79;
Gruenfrosch 0:7627c79db971 313 t119 = t80 + t81;
Gruenfrosch 0:7627c79db971 314
Gruenfrosch 0:7627c79db971 315 t58 = t118 + t119;
Gruenfrosch 0:7627c79db971 316
Gruenfrosch 0:7627c79db971 317 /* 2 */ hi[13][slot] = SHIFT(t58);
Gruenfrosch 0:7627c79db971 318
Gruenfrosch 0:7627c79db971 319 t121 = t83 + t84;
Gruenfrosch 0:7627c79db971 320 t122 = t85 + t86;
Gruenfrosch 0:7627c79db971 321
Gruenfrosch 0:7627c79db971 322 t67 = t121 + t122;
Gruenfrosch 0:7627c79db971 323
Gruenfrosch 0:7627c79db971 324 t49 = (t67 * 2) - t32;
Gruenfrosch 0:7627c79db971 325
Gruenfrosch 0:7627c79db971 326 /* 3 */ hi[12][slot] = SHIFT(t49);
Gruenfrosch 0:7627c79db971 327
Gruenfrosch 0:7627c79db971 328 t125 = t89 + t90;
Gruenfrosch 0:7627c79db971 329 t126 = t91 + t92;
Gruenfrosch 0:7627c79db971 330
Gruenfrosch 0:7627c79db971 331 t93 = t125 + t126;
Gruenfrosch 0:7627c79db971 332
Gruenfrosch 0:7627c79db971 333 /* 4 */ hi[11][slot] = SHIFT(t93);
Gruenfrosch 0:7627c79db971 334
Gruenfrosch 0:7627c79db971 335 t128 = t94 + t95;
Gruenfrosch 0:7627c79db971 336 t129 = t96 + t97;
Gruenfrosch 0:7627c79db971 337
Gruenfrosch 0:7627c79db971 338 t98 = t128 + t129;
Gruenfrosch 0:7627c79db971 339
Gruenfrosch 0:7627c79db971 340 t68 = (t98 * 2) - t49;
Gruenfrosch 0:7627c79db971 341
Gruenfrosch 0:7627c79db971 342 /* 5 */ hi[10][slot] = SHIFT(t68);
Gruenfrosch 0:7627c79db971 343
Gruenfrosch 0:7627c79db971 344 t132 = t100 + t101;
Gruenfrosch 0:7627c79db971 345 t133 = t102 + t103;
Gruenfrosch 0:7627c79db971 346
Gruenfrosch 0:7627c79db971 347 t104 = t132 + t133;
Gruenfrosch 0:7627c79db971 348
Gruenfrosch 0:7627c79db971 349 t82 = (t104 * 2) - t58;
Gruenfrosch 0:7627c79db971 350
Gruenfrosch 0:7627c79db971 351 /* 6 */ hi[ 9][slot] = SHIFT(t82);
Gruenfrosch 0:7627c79db971 352
Gruenfrosch 0:7627c79db971 353 t136 = t106 + t107;
Gruenfrosch 0:7627c79db971 354 t137 = t108 + t109;
Gruenfrosch 0:7627c79db971 355
Gruenfrosch 0:7627c79db971 356 t110 = t136 + t137;
Gruenfrosch 0:7627c79db971 357
Gruenfrosch 0:7627c79db971 358 t87 = (t110 * 2) - t67;
Gruenfrosch 0:7627c79db971 359
Gruenfrosch 0:7627c79db971 360 t77 = (t87 * 2) - t68;
Gruenfrosch 0:7627c79db971 361
Gruenfrosch 0:7627c79db971 362 /* 7 */ hi[ 8][slot] = SHIFT(t77);
Gruenfrosch 0:7627c79db971 363
Gruenfrosch 0:7627c79db971 364 t141 = MUL(t69 - t70, costab8);
Gruenfrosch 0:7627c79db971 365 t142 = MUL(t71 - t72, costab24);
Gruenfrosch 0:7627c79db971 366 t143 = t141 + t142;
Gruenfrosch 0:7627c79db971 367
Gruenfrosch 0:7627c79db971 368 /* 8 */ hi[ 7][slot] = SHIFT(t143);
Gruenfrosch 0:7627c79db971 369 /* 24 */ lo[ 8][slot] =
Gruenfrosch 0:7627c79db971 370 SHIFT((MUL(t141 - t142, costab16) * 2) - t143);
Gruenfrosch 0:7627c79db971 371
Gruenfrosch 0:7627c79db971 372 t144 = MUL(t73 - t74, costab8);
Gruenfrosch 0:7627c79db971 373 t145 = MUL(t75 - t76, costab24);
Gruenfrosch 0:7627c79db971 374 t146 = t144 + t145;
Gruenfrosch 0:7627c79db971 375
Gruenfrosch 0:7627c79db971 376 t88 = (t146 * 2) - t77;
Gruenfrosch 0:7627c79db971 377
Gruenfrosch 0:7627c79db971 378 /* 9 */ hi[ 6][slot] = SHIFT(t88);
Gruenfrosch 0:7627c79db971 379
Gruenfrosch 0:7627c79db971 380 t148 = MUL(t78 - t79, costab8);
Gruenfrosch 0:7627c79db971 381 t149 = MUL(t80 - t81, costab24);
Gruenfrosch 0:7627c79db971 382 t150 = t148 + t149;
Gruenfrosch 0:7627c79db971 383
Gruenfrosch 0:7627c79db971 384 t105 = (t150 * 2) - t82;
Gruenfrosch 0:7627c79db971 385
Gruenfrosch 0:7627c79db971 386 /* 10 */ hi[ 5][slot] = SHIFT(t105);
Gruenfrosch 0:7627c79db971 387
Gruenfrosch 0:7627c79db971 388 t152 = MUL(t83 - t84, costab8);
Gruenfrosch 0:7627c79db971 389 t153 = MUL(t85 - t86, costab24);
Gruenfrosch 0:7627c79db971 390 t154 = t152 + t153;
Gruenfrosch 0:7627c79db971 391
Gruenfrosch 0:7627c79db971 392 t111 = (t154 * 2) - t87;
Gruenfrosch 0:7627c79db971 393
Gruenfrosch 0:7627c79db971 394 t99 = (t111 * 2) - t88;
Gruenfrosch 0:7627c79db971 395
Gruenfrosch 0:7627c79db971 396 /* 11 */ hi[ 4][slot] = SHIFT(t99);
Gruenfrosch 0:7627c79db971 397
Gruenfrosch 0:7627c79db971 398 t157 = MUL(t89 - t90, costab8);
Gruenfrosch 0:7627c79db971 399 t158 = MUL(t91 - t92, costab24);
Gruenfrosch 0:7627c79db971 400 t159 = t157 + t158;
Gruenfrosch 0:7627c79db971 401
Gruenfrosch 0:7627c79db971 402 t127 = (t159 * 2) - t93;
Gruenfrosch 0:7627c79db971 403
Gruenfrosch 0:7627c79db971 404 /* 12 */ hi[ 3][slot] = SHIFT(t127);
Gruenfrosch 0:7627c79db971 405
Gruenfrosch 0:7627c79db971 406 t160 = (MUL(t125 - t126, costab16) * 2) - t127;
Gruenfrosch 0:7627c79db971 407
Gruenfrosch 0:7627c79db971 408 /* 20 */ lo[ 4][slot] = SHIFT(t160);
Gruenfrosch 0:7627c79db971 409 /* 28 */ lo[12][slot] =
Gruenfrosch 0:7627c79db971 410 SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160);
Gruenfrosch 0:7627c79db971 411
Gruenfrosch 0:7627c79db971 412 t161 = MUL(t94 - t95, costab8);
Gruenfrosch 0:7627c79db971 413 t162 = MUL(t96 - t97, costab24);
Gruenfrosch 0:7627c79db971 414 t163 = t161 + t162;
Gruenfrosch 0:7627c79db971 415
Gruenfrosch 0:7627c79db971 416 t130 = (t163 * 2) - t98;
Gruenfrosch 0:7627c79db971 417
Gruenfrosch 0:7627c79db971 418 t112 = (t130 * 2) - t99;
Gruenfrosch 0:7627c79db971 419
Gruenfrosch 0:7627c79db971 420 /* 13 */ hi[ 2][slot] = SHIFT(t112);
Gruenfrosch 0:7627c79db971 421
Gruenfrosch 0:7627c79db971 422 t164 = (MUL(t128 - t129, costab16) * 2) - t130;
Gruenfrosch 0:7627c79db971 423
Gruenfrosch 0:7627c79db971 424 t166 = MUL(t100 - t101, costab8);
Gruenfrosch 0:7627c79db971 425 t167 = MUL(t102 - t103, costab24);
Gruenfrosch 0:7627c79db971 426 t168 = t166 + t167;
Gruenfrosch 0:7627c79db971 427
Gruenfrosch 0:7627c79db971 428 t134 = (t168 * 2) - t104;
Gruenfrosch 0:7627c79db971 429
Gruenfrosch 0:7627c79db971 430 t120 = (t134 * 2) - t105;
Gruenfrosch 0:7627c79db971 431
Gruenfrosch 0:7627c79db971 432 /* 14 */ hi[ 1][slot] = SHIFT(t120);
Gruenfrosch 0:7627c79db971 433
Gruenfrosch 0:7627c79db971 434 t135 = (MUL(t118 - t119, costab16) * 2) - t120;
Gruenfrosch 0:7627c79db971 435
Gruenfrosch 0:7627c79db971 436 /* 18 */ lo[ 2][slot] = SHIFT(t135);
Gruenfrosch 0:7627c79db971 437
Gruenfrosch 0:7627c79db971 438 t169 = (MUL(t132 - t133, costab16) * 2) - t134;
Gruenfrosch 0:7627c79db971 439
Gruenfrosch 0:7627c79db971 440 t151 = (t169 * 2) - t135;
Gruenfrosch 0:7627c79db971 441
Gruenfrosch 0:7627c79db971 442 /* 22 */ lo[ 6][slot] = SHIFT(t151);
Gruenfrosch 0:7627c79db971 443
Gruenfrosch 0:7627c79db971 444 t170 = (((MUL(t148 - t149, costab16) * 2) - t150) * 2) - t151;
Gruenfrosch 0:7627c79db971 445
Gruenfrosch 0:7627c79db971 446 /* 26 */ lo[10][slot] = SHIFT(t170);
Gruenfrosch 0:7627c79db971 447 /* 30 */ lo[14][slot] =
Gruenfrosch 0:7627c79db971 448 SHIFT((((((MUL(t166 - t167, costab16) * 2) -
Gruenfrosch 0:7627c79db971 449 t168) * 2) - t169) * 2) - t170);
Gruenfrosch 0:7627c79db971 450
Gruenfrosch 0:7627c79db971 451 t171 = MUL(t106 - t107, costab8);
Gruenfrosch 0:7627c79db971 452 t172 = MUL(t108 - t109, costab24);
Gruenfrosch 0:7627c79db971 453 t173 = t171 + t172;
Gruenfrosch 0:7627c79db971 454
Gruenfrosch 0:7627c79db971 455 t138 = (t173 * 2) - t110;
Gruenfrosch 0:7627c79db971 456
Gruenfrosch 0:7627c79db971 457 t123 = (t138 * 2) - t111;
Gruenfrosch 0:7627c79db971 458
Gruenfrosch 0:7627c79db971 459 t139 = (MUL(t121 - t122, costab16) * 2) - t123;
Gruenfrosch 0:7627c79db971 460
Gruenfrosch 0:7627c79db971 461 t117 = (t123 * 2) - t112;
Gruenfrosch 0:7627c79db971 462
Gruenfrosch 0:7627c79db971 463 /* 15 */ hi[ 0][slot] = SHIFT(t117);
Gruenfrosch 0:7627c79db971 464
Gruenfrosch 0:7627c79db971 465 t124 = (MUL(t115 - t116, costab16) * 2) - t117;
Gruenfrosch 0:7627c79db971 466
Gruenfrosch 0:7627c79db971 467 /* 17 */ lo[ 1][slot] = SHIFT(t124);
Gruenfrosch 0:7627c79db971 468
Gruenfrosch 0:7627c79db971 469 t131 = (t139 * 2) - t124;
Gruenfrosch 0:7627c79db971 470
Gruenfrosch 0:7627c79db971 471 /* 19 */ lo[ 3][slot] = SHIFT(t131);
Gruenfrosch 0:7627c79db971 472
Gruenfrosch 0:7627c79db971 473 t140 = (t164 * 2) - t131;
Gruenfrosch 0:7627c79db971 474
Gruenfrosch 0:7627c79db971 475 /* 21 */ lo[ 5][slot] = SHIFT(t140);
Gruenfrosch 0:7627c79db971 476
Gruenfrosch 0:7627c79db971 477 t174 = (MUL(t136 - t137, costab16) * 2) - t138;
Gruenfrosch 0:7627c79db971 478
Gruenfrosch 0:7627c79db971 479 t155 = (t174 * 2) - t139;
Gruenfrosch 0:7627c79db971 480
Gruenfrosch 0:7627c79db971 481 t147 = (t155 * 2) - t140;
Gruenfrosch 0:7627c79db971 482
Gruenfrosch 0:7627c79db971 483 /* 23 */ lo[ 7][slot] = SHIFT(t147);
Gruenfrosch 0:7627c79db971 484
Gruenfrosch 0:7627c79db971 485 t156 = (((MUL(t144 - t145, costab16) * 2) - t146) * 2) - t147;
Gruenfrosch 0:7627c79db971 486
Gruenfrosch 0:7627c79db971 487 /* 25 */ lo[ 9][slot] = SHIFT(t156);
Gruenfrosch 0:7627c79db971 488
Gruenfrosch 0:7627c79db971 489 t175 = (((MUL(t152 - t153, costab16) * 2) - t154) * 2) - t155;
Gruenfrosch 0:7627c79db971 490
Gruenfrosch 0:7627c79db971 491 t165 = (t175 * 2) - t156;
Gruenfrosch 0:7627c79db971 492
Gruenfrosch 0:7627c79db971 493 /* 27 */ lo[11][slot] = SHIFT(t165);
Gruenfrosch 0:7627c79db971 494
Gruenfrosch 0:7627c79db971 495 t176 = (((((MUL(t161 - t162, costab16) * 2) -
Gruenfrosch 0:7627c79db971 496 t163) * 2) - t164) * 2) - t165;
Gruenfrosch 0:7627c79db971 497
Gruenfrosch 0:7627c79db971 498 /* 29 */ lo[13][slot] = SHIFT(t176);
Gruenfrosch 0:7627c79db971 499 /* 31 */ lo[15][slot] =
Gruenfrosch 0:7627c79db971 500 SHIFT((((((((MUL(t171 - t172, costab16) * 2) -
Gruenfrosch 0:7627c79db971 501 t173) * 2) - t174) * 2) - t175) * 2) - t176);
Gruenfrosch 0:7627c79db971 502
Gruenfrosch 0:7627c79db971 503 /*
Gruenfrosch 0:7627c79db971 504 * Totals:
Gruenfrosch 0:7627c79db971 505 * 80 multiplies
Gruenfrosch 0:7627c79db971 506 * 80 additions
Gruenfrosch 0:7627c79db971 507 * 119 subtractions
Gruenfrosch 0:7627c79db971 508 * 49 shifts (not counting SSO)
Gruenfrosch 0:7627c79db971 509 */
Gruenfrosch 0:7627c79db971 510 }
Gruenfrosch 0:7627c79db971 511
Gruenfrosch 0:7627c79db971 512 # undef MUL
Gruenfrosch 0:7627c79db971 513 # undef SHIFT
Gruenfrosch 0:7627c79db971 514
Gruenfrosch 0:7627c79db971 515 /* third SSO shift and/or D[] optimization preshift */
Gruenfrosch 0:7627c79db971 516
Gruenfrosch 0:7627c79db971 517 # if defined(OPT_SSO)
Gruenfrosch 0:7627c79db971 518 # if MAD_F_FRACBITS != 28
Gruenfrosch 0:7627c79db971 519 # error "MAD_F_FRACBITS must be 28 to use OPT_SSO"
Gruenfrosch 0:7627c79db971 520 # endif
Gruenfrosch 0:7627c79db971 521 # define ML0(hi, lo, x, y) ((lo) = (x) * (y))
Gruenfrosch 0:7627c79db971 522 # define MLA(hi, lo, x, y) ((lo) += (x) * (y))
Gruenfrosch 0:7627c79db971 523 # define MLN(hi, lo) ((lo) = -(lo))
Gruenfrosch 0:7627c79db971 524 # define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
Gruenfrosch 0:7627c79db971 525 # define SHIFT(x) ((x) >> 2)
Gruenfrosch 0:7627c79db971 526 # define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14)
Gruenfrosch 0:7627c79db971 527 # else
Gruenfrosch 0:7627c79db971 528 # define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y))
Gruenfrosch 0:7627c79db971 529 # define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y))
Gruenfrosch 0:7627c79db971 530 # define MLN(hi, lo) MAD_F_MLN((hi), (lo))
Gruenfrosch 0:7627c79db971 531 # define MLZ(hi, lo) MAD_F_MLZ((hi), (lo))
Gruenfrosch 0:7627c79db971 532 # define SHIFT(x) (x)
Gruenfrosch 0:7627c79db971 533 # if defined(MAD_F_SCALEBITS)
Gruenfrosch 0:7627c79db971 534 # undef MAD_F_SCALEBITS
Gruenfrosch 0:7627c79db971 535 # define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12)
Gruenfrosch 0:7627c79db971 536 # define PRESHIFT(x) (MAD_F(x) >> 12)
Gruenfrosch 0:7627c79db971 537 # else
Gruenfrosch 0:7627c79db971 538 # define PRESHIFT(x) MAD_F(x)
Gruenfrosch 0:7627c79db971 539 # endif
Gruenfrosch 0:7627c79db971 540 # endif
Gruenfrosch 0:7627c79db971 541
Gruenfrosch 0:7627c79db971 542 static
Gruenfrosch 0:7627c79db971 543 mad_fixed_t const D[17][32] = {
Gruenfrosch 0:7627c79db971 544 # include "d.h"
Gruenfrosch 0:7627c79db971 545 };
Gruenfrosch 0:7627c79db971 546
Gruenfrosch 0:7627c79db971 547 # if defined(ASO_SYNTH)
Gruenfrosch 0:7627c79db971 548 void synth_full(struct mad_synth *, struct mad_frame const *,
Gruenfrosch 0:7627c79db971 549 unsigned int, unsigned int);
Gruenfrosch 0:7627c79db971 550 # else
Gruenfrosch 0:7627c79db971 551 /*
Gruenfrosch 0:7627c79db971 552 * NAME: synth->full()
Gruenfrosch 0:7627c79db971 553 * DESCRIPTION: perform full frequency PCM synthesis
Gruenfrosch 0:7627c79db971 554 */
Gruenfrosch 0:7627c79db971 555 static
Gruenfrosch 0:7627c79db971 556 void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
Gruenfrosch 0:7627c79db971 557 unsigned int nch, unsigned int ns)
Gruenfrosch 0:7627c79db971 558 {
Gruenfrosch 0:7627c79db971 559 unsigned int phase, ch, s, sb, pe, po;
Gruenfrosch 0:7627c79db971 560 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
Gruenfrosch 0:7627c79db971 561 mad_fixed_t const (*sbsample)[36][32];
Gruenfrosch 0:7627c79db971 562 register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
Gruenfrosch 0:7627c79db971 563 register mad_fixed_t const (*Dptr)[32], *ptr;
Gruenfrosch 0:7627c79db971 564 register mad_fixed64hi_t hi;
Gruenfrosch 0:7627c79db971 565 register mad_fixed64lo_t lo;
Gruenfrosch 0:7627c79db971 566
Gruenfrosch 0:7627c79db971 567 for (ch = 0; ch < nch; ++ch) {
Gruenfrosch 0:7627c79db971 568 sbsample = &frame->sbsample[ch];
Gruenfrosch 0:7627c79db971 569 filter = &synth->filter[ch];
Gruenfrosch 0:7627c79db971 570 phase = synth->phase;
Gruenfrosch 0:7627c79db971 571 pcm1 = synth->pcm.samples[ch];
Gruenfrosch 0:7627c79db971 572
Gruenfrosch 0:7627c79db971 573 for (s = 0; s < ns; ++s) {
Gruenfrosch 0:7627c79db971 574 dct32((*sbsample)[s], phase >> 1,
Gruenfrosch 0:7627c79db971 575 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
Gruenfrosch 0:7627c79db971 576
Gruenfrosch 0:7627c79db971 577 pe = phase & ~1;
Gruenfrosch 0:7627c79db971 578 po = ((phase - 1) & 0xf) | 1;
Gruenfrosch 0:7627c79db971 579
Gruenfrosch 0:7627c79db971 580 /* calculate 32 samples */
Gruenfrosch 0:7627c79db971 581
Gruenfrosch 0:7627c79db971 582 fe = &(*filter)[0][ phase & 1][0];
Gruenfrosch 0:7627c79db971 583 fx = &(*filter)[0][~phase & 1][0];
Gruenfrosch 0:7627c79db971 584 fo = &(*filter)[1][~phase & 1][0];
Gruenfrosch 0:7627c79db971 585
Gruenfrosch 0:7627c79db971 586 Dptr = &D[0];
Gruenfrosch 0:7627c79db971 587
Gruenfrosch 0:7627c79db971 588 ptr = *Dptr + po;
Gruenfrosch 0:7627c79db971 589 ML0(hi, lo, (*fx)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 590 MLA(hi, lo, (*fx)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 591 MLA(hi, lo, (*fx)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 592 MLA(hi, lo, (*fx)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 593 MLA(hi, lo, (*fx)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 594 MLA(hi, lo, (*fx)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 595 MLA(hi, lo, (*fx)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 596 MLA(hi, lo, (*fx)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 597 MLN(hi, lo);
Gruenfrosch 0:7627c79db971 598
Gruenfrosch 0:7627c79db971 599 ptr = *Dptr + pe;
Gruenfrosch 0:7627c79db971 600 MLA(hi, lo, (*fe)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 601 MLA(hi, lo, (*fe)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 602 MLA(hi, lo, (*fe)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 603 MLA(hi, lo, (*fe)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 604 MLA(hi, lo, (*fe)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 605 MLA(hi, lo, (*fe)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 606 MLA(hi, lo, (*fe)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 607 MLA(hi, lo, (*fe)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 608
Gruenfrosch 0:7627c79db971 609 *pcm1++ = SHIFT(MLZ(hi, lo));
Gruenfrosch 0:7627c79db971 610
Gruenfrosch 0:7627c79db971 611 pcm2 = pcm1 + 30;
Gruenfrosch 0:7627c79db971 612
Gruenfrosch 0:7627c79db971 613 for (sb = 1; sb < 16; ++sb) {
Gruenfrosch 0:7627c79db971 614 ++fe;
Gruenfrosch 0:7627c79db971 615 ++Dptr;
Gruenfrosch 0:7627c79db971 616
Gruenfrosch 0:7627c79db971 617 /* D[32 - sb][i] == -D[sb][31 - i] */
Gruenfrosch 0:7627c79db971 618
Gruenfrosch 0:7627c79db971 619 ptr = *Dptr + po;
Gruenfrosch 0:7627c79db971 620 ML0(hi, lo, (*fo)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 621 MLA(hi, lo, (*fo)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 622 MLA(hi, lo, (*fo)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 623 MLA(hi, lo, (*fo)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 624 MLA(hi, lo, (*fo)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 625 MLA(hi, lo, (*fo)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 626 MLA(hi, lo, (*fo)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 627 MLA(hi, lo, (*fo)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 628 MLN(hi, lo);
Gruenfrosch 0:7627c79db971 629
Gruenfrosch 0:7627c79db971 630 ptr = *Dptr + pe;
Gruenfrosch 0:7627c79db971 631 MLA(hi, lo, (*fe)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 632 MLA(hi, lo, (*fe)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 633 MLA(hi, lo, (*fe)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 634 MLA(hi, lo, (*fe)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 635 MLA(hi, lo, (*fe)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 636 MLA(hi, lo, (*fe)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 637 MLA(hi, lo, (*fe)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 638 MLA(hi, lo, (*fe)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 639
Gruenfrosch 0:7627c79db971 640 *pcm1++ = SHIFT(MLZ(hi, lo));
Gruenfrosch 0:7627c79db971 641
Gruenfrosch 0:7627c79db971 642 ptr = *Dptr - pe;
Gruenfrosch 0:7627c79db971 643 ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
Gruenfrosch 0:7627c79db971 644 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
Gruenfrosch 0:7627c79db971 645 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
Gruenfrosch 0:7627c79db971 646 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
Gruenfrosch 0:7627c79db971 647 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
Gruenfrosch 0:7627c79db971 648 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
Gruenfrosch 0:7627c79db971 649 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
Gruenfrosch 0:7627c79db971 650 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
Gruenfrosch 0:7627c79db971 651
Gruenfrosch 0:7627c79db971 652 ptr = *Dptr - po;
Gruenfrosch 0:7627c79db971 653 MLA(hi, lo, (*fo)[7], ptr[31 - 2]);
Gruenfrosch 0:7627c79db971 654 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
Gruenfrosch 0:7627c79db971 655 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
Gruenfrosch 0:7627c79db971 656 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
Gruenfrosch 0:7627c79db971 657 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
Gruenfrosch 0:7627c79db971 658 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
Gruenfrosch 0:7627c79db971 659 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
Gruenfrosch 0:7627c79db971 660 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
Gruenfrosch 0:7627c79db971 661
Gruenfrosch 0:7627c79db971 662 *pcm2-- = SHIFT(MLZ(hi, lo));
Gruenfrosch 0:7627c79db971 663
Gruenfrosch 0:7627c79db971 664 ++fo;
Gruenfrosch 0:7627c79db971 665 }
Gruenfrosch 0:7627c79db971 666
Gruenfrosch 0:7627c79db971 667 ++Dptr;
Gruenfrosch 0:7627c79db971 668
Gruenfrosch 0:7627c79db971 669 ptr = *Dptr + po;
Gruenfrosch 0:7627c79db971 670 ML0(hi, lo, (*fo)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 671 MLA(hi, lo, (*fo)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 672 MLA(hi, lo, (*fo)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 673 MLA(hi, lo, (*fo)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 674 MLA(hi, lo, (*fo)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 675 MLA(hi, lo, (*fo)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 676 MLA(hi, lo, (*fo)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 677 MLA(hi, lo, (*fo)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 678
Gruenfrosch 0:7627c79db971 679 *pcm1 = SHIFT(-MLZ(hi, lo));
Gruenfrosch 0:7627c79db971 680 pcm1 += 16;
Gruenfrosch 0:7627c79db971 681
Gruenfrosch 0:7627c79db971 682 phase = (phase + 1) % 16;
Gruenfrosch 0:7627c79db971 683 }
Gruenfrosch 0:7627c79db971 684 }
Gruenfrosch 0:7627c79db971 685 }
Gruenfrosch 0:7627c79db971 686 # endif
Gruenfrosch 0:7627c79db971 687
Gruenfrosch 0:7627c79db971 688 /*
Gruenfrosch 0:7627c79db971 689 * NAME: synth->half()
Gruenfrosch 0:7627c79db971 690 * DESCRIPTION: perform half frequency PCM synthesis
Gruenfrosch 0:7627c79db971 691 */
Gruenfrosch 0:7627c79db971 692 static
Gruenfrosch 0:7627c79db971 693 void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
Gruenfrosch 0:7627c79db971 694 unsigned int nch, unsigned int ns)
Gruenfrosch 0:7627c79db971 695 {
Gruenfrosch 0:7627c79db971 696 unsigned int phase, ch, s, sb, pe, po;
Gruenfrosch 0:7627c79db971 697 mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
Gruenfrosch 0:7627c79db971 698 mad_fixed_t const (*sbsample)[36][32];
Gruenfrosch 0:7627c79db971 699 register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
Gruenfrosch 0:7627c79db971 700 register mad_fixed_t const (*Dptr)[32], *ptr;
Gruenfrosch 0:7627c79db971 701 register mad_fixed64hi_t hi;
Gruenfrosch 0:7627c79db971 702 register mad_fixed64lo_t lo;
Gruenfrosch 0:7627c79db971 703
Gruenfrosch 0:7627c79db971 704 for (ch = 0; ch < nch; ++ch) {
Gruenfrosch 0:7627c79db971 705 sbsample = &frame->sbsample[ch];
Gruenfrosch 0:7627c79db971 706 filter = &synth->filter[ch];
Gruenfrosch 0:7627c79db971 707 phase = synth->phase;
Gruenfrosch 0:7627c79db971 708 pcm1 = synth->pcm.samples[ch];
Gruenfrosch 0:7627c79db971 709
Gruenfrosch 0:7627c79db971 710 for (s = 0; s < ns; ++s) {
Gruenfrosch 0:7627c79db971 711 dct32((*sbsample)[s], phase >> 1,
Gruenfrosch 0:7627c79db971 712 (*filter)[0][phase & 1], (*filter)[1][phase & 1]);
Gruenfrosch 0:7627c79db971 713
Gruenfrosch 0:7627c79db971 714 pe = phase & ~1;
Gruenfrosch 0:7627c79db971 715 po = ((phase - 1) & 0xf) | 1;
Gruenfrosch 0:7627c79db971 716
Gruenfrosch 0:7627c79db971 717 /* calculate 16 samples */
Gruenfrosch 0:7627c79db971 718
Gruenfrosch 0:7627c79db971 719 fe = &(*filter)[0][ phase & 1][0];
Gruenfrosch 0:7627c79db971 720 fx = &(*filter)[0][~phase & 1][0];
Gruenfrosch 0:7627c79db971 721 fo = &(*filter)[1][~phase & 1][0];
Gruenfrosch 0:7627c79db971 722
Gruenfrosch 0:7627c79db971 723 Dptr = &D[0];
Gruenfrosch 0:7627c79db971 724
Gruenfrosch 0:7627c79db971 725 ptr = *Dptr + po;
Gruenfrosch 0:7627c79db971 726 ML0(hi, lo, (*fx)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 727 MLA(hi, lo, (*fx)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 728 MLA(hi, lo, (*fx)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 729 MLA(hi, lo, (*fx)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 730 MLA(hi, lo, (*fx)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 731 MLA(hi, lo, (*fx)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 732 MLA(hi, lo, (*fx)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 733 MLA(hi, lo, (*fx)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 734 MLN(hi, lo);
Gruenfrosch 0:7627c79db971 735
Gruenfrosch 0:7627c79db971 736 ptr = *Dptr + pe;
Gruenfrosch 0:7627c79db971 737 MLA(hi, lo, (*fe)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 738 MLA(hi, lo, (*fe)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 739 MLA(hi, lo, (*fe)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 740 MLA(hi, lo, (*fe)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 741 MLA(hi, lo, (*fe)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 742 MLA(hi, lo, (*fe)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 743 MLA(hi, lo, (*fe)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 744 MLA(hi, lo, (*fe)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 745
Gruenfrosch 0:7627c79db971 746 *pcm1++ = SHIFT(MLZ(hi, lo));
Gruenfrosch 0:7627c79db971 747
Gruenfrosch 0:7627c79db971 748 pcm2 = pcm1 + 14;
Gruenfrosch 0:7627c79db971 749
Gruenfrosch 0:7627c79db971 750 for (sb = 1; sb < 16; ++sb) {
Gruenfrosch 0:7627c79db971 751 ++fe;
Gruenfrosch 0:7627c79db971 752 ++Dptr;
Gruenfrosch 0:7627c79db971 753
Gruenfrosch 0:7627c79db971 754 /* D[32 - sb][i] == -D[sb][31 - i] */
Gruenfrosch 0:7627c79db971 755
Gruenfrosch 0:7627c79db971 756 if (!(sb & 1)) {
Gruenfrosch 0:7627c79db971 757 ptr = *Dptr + po;
Gruenfrosch 0:7627c79db971 758 ML0(hi, lo, (*fo)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 759 MLA(hi, lo, (*fo)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 760 MLA(hi, lo, (*fo)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 761 MLA(hi, lo, (*fo)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 762 MLA(hi, lo, (*fo)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 763 MLA(hi, lo, (*fo)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 764 MLA(hi, lo, (*fo)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 765 MLA(hi, lo, (*fo)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 766 MLN(hi, lo);
Gruenfrosch 0:7627c79db971 767
Gruenfrosch 0:7627c79db971 768 ptr = *Dptr + pe;
Gruenfrosch 0:7627c79db971 769 MLA(hi, lo, (*fe)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 770 MLA(hi, lo, (*fe)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 771 MLA(hi, lo, (*fe)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 772 MLA(hi, lo, (*fe)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 773 MLA(hi, lo, (*fe)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 774 MLA(hi, lo, (*fe)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 775 MLA(hi, lo, (*fe)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 776 MLA(hi, lo, (*fe)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 777
Gruenfrosch 0:7627c79db971 778 *pcm1++ = SHIFT(MLZ(hi, lo));
Gruenfrosch 0:7627c79db971 779
Gruenfrosch 0:7627c79db971 780 ptr = *Dptr - po;
Gruenfrosch 0:7627c79db971 781 ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
Gruenfrosch 0:7627c79db971 782 MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
Gruenfrosch 0:7627c79db971 783 MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
Gruenfrosch 0:7627c79db971 784 MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
Gruenfrosch 0:7627c79db971 785 MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
Gruenfrosch 0:7627c79db971 786 MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
Gruenfrosch 0:7627c79db971 787 MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
Gruenfrosch 0:7627c79db971 788 MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
Gruenfrosch 0:7627c79db971 789
Gruenfrosch 0:7627c79db971 790 ptr = *Dptr - pe;
Gruenfrosch 0:7627c79db971 791 MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
Gruenfrosch 0:7627c79db971 792 MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
Gruenfrosch 0:7627c79db971 793 MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
Gruenfrosch 0:7627c79db971 794 MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
Gruenfrosch 0:7627c79db971 795 MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
Gruenfrosch 0:7627c79db971 796 MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
Gruenfrosch 0:7627c79db971 797 MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
Gruenfrosch 0:7627c79db971 798 MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
Gruenfrosch 0:7627c79db971 799
Gruenfrosch 0:7627c79db971 800 *pcm2-- = SHIFT(MLZ(hi, lo));
Gruenfrosch 0:7627c79db971 801 }
Gruenfrosch 0:7627c79db971 802
Gruenfrosch 0:7627c79db971 803 ++fo;
Gruenfrosch 0:7627c79db971 804 }
Gruenfrosch 0:7627c79db971 805
Gruenfrosch 0:7627c79db971 806 ++Dptr;
Gruenfrosch 0:7627c79db971 807
Gruenfrosch 0:7627c79db971 808 ptr = *Dptr + po;
Gruenfrosch 0:7627c79db971 809 ML0(hi, lo, (*fo)[0], ptr[ 0]);
Gruenfrosch 0:7627c79db971 810 MLA(hi, lo, (*fo)[1], ptr[14]);
Gruenfrosch 0:7627c79db971 811 MLA(hi, lo, (*fo)[2], ptr[12]);
Gruenfrosch 0:7627c79db971 812 MLA(hi, lo, (*fo)[3], ptr[10]);
Gruenfrosch 0:7627c79db971 813 MLA(hi, lo, (*fo)[4], ptr[ 8]);
Gruenfrosch 0:7627c79db971 814 MLA(hi, lo, (*fo)[5], ptr[ 6]);
Gruenfrosch 0:7627c79db971 815 MLA(hi, lo, (*fo)[6], ptr[ 4]);
Gruenfrosch 0:7627c79db971 816 MLA(hi, lo, (*fo)[7], ptr[ 2]);
Gruenfrosch 0:7627c79db971 817
Gruenfrosch 0:7627c79db971 818 *pcm1 = SHIFT(-MLZ(hi, lo));
Gruenfrosch 0:7627c79db971 819 pcm1 += 8;
Gruenfrosch 0:7627c79db971 820
Gruenfrosch 0:7627c79db971 821 phase = (phase + 1) % 16;
Gruenfrosch 0:7627c79db971 822 }
Gruenfrosch 0:7627c79db971 823 }
Gruenfrosch 0:7627c79db971 824 }
Gruenfrosch 0:7627c79db971 825
Gruenfrosch 0:7627c79db971 826 /*
Gruenfrosch 0:7627c79db971 827 * NAME: synth->frame()
Gruenfrosch 0:7627c79db971 828 * DESCRIPTION: perform PCM synthesis of frame subband samples
Gruenfrosch 0:7627c79db971 829 */
Gruenfrosch 0:7627c79db971 830 void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
Gruenfrosch 0:7627c79db971 831 {
Gruenfrosch 0:7627c79db971 832 unsigned int nch, ns;
Gruenfrosch 0:7627c79db971 833 void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
Gruenfrosch 0:7627c79db971 834 unsigned int, unsigned int);
Gruenfrosch 0:7627c79db971 835
Gruenfrosch 0:7627c79db971 836 nch = MAD_NCHANNELS(&frame->header);
Gruenfrosch 0:7627c79db971 837 ns = MAD_NSBSAMPLES(&frame->header);
Gruenfrosch 0:7627c79db971 838
Gruenfrosch 0:7627c79db971 839 synth->pcm.samplerate = frame->header.samplerate;
Gruenfrosch 0:7627c79db971 840 synth->pcm.channels = nch;
Gruenfrosch 0:7627c79db971 841 synth->pcm.length = 32 * ns;
Gruenfrosch 0:7627c79db971 842
Gruenfrosch 0:7627c79db971 843 synth_frame = synth_full;
Gruenfrosch 0:7627c79db971 844
Gruenfrosch 0:7627c79db971 845 if (frame->options & MAD_OPTION_HALFSAMPLERATE) {
Gruenfrosch 0:7627c79db971 846 synth->pcm.samplerate /= 2;
Gruenfrosch 0:7627c79db971 847 synth->pcm.length /= 2;
Gruenfrosch 0:7627c79db971 848
Gruenfrosch 0:7627c79db971 849 synth_frame = synth_half;
Gruenfrosch 0:7627c79db971 850 }
Gruenfrosch 0:7627c79db971 851
Gruenfrosch 0:7627c79db971 852 synth_frame(synth, frame, nch, ns);
Gruenfrosch 0:7627c79db971 853
Gruenfrosch 0:7627c79db971 854 synth->phase = (synth->phase + ns) % 16;
Gruenfrosch 0:7627c79db971 855 }