comparison liba52/imdct_mlib.c @ 3394:35b18ed357c2

imported from liba52 CVS
author arpi
date Sun, 09 Dec 2001 15:28:44 +0000
parents
children a4721884eaf5
comparison
equal deleted inserted replaced
3393:3624cd351618 3394:35b18ed357c2
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>
5 *
6 * This file is part of a52dec, a free ATSC A-52 stream decoder.
7 * See http://liba52.sourceforge.net/ for updates.
8 *
9 * a52dec is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * a52dec is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #include "config.h"
25
26 #ifdef LIBA52_MLIB
27
28 #include <mlib_types.h>
29 #include <mlib_status.h>
30 #include <mlib_signal.h>
31 #include <string.h>
32 #include <inttypes.h>
33
34 #include "a52.h"
35 #include "a52_internal.h"
36 #include "attributes.h"
37
38 extern sample_t imdct_window[];
39
40 void
41 imdct_do_512_mlib(sample_t data[], sample_t delay[], sample_t bias)
42 {
43 sample_t *buf_real;
44 sample_t *buf_imag;
45 sample_t *data_ptr;
46 sample_t *delay_ptr;
47 sample_t *window_ptr;
48 sample_t tmp[256] ATTR_ALIGN (16);
49 int i;
50
51 memcpy(tmp, data, 256 * sizeof(sample_t));
52 mlib_SignalIMDCT_F32(tmp);
53
54 buf_real = tmp;
55 buf_imag = tmp + 128;
56 data_ptr = data;
57 delay_ptr = delay;
58 window_ptr = imdct_window;
59
60 /* Window and convert to real valued signal */
61 for(i=0; i< 64; i++)
62 {
63 *data_ptr++ = -buf_imag[64+i] * *window_ptr++ + *delay_ptr++ + bias;
64 *data_ptr++ = buf_real[64-i-1] * *window_ptr++ + *delay_ptr++ + bias;
65 }
66
67 for(i=0; i< 64; i++)
68 {
69 *data_ptr++ = -buf_real[i] * *window_ptr++ + *delay_ptr++ + bias;
70 *data_ptr++ = buf_imag[128-i-1] * *window_ptr++ + *delay_ptr++ + bias;
71 }
72
73 /* The trailing edge of the window goes into the delay line */
74 delay_ptr = delay;
75
76 for(i=0; i< 64; i++)
77 {
78 *delay_ptr++ = -buf_real[64+i] * *--window_ptr;
79 *delay_ptr++ = buf_imag[64-i-1] * *--window_ptr;
80 }
81
82 for(i=0; i<64; i++)
83 {
84 *delay_ptr++ = buf_imag[i] * *--window_ptr;
85 *delay_ptr++ = -buf_real[128-i-1] * *--window_ptr;
86 }
87 }
88
89 void
90 imdct_do_256_mlib(sample_t data[], sample_t delay[], sample_t bias)
91 {
92 sample_t *buf1_real, *buf1_imag;
93 sample_t *buf2_real, *buf2_imag;
94 sample_t *data_ptr;
95 sample_t *delay_ptr;
96 sample_t *window_ptr;
97 sample_t tmp[256] ATTR_ALIGN (16);
98 int i;
99
100 memcpy(tmp, data, 256 * sizeof(sample_t));
101 mlib_SignalIMDCTSplit_F32(tmp);
102
103 buf1_real = tmp;
104 buf1_imag = tmp + 128 + 64;
105 buf2_real = tmp + 64;
106 buf2_imag = tmp + 128;
107 data_ptr = data;
108 delay_ptr = delay;
109 window_ptr = imdct_window;
110
111 /* Window and convert to real valued signal */
112 for(i=0; i< 64; i++)
113 {
114 *data_ptr++ = -buf1_imag[i] * *window_ptr++ + *delay_ptr++ + bias;
115 *data_ptr++ = buf1_real[64-i-1] * *window_ptr++ + *delay_ptr++ + bias;
116 }
117
118 for(i=0; i< 64; i++)
119 {
120 *data_ptr++ = -buf1_real[i] * *window_ptr++ + *delay_ptr++ + bias;
121 *data_ptr++ = buf1_imag[64-i-1] * *window_ptr++ + *delay_ptr++ + bias;
122 }
123
124 delay_ptr = delay;
125
126 for(i=0; i< 64; i++)
127 {
128 *delay_ptr++ = -buf2_real[i] * *--window_ptr;
129 *delay_ptr++ = buf2_imag[64-i-1] * *--window_ptr;
130 }
131
132 for(i=0; i< 64; i++)
133 {
134 *delay_ptr++ = buf2_imag[i] * *--window_ptr;
135 *delay_ptr++ = -buf2_real[64-i-1] * *--window_ptr;
136 }
137 }
138
139 #endif