Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / gst / goom2k1 / lines.c
1 /*
2  *  lines.c
3  *  iTunesXPlugIn
4  *
5  *  Created by guillaum on Tue Aug 14 2001.
6  *  Copyright (c) 2001 __CompanyName__. All rights reserved.
7  *
8  */
9
10 #ifdef HAVE_CONFIG_H
11 #include "config.h"
12 #endif
13
14 #include "lines.h"
15 #include <math.h>
16
17 static inline unsigned char
18 lighten (unsigned char value, unsigned char power)
19 {
20   unsigned char i;
21
22   for (i = 0; i < power; i++)
23     value += (255 - value) / 5;
24   return value;
25 }
26
27 void
28 goom_lines (GoomData * goomdata, gint16 data[2][512], unsigned int ID,
29     unsigned int *p, guint32 power)
30 {
31   guint32 color1;
32   guint32 color2;
33   guint32 resolx = goomdata->resolx;
34   guint32 resoly = goomdata->resoly;
35   unsigned char *color = 1 + (unsigned char *) &color1;
36
37   switch (ID) {
38     case 0:                    /* Horizontal stereo lines */
39     {
40       color1 = 0x0000AA00;
41       color2 = 0x00AA0000;
42       break;
43     }
44
45     case 1:                    /* Stereo circles */
46     {
47       color1 = 0x00AA33DD;
48       color2 = 0x00AA33DD;
49       break;
50     }
51   }
52   *color = lighten (*color, power);
53   color++;
54   *color = lighten (*color, power);
55   color++;
56   *color = lighten (*color, power);
57   color = 1 + (unsigned char *) &color2;
58   *color = lighten (*color, power);
59   color++;
60   *color = lighten (*color, power);
61   color++;
62   *color = lighten (*color, power);
63
64   switch (ID) {
65     case 0:                    /* Horizontal stereo lines */
66     {
67       unsigned int i;
68
69       for (i = 0; i < 512; i++) {
70         guint32 plot;
71
72         plot = i * resolx / 512 + (resoly / 4 + data[0][i] / 1600) * resolx;
73         p[plot] = color1;
74         p[plot + 1] = color1;
75         plot = i * resolx / 512 + (resoly * 3 / 4 - data[1][i] / 1600) * resolx;
76         p[plot] = color2;
77         p[plot + 1] = color2;
78       }
79       break;
80     }
81
82     case 1:                    /* Stereo circles */
83     {
84       float z;
85       unsigned int monX = resolx / 2;
86       float monY = resoly / 4;
87       float monY2 = resoly / 2;
88
89       for (z = 0; z < 6.2832f; z += 1.0f / monY) {
90         /* float offset1 = 128+data[1][(unsigned int)(z*81.33f)])/200000; */
91         p[monX + (unsigned int) ((monY + ((float) resoly) * (128 +
92                         data[1][(unsigned int) (z * 81.33f)]) / 200000) *
93                 cos (z) + resolx * (unsigned int) (monY2 + (monY +
94                         ((float) resoly) * (128 +
95                             data[1][(unsigned int) (z * 81.33f)]) / 400000) *
96                     sin (z)))] = color1;
97         p[monX + (unsigned int) ((monY - ((float) resoly) * (128 +
98                         data[0][(unsigned int) (z * 81.33f)]) / 200000) *
99                 cos (z) + resolx * (unsigned int) (monY2 + (monY -
100                         ((float) resoly) * (128 +
101                             data[0][(unsigned int) (z * 81.33f)]) / 400000) *
102                     sin (z)))] = color2;
103       }
104       break;
105     }
106   }
107 }