~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to extern/fftw/rdft/rank0-rdft2.c

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2003, 2006 Matteo Frigo
 
3
 * Copyright (c) 2003, 2006 Massachusetts Institute of Technology
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
 
20
 
 
21
/* $Id: rank0-rdft2.c,v 1.13 2006-01-27 02:10:50 athena Exp $ */
 
22
 
 
23
/* plans for rank-0 RDFT2 (copy operations, plus setting 0 imag. parts) */
 
24
 
 
25
#include "rdft.h"
 
26
 
 
27
#ifdef HAVE_STRING_H
 
28
#include <string.h>             /* for memcpy() */
 
29
#endif
 
30
 
 
31
typedef struct {
 
32
     solver super;
 
33
} S;
 
34
 
 
35
typedef struct {
 
36
     plan_rdft super;
 
37
     INT vl;
 
38
     INT ivs, ovs;
 
39
     plan *cldcpy;
 
40
} P;
 
41
 
 
42
static int applicable(const problem *p_)
 
43
{
 
44
     const problem_rdft2 *p = (const problem_rdft2 *) p_;
 
45
     return (1
 
46
             && p->sz->rnk == 0
 
47
             && (p->kind == HC2R
 
48
                 || (((p->r != p->rio && p->r != p->iio)
 
49
                      || X(rdft2_inplace_strides)(p, RNK_MINFTY))
 
50
                     && p->vecsz->rnk <= 1))
 
51
          );
 
52
}
 
53
 
 
54
static void apply_r2hc(const plan *ego_, R *r, R *rio, R *iio)
 
55
{
 
56
     const P *ego = (const P *) ego_;
 
57
     INT i, vl = ego->vl;
 
58
     INT ivs = ego->ivs, ovs = ego->ovs;
 
59
 
 
60
     for (i = 4; i <= vl; i += 4) {
 
61
          R r0, r1, r2, r3;
 
62
          r0 = *r; r += ivs;
 
63
          r1 = *r; r += ivs;
 
64
          r2 = *r; r += ivs;
 
65
          r3 = *r; r += ivs;
 
66
          *rio = r0; rio += ovs;
 
67
          *iio = K(0.0); iio += ovs;
 
68
          *rio = r1; rio += ovs;
 
69
          *iio = K(0.0); iio += ovs;
 
70
          *rio = r2; rio += ovs;
 
71
          *iio = K(0.0); iio += ovs;
 
72
          *rio = r3; rio += ovs;
 
73
          *iio = K(0.0); iio += ovs;
 
74
     }
 
75
     for (; i < vl + 4; ++i) {
 
76
          R r0;
 
77
          r0 = *r; r += ivs;
 
78
          *rio = r0; rio += ovs;
 
79
          *iio = K(0.0); iio += ovs;
 
80
     }
 
81
}
 
82
 
 
83
/* in-place r2hc rank-0: set imaginary parts of output to 0 */
 
84
static void apply_r2hc_inplace(const plan *ego_, R *r, R *rio, R *iio)
 
85
{
 
86
     const P *ego = (const P *) ego_;
 
87
     INT i, vl = ego->vl;
 
88
     INT ovs = ego->ovs;
 
89
 
 
90
     UNUSED(r);
 
91
     UNUSED(rio);
 
92
     for (i = 4; i <= vl; i += 4) {
 
93
          *iio = K(0.0); iio += ovs;
 
94
          *iio = K(0.0); iio += ovs;
 
95
          *iio = K(0.0); iio += ovs;
 
96
          *iio = K(0.0); iio += ovs;
 
97
     }
 
98
     for (; i < vl + 4; ++i) {
 
99
          *iio = K(0.0); iio += ovs;
 
100
     }
 
101
}
 
102
 
 
103
/* a rank-0 HC2R rdft2 problem is just a copy from rio to r,
 
104
   so we can use a rank-0 rdft plan */
 
105
static void apply_hc2r(const plan *ego_, R *r, R *rio, R *iio)
 
106
{
 
107
     const P *ego = (const P *) ego_;
 
108
     plan_rdft *cldcpy = (plan_rdft *) ego->cldcpy;
 
109
     UNUSED(iio);
 
110
     cldcpy->apply((plan *) cldcpy, rio, r);
 
111
}
 
112
 
 
113
static void awake(plan *ego_, enum wakefulness wakefulness)
 
114
{
 
115
     P *ego = (P *) ego_;
 
116
     if (ego->cldcpy)
 
117
          X(plan_awake)(ego->cldcpy, wakefulness);
 
118
}
 
119
 
 
120
static void destroy(plan *ego_)
 
121
{
 
122
     P *ego = (P *) ego_;
 
123
     if (ego->cldcpy)
 
124
          X(plan_destroy_internal)(ego->cldcpy);
 
125
}
 
126
 
 
127
static void print(const plan *ego_, printer *p)
 
128
{
 
129
     const P *ego = (const P *) ego_;
 
130
     if (ego->cldcpy)
 
131
          p->print(p, "(rdft2-hc2r-rank0%(%p%))", ego->cldcpy);
 
132
     else
 
133
          p->print(p, "(rdft2-r2hc-rank0%v)", ego->vl);
 
134
}
 
135
 
 
136
static plan *mkplan(const solver *ego_, const problem *p_, planner *plnr)
 
137
{
 
138
     const problem_rdft2 *p;
 
139
     plan *cldcpy = (plan *) 0;
 
140
     P *pln;
 
141
 
 
142
     static const plan_adt padt = {
 
143
          X(rdft2_solve), awake, print, destroy
 
144
     };
 
145
 
 
146
     UNUSED(ego_);
 
147
 
 
148
     if (!applicable(p_))
 
149
          return (plan *) 0;
 
150
 
 
151
     p = (const problem_rdft2 *) p_;
 
152
 
 
153
     if (p->kind == HC2R) {
 
154
          cldcpy = X(mkplan_d)(plnr,
 
155
                               X(mkproblem_rdft_0_d)(
 
156
                                    X(tensor_copy)(p->vecsz),
 
157
                                    p->rio, p->r));
 
158
          if (!cldcpy) return (plan *) 0;
 
159
     }
 
160
 
 
161
     pln = MKPLAN_RDFT2(P, &padt, 
 
162
                        p->kind == R2HC ? 
 
163
                        (p->r == p->rio ? apply_r2hc_inplace : apply_r2hc) 
 
164
                        : apply_hc2r);
 
165
     
 
166
     if (p->kind == R2HC)
 
167
          X(tensor_tornk1)(p->vecsz, &pln->vl, &pln->ivs, &pln->ovs);
 
168
     pln->cldcpy = cldcpy;
 
169
 
 
170
     if (p->kind == R2HC) {
 
171
          /* vl loads, 2*vl stores */
 
172
          X(ops_other)(3 * pln->vl, &pln->super.super.ops);
 
173
     }
 
174
     else {
 
175
          pln->super.super.ops = cldcpy->ops;
 
176
     }
 
177
 
 
178
     return &(pln->super.super);
 
179
}
 
180
 
 
181
static solver *mksolver(void)
 
182
{
 
183
     static const solver_adt sadt = { PROBLEM_RDFT2, mkplan };
 
184
     S *slv = MKSOLVER(S, &sadt);
 
185
     return &(slv->super);
 
186
}
 
187
 
 
188
void X(rdft2_rank0_register)(planner *p)
 
189
{
 
190
     REGISTER_SOLVER(p, mksolver());
 
191
}