131fd002ed863ec3f59d2379cd256b8bb3dda8ef
[platform/upstream/gst-plugins-good.git] / gst / goom / 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 extern unsigned int resolx,resoly;
18
19 inline unsigned char  lighten(unsigned char value,unsigned char power)
20 {
21     unsigned char i;
22     for (i=0;i < power; i++) value += (255-value)/5;
23     return value;
24 }
25
26 void goom_lines(gint16 data [2][512], unsigned int ID,unsigned int* p, guint32 power)
27 {
28     guint32 color1;
29     guint32 color2;
30     unsigned char * color = 1 + (unsigned char *) &color1;
31
32     switch (ID)
33     {
34         case 0: /* Horizontal stereo lines */
35         {
36             color1 = 0x0000AA00;
37             color2 = 0x00AA0000;
38             break;
39         }
40
41         case 1: /* Stereo circles */
42         {
43             color1 = 0x00AA33DD;
44             color2 = 0x00AA33DD;
45             break;
46         }
47     }
48     *color = lighten(*color,power);
49     color++;  
50     * color = lighten(*color,power);
51     color++;  
52     * color = lighten(*color,power);
53     color = 1 + (unsigned char *) &color2;
54     * color = lighten(*color,power);
55     color++;  
56     * color = lighten(*color,power);
57     color++;  
58     * color = lighten(*color,power);
59     
60     switch (ID)
61     {
62         case 0: /* Horizontal stereo lines */
63         {
64             unsigned int i;
65             for (i=0;i<512;i++)
66             {
67                 guint32 plot ;
68                 plot = i * resolx / 512 + (resoly / 4 + data[0][i] / 1600) * resolx;
69                 p[plot] = color1;
70                 p[plot+1] = color1;
71                 plot = i * resolx / 512 + (resoly * 3 / 4 - data[1][i] / 1600) * resolx;
72                 p[plot] = color2;
73                 p[plot+1] = color2;
74             }
75             break;
76         }
77
78         case 1: /* Stereo circles */
79         {
80             float z;
81             unsigned int monX = resolx/2;
82             float monY = resoly/4;
83             float monY2 = resoly/2;
84             for (z=0;z<6.2832f; z+=1.0f/monY)
85             {
86                /* float offset1 = 128+data[1][(unsigned int)(z*81.33f)])/200000; */
87                 p[ monX + (unsigned int)( (monY + ((float)resoly) * (128+data[1][(unsigned int)(z*81.33f)])/200000) * cos (z) + resolx * (unsigned int)( monY2 + (monY + ((float)resoly)*(128+data[1][(unsigned int)(z*81.33f)])/400000) * sin (z)))] = color1;
88                 p[ monX + (unsigned int)((monY - ((float)resoly) * (128+data[0][(unsigned int)(z*81.33f)])/200000) * cos (z) + resolx * (unsigned int)( monY2 + (monY - ((float)resoly)*(128+data[0][(unsigned int)(z*81.33f)])/400000) * sin (z)))] = color2;
89             }
90         break;
91         }
92     }
93 }
94