OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [compile/] [pr38554.c] - Blame information for rev 297

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
typedef unsigned long sample;
2
struct pam
3
{
4
  sample maxval;
5
};
6
typedef sample *tuple;
7
enum function
8
  {
9
    FN_MULTIPLY, FN_DIVIDE, FN_ADD, FN_SUBTRACT, FN_MIN, FN_MAX, FN_AND, FN_OR,
10
    FN_XOR, FN_NOT, FN_SHIFTLEFT, FN_SHIFTRIGHT
11
  };
12
struct cmdlineInfo
13
{
14
  enum function function;
15
  union
16
  {
17
    float divisor;
18
    unsigned int shiftCount;
19
  }
20
    u;
21
};
22
applyFunction (struct cmdlineInfo const cmdline, struct pam const inpam,
23
               struct pam const outpam, tuple * const inputRow,
24
               tuple * const outputRow)
25
{
26
  float const oneOverDivisor = 1 / cmdline.u.divisor;
27
  int col;
28
  {
29
    int plane;
30
    {
31
      sample const inSample = inputRow[col][plane];
32
      sample outSample;
33
      switch (cmdline.function)
34
        {
35
        case FN_DIVIDE:
36
          outSample = ((unsigned int) ((inSample * oneOverDivisor) + 0.5));
37
          break;
38
        case FN_SHIFTLEFT:
39
          outSample = (inSample << cmdline.u.shiftCount) & outpam.maxval;
40
        }
41
      outputRow[col][plane] =
42
        ((outpam.maxval) < (outSample) ? (outpam.maxval) : (outSample));
43
    }
44
  }
45
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.