| 1 | /* |
| 2 | Copyright (C) 2013 Vadim Druzhin <[email protected]> |
| 3 | |
| 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU Lesser General Public License as published by |
| 6 | the Free Software Foundation, either version 3 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #include <stdlib.h> |
| 19 | #include <stdint.h> |
| 20 | #include <string.h> |
| 21 | #include <frei0r.h>cxx . . $ `<file>/include/frei0r.h`/ |
| 22 | |
| 23 | typedef struct instance_scxx . . $ instance_s# |
| 24 | { |
| 25 | unsigned wcxx . . $ instance_s#w.; |
| 26 | unsigned hcxx . . $ instance_s#h.; |
| 27 | double poscxx . . $ instance_s#pos.; |
| 28 | unsigned bwcxx . . $ instance_s#bw.; |
| 29 | unsigned bw_scalecxx . . $ instance_s#bw_scale.; |
| 30 | unsigned *bwkcxx . . $ instance_s#bwk.; |
| 31 | } instance_tcxx . . $ instance_t#; |
| 32 | |
| 33 | int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).(void) |
| 34 | { |
| 35 | return 1; |
| 36 | } |
| 37 | |
| 38 | void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).(void) {} |
| 39 | |
| 40 | void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t# *info) |
| 41 | { |
| 42 | info->namecxx . . $ f0r_plugin_info#name. = "wipe-left"; |
| 43 | info->authorcxx . . $ f0r_plugin_info#author. = "Vadim Druzhin"; |
| 44 | info->plugin_typecxx . . $ f0r_plugin_info#plugin_type. = F0R_PLUGIN_TYPE_MIXER2cxx . . $ `include/frei0r.h:251:9`!; |
| 45 | info->color_modelcxx . . $ f0r_plugin_info#color_model. = F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!; |
| 46 | info->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version. = FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!; |
| 47 | info->major_versioncxx . . $ f0r_plugin_info#major_version. = 0; |
| 48 | info->minor_versioncxx . . $ f0r_plugin_info#minor_version. = 1; |
| 49 | info->num_paramscxx . . $ f0r_plugin_info#num_params. = 1; |
| 50 | info->explanationcxx . . $ f0r_plugin_info#explanation. = "Wipe from right to left"; |
| 51 | } |
| 52 | |
| 53 | void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t# *info, int index) |
| 54 | { |
| 55 | if(0 == index) |
| 56 | { |
| 57 | info->namecxx . . $ f0r_param_info#name. = "position"; |
| 58 | info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!; |
| 59 | info->explanationcxx . . $ f0r_param_info#explanation. = "Edge position"; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned width, unsigned height) |
| 64 | { |
| 65 | instance_tcxx . . $ instance_t# *inst; |
| 66 | unsigned bw = width / 16; |
| 67 | unsigned i; |
| 68 | |
| 69 | inst = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(*inst) + bw * sizeof(*inst->bwkcxx . . $ instance_s#bwk.)); |
| 70 | if(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! == inst) |
| 71 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 72 | |
| 73 | inst->wcxx . . $ instance_s#w. = width; |
| 74 | inst->hcxx . . $ instance_s#h. = height; |
| 75 | inst->poscxx . . $ instance_s#pos. = 0.0; |
| 76 | inst->bwcxx . . $ instance_s#bw. = bw; |
| 77 | inst->bw_scalecxx . . $ instance_s#bw_scale. = bw * bw; |
| 78 | inst->bwkcxx . . $ instance_s#bwk. = (unsigned *)(inst + 1); |
| 79 | |
| 80 | for(i = 0; i < bw; ++i) |
| 81 | { |
| 82 | if(i < bw / 2) |
| 83 | inst->bwkcxx . . $ instance_s#bwk.[i] = i * i * 2; |
| 84 | else |
| 85 | inst->bwkcxx . . $ instance_s#bwk.[i] = inst->bw_scalecxx . . $ instance_s#bw_scale. - (bw - i) * (bw - i) * 2; |
| 86 | } |
| 87 | |
| 88 | return inst; |
| 89 | } |
| 90 | |
| 91 | void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# inst) |
| 92 | { |
| 93 | freecxx . . $ free(5d22bdacc48458e8).(inst); |
| 94 | } |
| 95 | |
| 96 | void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# param, int param_index) |
| 97 | { |
| 98 | instance_tcxx . . $ instance_t# *inst = instance; |
| 99 | |
| 100 | if(0 == param_index) |
| 101 | inst->poscxx . . $ instance_s#pos. = *(f0r_param_doublecxx . . $ f0r_param_double# *)param; |
| 102 | } |
| 103 | |
| 104 | void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# param, int param_index) |
| 105 | { |
| 106 | instance_tcxx . . $ instance_t# *inst = instance; |
| 107 | |
| 108 | if(0 == param_index) |
| 109 | *(f0r_param_doublecxx . . $ f0r_param_double# *)param = inst->poscxx . . $ instance_s#pos.; |
| 110 | } |
| 111 | |
| 112 | void f0r_update2cxx . . $ f0r_update2(1b234bc88d3943d5).( |
| 113 | f0r_instance_tcxx . . $ f0r_instance_t# instance, |
| 114 | double time, |
| 115 | const uint32_tcxx . . $ uint32_t#* inframe1, |
| 116 | const uint32_tcxx . . $ uint32_t#* inframe2, |
| 117 | const uint32_tcxx . . $ uint32_t#* inframe3, |
| 118 | uint32_tcxx . . $ uint32_t#* outframe |
| 119 | ) |
| 120 | { |
| 121 | instance_tcxx . . $ instance_t# *inst = instance; |
| 122 | unsigned y; |
| 123 | int off; |
| 124 | unsigned bw, i, dbw; |
| 125 | uint8_tcxx . . $ uint8_t# *c1, *c2, *co; |
| 126 | |
| 127 | (void)time; /* Unused */ |
| 128 | (void)inframe3; /* Unused */ |
| 129 | |
| 130 | off = (int)((inst->wcxx . . $ instance_s#w. + inst->bwcxx . . $ instance_s#bw.) * inst->poscxx . . $ instance_s#pos. + 0.5) - inst->bwcxx . . $ instance_s#bw.; |
| 131 | bw = inst->bwcxx . . $ instance_s#bw.; |
| 132 | dbw = 0; |
| 133 | |
| 134 | if(off < 0) |
| 135 | { |
| 136 | bw += off; |
| 137 | off = 0; |
| 138 | } |
| 139 | else if(inst->wcxx . . $ instance_s#w. < off + bw) |
| 140 | { |
| 141 | bw = inst->wcxx . . $ instance_s#w. - off; |
| 142 | dbw = inst->bwcxx . . $ instance_s#bw. - bw; |
| 143 | } |
| 144 | |
| 145 | for(y = 0; y < inst->hcxx . . $ instance_s#h.; ++y) |
| 146 | { |
| 147 | memcpycxx . . $ memcpy(cc817cb175f282d).(outframe + inst->wcxx . . $ instance_s#w. * y, inframe1 + inst->wcxx . . $ instance_s#w. * y, |
| 148 | (inst->wcxx . . $ instance_s#w. - off - bw) * sizeof(*outframe)); |
| 149 | |
| 150 | c1 = (uint8_tcxx . . $ uint8_t# *)(inframe1 + inst->wcxx . . $ instance_s#w. * y + inst->wcxx . . $ instance_s#w. - off - bw); |
| 151 | c2 = (uint8_tcxx . . $ uint8_t# *)(inframe2 + inst->wcxx . . $ instance_s#w. * y + inst->wcxx . . $ instance_s#w. - off - bw); |
| 152 | co = (uint8_tcxx . . $ uint8_t# *)(outframe + inst->wcxx . . $ instance_s#w. * y + inst->wcxx . . $ instance_s#w. - off - bw); |
| 153 | for(i = 0; i < bw * 4; ++i) |
| 154 | { |
| 155 | unsigned k = inst->bwkcxx . . $ instance_s#bwk.[i / 4 + dbw]; |
| 156 | |
| 157 | *co = (*c1 * (inst->bw_scalecxx . . $ instance_s#bw_scale. - k) + *c2 * k + inst->bw_scalecxx . . $ instance_s#bw_scale. / 2) / inst->bw_scalecxx . . $ instance_s#bw_scale.; |
| 158 | ++c1; |
| 159 | ++c2; |
| 160 | ++co; |
| 161 | } |
| 162 | |
| 163 | memcpycxx . . $ memcpy(cc817cb175f282d).(outframe + inst->wcxx . . $ instance_s#w. * y + inst->wcxx . . $ instance_s#w. - off, inframe2 + inst->wcxx . . $ instance_s#w. * y + inst->wcxx . . $ instance_s#w. - off, |
| 164 | off * sizeof(*outframe)); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | |
| 169 |