Debian Codegraph @

src/filter/nervous/nervous.cpp

raw symbols SCIP
1 /*
2 * nervousTV - The name says it all...
3 * Copyright (C) 2002 TANNENBAUM Edo
4 *
5 * 2002/2/9
6 * Original code copied same frame twice, and did not use memcpy().
7 * I modified those point.
8 * -Kentarou Fukuchi
9 *
10 * 2009/8/26
11 * Ported to frei0r from the old FreeJ filter API
12 * -Jaromil
13 *
14 * This source code is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This source code is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Please refer
22 * to the GNU Public License for more details.
23 *
24 * You should have received a copy of the GNU Public License along
25 * with this source code; if not, write to: Free Software Foundation,
26 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 *
28 */
29
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <assert.h>
34 #include <math.h>
35 #include <string.h>
36
37 #include <frei0r.hpp>cxx . . $ `<file>/include/frei0r.hpp`/
38
39
40 #define PLANEScxx . . $ `src/filter/nervous/nervous.cpp:40:9`! 32
41
42 // freej compat facilitator
43 typedef structcxx . . $ $anonymous_type_c8c3936d4ff26781_0# {
44 int16_t wcxx . . $ $anonymous_type_c8c3936d4ff26781_0#w.;
45 int16_t hcxx . . $ $anonymous_type_c8c3936d4ff26781_0#h.;
46 uint8_t bppcxx . . $ $anonymous_type_c8c3936d4ff26781_0#bpp.;
47 uint32_t sizecxx . . $ $anonymous_type_c8c3936d4ff26781_0#size.;
48 } ScreenGeometrycxx . . $ ScreenGeometry#;
49
50
51
52 class Nervouscxx . . $ Nervous#: public frei0rcxx . . $ frei0r/::filtercxx . . $ frei0r/filter# {
53
54 public:
55
56 Nervouscxx . . $ Nervous#Nervous(3e454b8ccf442868).(int width, int height);
57
58 ~cxx . . $ Nervous#`~Nervous`(49f6e7a06ebc5aa8).Nervouscxx . . $ Nervous#();
59
60 virtual void updatecxx . . $ Nervous#update(da7b4a17ceb4e697).(double time,
61 uint32_t* out,
62 const uint32_t* in);
63
64 private:
65
66 ScreenGeometrycxx . . $ ScreenGeometry# geocxx . . $ Nervous#geo.;
67
68 void _initcxx . . $ Nervous#_init(3e454b8ccf442868).(int wdt, int hgt);
69 int32_t *buffercxx . . $ Nervous#buffer.;
70 int32_t *planetablecxx . . $ Nervous#planetable.[PLANEScxx . . $ `src/filter/nervous/nervous.cpp:40:9`!];
71 int modecxx . . $ Nervous#mode.;
72 int planecxx . . $ Nervous#plane., stockcxx . . $ Nervous#stock., timercxx . . $ Nervous#timer., stridecxx . . $ Nervous#stride., readplanecxx . . $ Nervous#readplane.;
73
74 /* cheap & fast randomizer (by Fukuchi Kentarou) */
75 uint32_t randvalcxx . . $ Nervous#randval.;
76 uint32_t fastrandcxx . . $ Nervous#fastrand(db52760e79bf9054).() { return (randvalcxx . . $ Nervous#randval.=randvalcxx . . $ Nervous#randval.*1103515245+12345); };
77 void fastsrandcxx . . $ Nervous#fastsrand(cb2f890c2fdad230).(uint32_t seed) { randvalcxx . . $ Nervous#randval. = seed; };
78
79 };
80
81 Nervouscxx . . $ Nervous#::Nervouscxx . . $ Nervous#Nervous(3e454b8ccf442868).(int wdt, int hgt) {
82 int c;
83 _initcxx . . $ Nervous#_init(3e454b8ccf442868).(wdt, hgt);
84
85 buffercxx . . $ Nervous#buffer. = (int32_t*) calloccxx . . $ calloc(63a7bf2941bfcd7a).(geocxx . . $ Nervous#geo..sizecxx . . $ $anonymous_type_c8c3936d4ff26781_0#size., PLANEScxx . . $ `src/filter/nervous/nervous.cpp:40:9`!);
86 if(!buffercxx . . $ Nervous#buffer.) {
87 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!,"ERROR: nervous plugin can't allocate needed memory: %u bytes\n",
88 geocxx . . $ Nervous#geo..sizecxx . . $ $anonymous_type_c8c3936d4ff26781_0#size.*PLANEScxx . . $ `src/filter/nervous/nervous.cpp:40:9`!);
89 return;
90 }
91 for(c=0;c<PLANEScxx . . $ `src/filter/nervous/nervous.cpp:40:9`!;c++)
92 planetablecxx . . $ Nervous#planetable.[c] = &buffercxx . . $ Nervous#buffer.[geocxx . . $ Nervous#geo..wcxx . . $ $anonymous_type_c8c3936d4ff26781_0#w.*geocxx . . $ Nervous#geo..hcxx . . $ $anonymous_type_c8c3936d4ff26781_0#h.*c];
93
94 planecxx . . $ Nervous#plane. = 0;
95 stockcxx . . $ Nervous#stock. = 0;
96 timercxx . . $ Nervous#timer. = 0;
97 readplanecxx . . $ Nervous#readplane. = 0;
98 modecxx . . $ Nervous#mode. = 1;
99 }
100
101 Nervouscxx . . $ Nervous#::~cxx . . $ Nervous#`~Nervous`(49f6e7a06ebc5aa8).Nervouscxx . . $ Nervous#() {
102 freecxx . . $ free(5d22bdacc48458e8).(buffercxx . . $ Nervous#buffer.);
103 }
104
105 void Nervouscxx . . $ Nervous#::_initcxx . . $ Nervous#_init(3e454b8ccf442868).(int wdt, int hgt) {
106 geocxx . . $ Nervous#geo..wcxx . . $ $anonymous_type_c8c3936d4ff26781_0#w. = wdt;
107 geocxx . . $ Nervous#geo..hcxx . . $ $anonymous_type_c8c3936d4ff26781_0#h. = hgt;
108 geocxx . . $ Nervous#geo..bppcxx . . $ $anonymous_type_c8c3936d4ff26781_0#bpp. = 32;
109 geocxx . . $ Nervous#geo..sizecxx . . $ $anonymous_type_c8c3936d4ff26781_0#size. = geocxx . . $ Nervous#geo..wcxx . . $ $anonymous_type_c8c3936d4ff26781_0#w.*geocxx . . $ Nervous#geo..hcxx . . $ $anonymous_type_c8c3936d4ff26781_0#h.*(geocxx . . $ Nervous#geo..bppcxx . . $ $anonymous_type_c8c3936d4ff26781_0#bpp./8);
110 }
111
112
113
114
115 void Nervouscxx . . $ Nervous#::updatecxx . . $ Nervous#update(da7b4a17ceb4e697).(double time,
116 uint32_t* out,
117 const uint32_t* in) {
118 memcpy(planetablecxx . . $ Nervous#planetable.[planecxx . . $ Nervous#plane.],in,geocxx . . $ Nervous#geo..sizecxx . . $ $anonymous_type_c8c3936d4ff26781_0#size.);
119
120 if(stockcxx . . $ Nervous#stock.<PLANEScxx . . $ `src/filter/nervous/nervous.cpp:40:9`!) stockcxx . . $ Nervous#stock.++;
121
122 if(modecxx . . $ Nervous#mode.) {
123 if(timercxx . . $ Nervous#timer.) {
124 readplanecxx . . $ Nervous#readplane. = readplanecxx . . $ Nervous#readplane. + stridecxx . . $ Nervous#stride.;
125 while(readplanecxx . . $ Nervous#readplane. < 0) readplanecxx . . $ Nervous#readplane. += stockcxx . . $ Nervous#stock.;
126 while(readplanecxx . . $ Nervous#readplane. >= stockcxx . . $ Nervous#stock.) readplanecxx . . $ Nervous#readplane. -= stockcxx . . $ Nervous#stock.;
127 timercxx . . $ Nervous#timer.--;
128 } else {
129 readplanecxx . . $ Nervous#readplane. = fastrandcxx . . $ Nervous#fastrand(db52760e79bf9054).() % stockcxx . . $ Nervous#stock.;
130 stridecxx . . $ Nervous#stride. = fastrandcxx . . $ Nervous#fastrand(db52760e79bf9054).() % 5 - 2;
131 if(stridecxx . . $ Nervous#stride. >= 0) stridecxx . . $ Nervous#stride.++;
132 timercxx . . $ Nervous#timer. = fastrandcxx . . $ Nervous#fastrand(db52760e79bf9054).() % 6 + 2;
133 }
134 } else
135 if(stockcxx . . $ Nervous#stock. > 0)
136 readplanecxx . . $ Nervous#readplane. = fastrandcxx . . $ Nervous#fastrand(db52760e79bf9054).() % stockcxx . . $ Nervous#stock.;
137
138 planecxx . . $ Nervous#plane.++;
139 if(planecxx . . $ Nervous#plane.==PLANEScxx . . $ `src/filter/nervous/nervous.cpp:40:9`!) planecxx . . $ Nervous#plane.=0;
140
141 memcpy(out,planetablecxx . . $ Nervous#planetable.[readplanecxx . . $ Nervous#readplane.],geocxx . . $ Nervous#geo..sizecxx . . $ $anonymous_type_c8c3936d4ff26781_0#size.);
142
143 }
144
145
146
147 frei0rcxx . . $ frei0r/::constructcxx . . $ frei0r/construct#<Nervouscxx . . $ Nervous#> plugincxx . . $ plugin.("Nervous"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
148 "flushes frames in time in a nervous way"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
149 "Tannenbaum, Kentaro, Jaromil"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
150 3,1);