Debian Codegraph @

src/mixer2/uvmap/uvmap.c

raw symbols SCIP
1 /* uvmap.c
2 * Copyright (C) 2008 Richard Spindler ([email protected])
3 * This file is a Frei0r plugin.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <stdlib.h>
21 #include <assert.h>
22 #include <math.h>
23
24 #include "frei0r.h"cxx . . $ `<file>/include/frei0r.h`/
25
26 typedef struct uvmap_instancecxx . . $ uvmap_instance#
27 {
28 unsigned int widthcxx . . $ uvmap_instance#width.;
29 unsigned int heightcxx . . $ uvmap_instance#height.;
30 } uvmap_instance_tcxx . . $ uvmap_instance_t#;
31
32 int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).()
33 {
34 return 1;
35 }
36
37 void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).()
38 { /* no initialization required */ }
39
40 void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#* uvmapInfo)
41 {
42 uvmapInfo->namecxx . . $ f0r_plugin_info#name. = "UV Map";
43 uvmapInfo->authorcxx . . $ f0r_plugin_info#author. = "Richard Spindler";
44 uvmapInfo->plugin_typecxx . . $ f0r_plugin_info#plugin_type. = F0R_PLUGIN_TYPE_MIXER2cxx . . $ `include/frei0r.h:251:9`!;
45 uvmapInfo->color_modelcxx . . $ f0r_plugin_info#color_model. = F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!;
46 uvmapInfo->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version. = FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!;
47 uvmapInfo->major_versioncxx . . $ f0r_plugin_info#major_version. = 0;
48 uvmapInfo->minor_versioncxx . . $ f0r_plugin_info#minor_version. = 9;
49 uvmapInfo->num_paramscxx . . $ f0r_plugin_info#num_params. = 0;
50 uvmapInfo->explanationcxx . . $ f0r_plugin_info#explanation. = "Uses Input 1 as UV Map to distort Input 2";
51 }
52
53 void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t#* info, int param_index)
54 {
55 /* no params */
56 }
57
58 f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned int width, unsigned int height)
59 {
60 uvmap_instance_tcxx . . $ uvmap_instance_t#* inst = (uvmap_instance_tcxx . . $ uvmap_instance_t#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*inst));
61 inst->widthcxx . . $ uvmap_instance#width. = width; inst->heightcxx . . $ uvmap_instance#height. = height;
62 return (f0r_instance_tcxx . . $ f0r_instance_t#)inst;
63 }
64
65 void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# instance)
66 {
67 freecxx . . $ free(5d22bdacc48458e8).(instance);
68 }
69
70 void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
71 f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
72 { /* no params */ }
73
74 void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
75 f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
76 { /* no params */ }
77
78 void f0r_update2cxx . . $ f0r_update2(1b234bc88d3943d5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
79 double time,
80 const uint32_tcxx . . $ uint32_t#* inframe1,
81 const uint32_tcxx . . $ uint32_t#* inframe2,
82 const uint32_tcxx . . $ uint32_t#* inframe3,
83 uint32_tcxx . . $ uint32_t#* outframe)
84 {
85 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance);
86 uvmap_instance_tcxx . . $ uvmap_instance_t#* inst = (uvmap_instance_tcxx . . $ uvmap_instance_t#*)instance;
87 unsigned int w = inst->widthcxx . . $ uvmap_instance#width.;
88 unsigned int h = inst->heightcxx . . $ uvmap_instance#height.;
89 unsigned int x,y;
90
91 uint32_tcxx . . $ uint32_t#* dst = outframe;
92 const uint32_tcxx . . $ uint32_t#* uvmap = inframe1;
93 const uint32_tcxx . . $ uint32_t#* src = inframe2;
94 float fx, fy;
95 long px, py;
96 for( y = 0; y < h; ++y )
97 for( x = 0; x < w; ++x ) {
98 /* The coordinates start in the lower left corner:
99 *
100 * ^ +-------------+
101 * | | |
102 * G | |
103 * 0+-------------+
104 * 0 R ->
105 *
106 */
107 unsigned char* tmpc = (unsigned char*)uvmap;
108 fx = ((float)tmpc[0]) / 255.0;
109 fy = ((float)tmpc[1]) / 255.0;
110 fy = 1.0 - fy;
111
112 px = lrintfcxx . . $ lrintf(2b53f6384d78b03a).( (w - 1) * fx );
113 py = lrintfcxx . . $ lrintf(2b53f6384d78b03a).( (h - 1) * fy );
114 if ( tmpc[2] > 128 ) {
115 *dst++ = src[px+w*py];
116 } else {
117 *dst++ = 0x00000000;
118 }
119 uvmap++;
120 }
121 }
122
123