~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to extern/fftw/kernel/pickdim.c

  • Committer: Bazaar Package Importer
  • Author(s): Kevin Roy
  • Date: 2011-02-08 22:20:54 UTC
  • mfrom: (1.4.2 upstream)
  • mto: (14.2.6 sid) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: james.westby@ubuntu.com-20110208222054-kk0gwa4bu8h5lyq4
Tags: upstream-2.56.1-beta-svn34076
ImportĀ upstreamĀ versionĀ 2.56.1-beta-svn34076

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
 
#include "ifftw.h"
22
 
 
23
 
/* $Id: pickdim.c,v 1.6 2006-01-05 03:04:27 stevenj Exp $ */
24
 
 
25
 
/* Given a solver which_dim, a vector sz, and whether or not the
26
 
   transform is out-of-place, return the actual dimension index that
27
 
   it corresponds to.  The basic idea here is that we return the
28
 
   which_dim'th valid dimension, starting from the end if
29
 
   which_dim < 0. */
30
 
static int really_pickdim(int which_dim, const tensor *sz, int oop, int *dp)
31
 
{
32
 
     int i;
33
 
     int count_ok = 0;
34
 
     if (which_dim > 0) {
35
 
          for (i = 0; i < sz->rnk; ++i) {
36
 
               if (oop || sz->dims[i].is == sz->dims[i].os)
37
 
                    if (++count_ok == which_dim) {
38
 
                         *dp = i;
39
 
                         return 1;
40
 
                    }
41
 
          }
42
 
     }
43
 
     else if (which_dim < 0) {
44
 
          for (i = sz->rnk - 1; i >= 0; --i) {
45
 
               if (oop || sz->dims[i].is == sz->dims[i].os)
46
 
                    if (++count_ok == -which_dim) {
47
 
                         *dp = i;
48
 
                         return 1;
49
 
                    }
50
 
          }
51
 
     }
52
 
     else { /* zero: pick the middle, if valid */
53
 
          i = (sz->rnk - 1) / 2;
54
 
          if (i >= 0 && (oop || sz->dims[i].is == sz->dims[i].os)) {
55
 
               *dp = i;
56
 
               return 1;
57
 
          }
58
 
     }
59
 
     return 0;
60
 
}
61
 
 
62
 
/* Like really_pickdim, but only returns 1 if no previous "buddy"
63
 
   which_dim in the buddies list would give the same dim. */
64
 
int X(pickdim)(int which_dim, const int *buddies, int nbuddies,
65
 
               const tensor *sz, int oop, int *dp)
66
 
{
67
 
     int i, d1;
68
 
 
69
 
     if (!really_pickdim(which_dim, sz, oop, dp))
70
 
          return 0;
71
 
 
72
 
     /* check whether some buddy solver would produce the same dim.
73
 
        If so, consider this solver unapplicable and let the buddy
74
 
        take care of it.  The smallest-indexed buddy is applicable. */
75
 
     for (i = 0; i < nbuddies; ++i) {
76
 
          if (buddies[i] == which_dim)
77
 
               break;  /* found self */
78
 
          if (really_pickdim(buddies[i], sz, oop, &d1) && *dp == d1)
79
 
               return 0; /* found equivalent buddy */
80
 
     }
81
 
     return 1;
82
 
}