tremor uses integer types
[mplayer/glamo.git] / liba52 / imdct_mlib.c
blobceec96e1a4145fecb162ac63c904b4756dfe9db8
1 /*
2 * imdct_mlib.c
3 * Copyright (C) 2000-2001 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
6 * This file is part of a52dec, a free ATSC A-52 stream decoder.
7 * See http://liba52.sourceforge.net/ for updates.
9 * Modified for use with MPlayer, changes contained in liba52_changes.diff.
10 * detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
11 * $Id$
13 * a52dec is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * a52dec is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "config.h"
30 #ifdef LIBA52_MLIB
32 #include <mlib_types.h>
33 #include <mlib_status.h>
34 #include <mlib_signal.h>
35 #include <string.h>
36 #include <inttypes.h>
38 #include "a52.h"
39 #include "a52_internal.h"
41 extern sample_t imdct_window[];
43 void
44 imdct_do_512_mlib(sample_t data[], sample_t delay[], sample_t bias)
46 sample_t *buf_real;
47 sample_t *buf_imag;
48 sample_t *data_ptr;
49 sample_t *delay_ptr;
50 sample_t *window_ptr;
51 sample_t tmp[256] __attribute__((aligned(16)));
52 int i;
54 memcpy(tmp, data, 256 * sizeof(sample_t));
55 mlib_SignalIMDCT_F32(tmp);
57 buf_real = tmp;
58 buf_imag = tmp + 128;
59 data_ptr = data;
60 delay_ptr = delay;
61 window_ptr = imdct_window;
63 /* Window and convert to real valued signal */
64 for(i=0; i< 64; i++)
66 *data_ptr++ = -buf_imag[64+i] * *window_ptr++ + *delay_ptr++ + bias;
67 *data_ptr++ = buf_real[64-i-1] * *window_ptr++ + *delay_ptr++ + bias;
70 for(i=0; i< 64; i++)
72 *data_ptr++ = -buf_real[i] * *window_ptr++ + *delay_ptr++ + bias;
73 *data_ptr++ = buf_imag[128-i-1] * *window_ptr++ + *delay_ptr++ + bias;
76 /* The trailing edge of the window goes into the delay line */
77 delay_ptr = delay;
79 for(i=0; i< 64; i++)
81 *delay_ptr++ = -buf_real[64+i] * *--window_ptr;
82 *delay_ptr++ = buf_imag[64-i-1] * *--window_ptr;
85 for(i=0; i<64; i++)
87 *delay_ptr++ = buf_imag[i] * *--window_ptr;
88 *delay_ptr++ = -buf_real[128-i-1] * *--window_ptr;
92 void
93 imdct_do_256_mlib(sample_t data[], sample_t delay[], sample_t bias)
95 sample_t *buf1_real, *buf1_imag;
96 sample_t *buf2_real, *buf2_imag;
97 sample_t *data_ptr;
98 sample_t *delay_ptr;
99 sample_t *window_ptr;
100 sample_t tmp[256] __attribute__((aligned(16)));
101 int i;
103 memcpy(tmp, data, 256 * sizeof(sample_t));
104 mlib_SignalIMDCTSplit_F32(tmp);
106 buf1_real = tmp;
107 buf1_imag = tmp + 128 + 64;
108 buf2_real = tmp + 64;
109 buf2_imag = tmp + 128;
110 data_ptr = data;
111 delay_ptr = delay;
112 window_ptr = imdct_window;
114 /* Window and convert to real valued signal */
115 for(i=0; i< 64; i++)
117 *data_ptr++ = -buf1_imag[i] * *window_ptr++ + *delay_ptr++ + bias;
118 *data_ptr++ = buf1_real[64-i-1] * *window_ptr++ + *delay_ptr++ + bias;
121 for(i=0; i< 64; i++)
123 *data_ptr++ = -buf1_real[i] * *window_ptr++ + *delay_ptr++ + bias;
124 *data_ptr++ = buf1_imag[64-i-1] * *window_ptr++ + *delay_ptr++ + bias;
127 delay_ptr = delay;
129 for(i=0; i< 64; i++)
131 *delay_ptr++ = -buf2_real[i] * *--window_ptr;
132 *delay_ptr++ = buf2_imag[64-i-1] * *--window_ptr;
135 for(i=0; i< 64; i++)
137 *delay_ptr++ = buf2_imag[i] * *--window_ptr;
138 *delay_ptr++ = -buf2_real[64-i-1] * *--window_ptr;
142 #endif