PIPS
alphablending.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+ Include dependency graph for alphablending.c:

Go to the source code of this file.

Macros

#define xmalloc(p)
 

Functions

void alphablending (unsigned int n, float src1[n], float src2[n], float result[n], float alpha)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ xmalloc

#define xmalloc (   p)
Value:
do { \
if (posix_memalign((void **) &p, 32, n * sizeof(float))) \
return 3; \
} while(0);

Function Documentation

◆ alphablending()

void alphablending ( unsigned int  n,
float  src1[n],
float  src2[n],
float  result[n],
float  alpha 
)

Definition at line 46 of file alphablending.c.

47 {
48  unsigned int i,j;
49  for(i=0;i<n;i++)
50  result[i]=alpha*src1[i]+(1-alpha)*src2[i];
51 }

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 8 of file alphablending.c.

9 {
10  unsigned int n;
11  int r;
12  float *src1, *src2, *result;
13  float alpha;
14  n = atoi(argv[1]);
15  printf(">>>> %d <<<<\n", n);
16  alpha = 0.7;
17 
18 #define xmalloc(p) \
19  do { \
20  if (posix_memalign((void **) &p, 32, n * sizeof(float))) \
21  return 3; \
22  } while(0);
23 
24  xmalloc(src1);
25  xmalloc(src2);
26  xmalloc(result);
27 
28  init_data_file(argv[2]);
29  init_data_float(src1, n);
30  init_data_float(src2, n);
32 
33  alphablending(n, src1, src2, result, alpha);
34 
35  print_array_float("result", result, n);
36 
37  free(src1);
38  free(src2);
39 
40  r = (int) (result[0] + result[n - 1]);
41  free(result);
42 
43  return 0;
44 }
#define xmalloc(p)
void alphablending(unsigned int n, float src1[n], float src2[n], float result[n], float alpha)
Definition: alphablending.c:46
void const char const char const int
void free(void *)
int printf()
void close_data_file()
Definition: tools.c:48
void print_array_float(const char *name, const float *arr, const unsigned int n)
Definition: tools.c:54
int init_data_float(float *ptr, const unsigned int n)
Definition: tools.c:125
void init_data_file(const char *data_file)
Definition: tools.c:36

References alphablending(), close_data_file(), free(), init_data_file(), init_data_float(), int, print_array_float(), printf(), and xmalloc.

+ Here is the call graph for this function: