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

« back to all changes in this revision

Viewing changes to extern/fftw/rdft/direct2.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: direct2.c,v 1.24 2006-01-05 03:04:27 stevenj Exp $ */
 
22
 
 
23
/* direct RDFT2 R2HC/HC2R solver, if we have a codelet */
 
24
 
 
25
#include "rdft.h"
 
26
 
 
27
typedef union {
 
28
     kr2hc r2hc;
 
29
     khc2r hc2r;
 
30
} kodelet;
 
31
 
 
32
typedef struct {
 
33
     solver super;
 
34
     union {
 
35
          const kr2hc_desc *r2hc;
 
36
          const khc2r_desc *hc2r;
 
37
     } desc;
 
38
     kodelet k;
 
39
     INT sz;
 
40
     rdft_kind kind;
 
41
     const char *nam;
 
42
} S;
 
43
 
 
44
typedef struct {
 
45
     plan_rdft2 super;
 
46
 
 
47
     stride is, os;
 
48
     INT vl;
 
49
     INT ivs, ovs;
 
50
     kodelet k;
 
51
     const S *slv;
 
52
     INT ilast;
 
53
} P;
 
54
 
 
55
static void apply_r2hc(const plan *ego_, R *r, R *rio, R *iio)
 
56
{
 
57
     const P *ego = (const P *) ego_;
 
58
     INT i, vl = ego->vl, ovs = ego->ovs;
 
59
     ASSERT_ALIGNED_DOUBLE;
 
60
     ego->k.r2hc(r, rio, iio, ego->is, ego->os, ego->os,
 
61
                 vl, ego->ivs, ovs);
 
62
     for (i = 0; i < vl; ++i, iio += ovs)
 
63
          iio[0] = iio[ego->ilast] = 0;
 
64
}
 
65
 
 
66
static void apply_hc2r(const plan *ego_, R *r, R *rio, R *iio)
 
67
{
 
68
     const P *ego = (const P *) ego_;
 
69
     ASSERT_ALIGNED_DOUBLE;
 
70
     ego->k.hc2r(rio, iio, r, ego->os, ego->os, ego->is,
 
71
                 ego->vl, ego->ivs, ego->ovs);
 
72
}
 
73
 
 
74
static void destroy(plan *ego_)
 
75
{
 
76
     P *ego = (P *) ego_;
 
77
     X(stride_destroy)(ego->is);
 
78
     X(stride_destroy)(ego->os);
 
79
}
 
80
 
 
81
static void print(const plan *ego_, printer *p)
 
82
{
 
83
     const P *ego = (const P *) ego_;
 
84
     const S *s = ego->slv;
 
85
 
 
86
     p->print(p, "(rdft2-%s-direct-%D%v \"%s\")", 
 
87
              X(rdft_kind_str)(s->kind), s->sz, ego->vl, s->nam);
 
88
}
 
89
 
 
90
static int applicable(const solver *ego_, const problem *p_)
 
91
{
 
92
     const S *ego = (const S *) ego_;
 
93
     const problem_rdft2 *p = (const problem_rdft2 *) p_;
 
94
     INT vl;
 
95
     INT ivs, ovs;
 
96
 
 
97
     return (
 
98
          1
 
99
          && p->sz->rnk == 1
 
100
          && p->vecsz->rnk <= 1
 
101
          && p->sz->dims[0].n == ego->sz
 
102
          && p->kind == ego->kind
 
103
 
 
104
          /* check strides etc */
 
105
          && X(tensor_tornk1)(p->vecsz, &vl, &ivs, &ovs)
 
106
 
 
107
          && (ego->kind != R2HC ||
 
108
              ego->desc.r2hc->genus->okp(ego->desc.r2hc, 
 
109
                                         p->r, p->rio, p->rio,
 
110
                                         p->sz->dims[0].is,
 
111
                                         p->sz->dims[0].os,
 
112
                                         p->sz->dims[0].os,
 
113
                                         vl, ivs, ovs))
 
114
          && (ego->kind != HC2R ||
 
115
              ego->desc.hc2r->genus->okp(ego->desc.hc2r,
 
116
                                         p->rio, p->rio, p->r,
 
117
                                         p->sz->dims[0].is,
 
118
                                         p->sz->dims[0].is,
 
119
                                         p->sz->dims[0].os,
 
120
                                         vl, ivs, ovs))
 
121
               
 
122
          && (0
 
123
              /* can operate out-of-place */
 
124
              || p->r != p->rio
 
125
 
 
126
              /*
 
127
               * can compute one transform in-place, no matter
 
128
               * what the strides are.
 
129
               */
 
130
              || p->vecsz->rnk == 0
 
131
 
 
132
              /* can operate in-place as long as strides are the same */
 
133
              || X(rdft2_inplace_strides)(p, RNK_MINFTY)
 
134
               )
 
135
          );
 
136
}
 
137
 
 
138
static plan *mkplan(const solver *ego_, const problem *p_, planner *plnr)
 
139
{
 
140
     const S *ego = (const S *) ego_;
 
141
     P *pln;
 
142
     const problem_rdft2 *p;
 
143
     iodim d;
 
144
     int r2hc_kindp;
 
145
 
 
146
     static const plan_adt padt = {
 
147
          X(rdft2_solve), X(null_awake), print, destroy
 
148
     };
 
149
 
 
150
     UNUSED(plnr);
 
151
 
 
152
     if (!applicable(ego_, p_))
 
153
          return (plan *)0;
 
154
 
 
155
     p = (const problem_rdft2 *) p_;
 
156
 
 
157
     r2hc_kindp = p->kind == R2HC;
 
158
     A(r2hc_kindp || p->kind == HC2R);
 
159
 
 
160
     pln = MKPLAN_RDFT2(P, &padt, r2hc_kindp ? apply_r2hc : apply_hc2r);
 
161
 
 
162
     d = p->sz->dims[0];
 
163
 
 
164
     pln->k = ego->k;
 
165
 
 
166
     pln->is = X(mkstride)(ego->sz, r2hc_kindp ? d.is : d.os);
 
167
     pln->os = X(mkstride)(d.n/2 + 1, r2hc_kindp ? d.os : d.is);
 
168
 
 
169
     X(tensor_tornk1)(p->vecsz, &pln->vl, &pln->ivs, &pln->ovs);
 
170
 
 
171
     pln->ilast = (d.n % 2) ? 0 : (d.n/2) * d.os; /* Nyquist freq., if any */
 
172
 
 
173
     pln->slv = ego;
 
174
     X(ops_zero)(&pln->super.super.ops);
 
175
     if (r2hc_kindp)
 
176
          X(ops_madd2)(pln->vl / ego->desc.r2hc->genus->vl,
 
177
                       &ego->desc.r2hc->ops,
 
178
                       &pln->super.super.ops);
 
179
     else {
 
180
          X(ops_madd2)(pln->vl / ego->desc.hc2r->genus->vl,
 
181
                       &ego->desc.hc2r->ops,
 
182
                       &pln->super.super.ops);
 
183
          pln->super.super.ops.other += 2 * pln->vl; /* + 2 stores */
 
184
     }
 
185
 
 
186
     pln->super.super.could_prune_now_p = 1;
 
187
     return &(pln->super.super);
 
188
}
 
189
 
 
190
/* constructor */
 
191
solver *X(mksolver_rdft2_r2hc_direct)(kr2hc k, const kr2hc_desc *desc)
 
192
{
 
193
     static const solver_adt sadt = { PROBLEM_RDFT2, mkplan };
 
194
     S *slv = MKSOLVER(S, &sadt);
 
195
     slv->k.r2hc = k;
 
196
     slv->desc.r2hc = desc;
 
197
     slv->sz = desc->sz;
 
198
     slv->nam = desc->nam;
 
199
     slv->kind = desc->genus->kind;
 
200
     return &(slv->super);
 
201
}
 
202
 
 
203
solver *X(mksolver_rdft2_hc2r_direct)(khc2r k, const khc2r_desc *desc)
 
204
{
 
205
     static const solver_adt sadt = { PROBLEM_RDFT2, mkplan };
 
206
     S *slv = MKSOLVER(S, &sadt);
 
207
     slv->k.hc2r = k;
 
208
     slv->desc.hc2r = desc;
 
209
     slv->sz = desc->sz;
 
210
     slv->nam = desc->nam;
 
211
     slv->kind = desc->genus->kind;
 
212
     return &(slv->super);
 
213
}