| 1 | /* |
| 2 | medians.c implements several median-type filters |
| 3 | |
| 4 | This frei0r plugin implements several median-type filters |
| 5 | |
| 6 | Version 0.1 jan 2013 |
| 7 | |
| 8 | Copyright (C) 2013 Marko Cebokli http://lea.hamradio.si/~s57uuu |
| 9 | |
| 10 | |
| 11 | This program is free software; you can redistribute it and/or modify |
| 12 | it under the terms of the GNU General Public License as published by |
| 13 | the Free Software Foundation; either version 2 of the License, or |
| 14 | (at your option) any later version. |
| 15 | |
| 16 | This program is distributed in the hope that it will be useful, |
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | GNU General Public License for more details. |
| 20 | |
| 21 | You should have received a copy of the GNU General Public License |
| 22 | along with this program; if not, write to the Free Software |
| 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | |
| 25 | */ |
| 26 | |
| 27 | |
| 28 | //compile: gcc -c -fPIC -Wall medians.c -o medians.o |
| 29 | //link: gcc -shared -o medians.so medians.o |
| 30 | |
| 31 | #include <stdio.h> |
| 32 | #include <frei0r.h>cxx . . $ `<file>/include/frei0r.h`/ |
| 33 | #include <stdlib.h> |
| 34 | #include <math.h> |
| 35 | #include <assert.h> |
| 36 | #include <inttypes.h> |
| 37 | #include <string.h> |
| 38 | #include <stdio.h> |
| 39 | |
| 40 | #include "small_medians.h"cxx . . $ `<file>/src/filter/medians/small_medians.h`/ |
| 41 | #include "ctmf.h"cxx . . $ `<file>/src/filter/medians/ctmf.h`/ |
| 42 | |
| 43 | |
| 44 | /* ****************************************** |
| 45 | //The following functions implement these median type filters: |
| 46 | |
| 47 | X |
| 48 | cross5: XXX |
| 49 | X |
| 50 | |
| 51 | XXX |
| 52 | square3x3: XXX |
| 53 | XXX |
| 54 | |
| 55 | |
| 56 | Bilevel: |
| 57 | |
| 58 | X |
| 59 | XXX |
| 60 | dia3x3: XXXXX |
| 61 | XXX |
| 62 | X |
| 63 | |
| 64 | Arce BI: multilevel spatio-temporal, see [1] |
| 65 | |
| 66 | Arp ML3D: multilevel spatio-temporal, see [1] |
| 67 | |
| 68 | ML3DEX: multilevel spatio-temporal, see [1] |
| 69 | |
| 70 | |
| 71 | [1] Anil Christopher Kokaram: Motion Picture Restoration |
| 72 | phd dissertation |
| 73 | |
| 74 | ****************************************** */ |
| 75 | |
| 76 | //------------------------------------------------------------ |
| 77 | //cross5 packed char RGB image (uint32_t) |
| 78 | //vs = input image |
| 79 | //is = output image |
| 80 | void cross5cxx . . $ cross5(4441e435cc27af0f).(const uint32_tcxx . . $ uint32_t# *vs, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 81 | { |
| 82 | int i,j,p; |
| 83 | uint32_tcxx . . $ uint32_t# m[8]; |
| 84 | |
| 85 | for (i=1;i<h-1;i++) |
| 86 | for (j=1;j<w-1;j++) |
| 87 | { |
| 88 | p=i*w+j; |
| 89 | |
| 90 | m[0]=vs[p-w]; m[1]=vs[p-1]; m[2]=vs[p]; |
| 91 | m[3]=vs[p+1]; m[4]=vs[p+w]; |
| 92 | |
| 93 | is[p]=median5cxx . . $ median5(c22c494133c14864).(m); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | //------------------------------------------------------------ |
| 98 | //square 3x3 packed char RGB image (uint32_t) |
| 99 | //vs = input image |
| 100 | //is = output image |
| 101 | void sq3x3cxx . . $ sq3x3(4441e435cc27af0f).(const uint32_tcxx . . $ uint32_t# *vs, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 102 | { |
| 103 | int i,j,p; |
| 104 | uint32_tcxx . . $ uint32_t# m[16]; |
| 105 | |
| 106 | for (i=1;i<h-1;i++) |
| 107 | for (j=1;j<w-1;j++) |
| 108 | { |
| 109 | p=i*w+j; |
| 110 | |
| 111 | m[0]=vs[p-w-1]; m[1]=vs[p-w]; m[2]=vs[p-w+1]; |
| 112 | m[3]=vs[p-1]; m[4]=vs[p]; m[5]=vs[p+1]; |
| 113 | m[6]=vs[p+w-1]; m[7]=vs[p+w]; m[8]=vs[p+w+1]; |
| 114 | |
| 115 | is[p]=median9cxx . . $ median9(c22c494133c14864).(m); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | //------------------------------------------------------------ |
| 120 | //bilevel packed char RGB image (uint32_t) |
| 121 | //vs = input image |
| 122 | //is = output image |
| 123 | void bilevelcxx . . $ bilevel(4441e435cc27af0f).(const uint32_tcxx . . $ uint32_t# *vs, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 124 | { |
| 125 | int i,j,p; |
| 126 | uint32_tcxx . . $ uint32_t# m[8],mm[4]; |
| 127 | |
| 128 | for (i=1;i<h-1;i++) |
| 129 | for (j=1;j<w-1;j++) |
| 130 | { |
| 131 | p=i*w+j; |
| 132 | |
| 133 | m[0]=vs[p-w-1]; m[1]=vs[p-w+1]; m[2]=vs[p]; |
| 134 | m[3]=vs[p+w-1]; m[4]=vs[p+w+1]; |
| 135 | mm[0]=median5cxx . . $ median5(c22c494133c14864).(m); |
| 136 | mm[1]=vs[p]; |
| 137 | m[0]=vs[p-w]; m[1]=vs[p-1]; m[2]=vs[p]; |
| 138 | m[3]=vs[p+1]; m[4]=vs[p+w]; |
| 139 | mm[2]=median5cxx . . $ median5(c22c494133c14864).(m); |
| 140 | |
| 141 | is[p]=median3cxx . . $ median3(c22c494133c14864).(mm); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | //------------------------------------------------------------ |
| 146 | //diamond 3x3 packed char RGB image (uint32_t) |
| 147 | //vs = input image |
| 148 | //is = output image |
| 149 | void dia3x3cxx . . $ dia3x3(4441e435cc27af0f).(const uint32_tcxx . . $ uint32_t# *vs, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 150 | { |
| 151 | int i,j,p; |
| 152 | uint32_tcxx . . $ uint32_t# m[16]; |
| 153 | |
| 154 | for (i=2;i<h-2;i++) |
| 155 | for (j=2;j<w-2;j++) |
| 156 | { |
| 157 | p=i*w+j; |
| 158 | m[0]=vs[p-2*w]; m[1]=vs[p-w-1]; m[2]=vs[p-w]; |
| 159 | m[3]=vs[p-w+1]; m[4]=vs[p-2]; m[5]=vs[p-1]; |
| 160 | m[6]=vs[p]; m[7]=vs[p+1]; m[8]=vs[p+2]; |
| 161 | m[9]=vs[p+w-1]; m[10]=vs[p+w]; m[11]=vs[p+w+1]; |
| 162 | m[12]=vs[p+2*w]; |
| 163 | |
| 164 | is[p]=median13cxx . . $ median13(c22c494133c14864).(m); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | //------------------------------------------------------------ |
| 169 | //square 5x5 packed char RGB image (uint32_t) |
| 170 | //vs = input image |
| 171 | //is = output image |
| 172 | void sq5x5cxx . . $ sq5x5(4441e435cc27af0f).(const uint32_tcxx . . $ uint32_t# *vs, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 173 | { |
| 174 | int i,j,p; |
| 175 | uint32_tcxx . . $ uint32_t# m[32]; |
| 176 | |
| 177 | for (i=2;i<h-2;i++) |
| 178 | for (j=2;j<w-2;j++) |
| 179 | { |
| 180 | p=i*w+j; |
| 181 | |
| 182 | m[0]=vs[p-2*w-2]; m[1]=vs[p-2*w-1]; m[2]=vs[p-2*w]; |
| 183 | m[3]=vs[p-2*w+1]; m[4]=vs[p-2*w+2]; m[5]=vs[p-w-2]; |
| 184 | m[6]=vs[p-w-1]; m[7]=vs[p-w]; m[8]=vs[p-w+1]; |
| 185 | m[9]=vs[p-w+2]; m[10]=vs[p-2]; m[11]=vs[p-1]; |
| 186 | m[12]=vs[p]; m[13]=vs[p+1]; m[14]=vs[p+2]; |
| 187 | m[15]=vs[p+w-2]; m[16]=vs[p+w-1]; m[17]=vs[p+w]; |
| 188 | m[18]=vs[p+w+1]; m[19]=vs[p+w+2]; m[20]=vs[p+2*w-2]; |
| 189 | m[21]=vs[p+2*w-1];m[22]=vs[p+2*w]; m[23]=vs[p+2*w+1]; |
| 190 | m[24]=vs[p+2*w+2]; |
| 191 | |
| 192 | is[p]=median25cxx . . $ median25(c22c494133c14864).(m); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | |
| 197 | //-------------------------------------------------------- |
| 198 | //temporal 3 frames |
| 199 | void temp3cxx . . $ temp3(6c037a616f2c86e8).(uint32_tcxx . . $ uint32_t# *s1, uint32_tcxx . . $ uint32_t# *s2, uint32_tcxx . . $ uint32_t# *s3, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 200 | { |
| 201 | int i; |
| 202 | uint32_tcxx . . $ uint32_t# m[32]; |
| 203 | |
| 204 | for (i=0;i<w*h;i++) |
| 205 | { |
| 206 | m[0]=s1[i]; m[1]=s2[i]; m[2]=s3[i]; |
| 207 | is[i]=median3cxx . . $ median3(c22c494133c14864).(m); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | |
| 212 | //-------------------------------------------------------- |
| 213 | //temporal 5 frames |
| 214 | void temp5cxx . . $ temp5(d0ccb6d87d194896).(uint32_tcxx . . $ uint32_t# *s1, uint32_tcxx . . $ uint32_t# *s2, uint32_tcxx . . $ uint32_t# *s3, uint32_tcxx . . $ uint32_t# *s4, uint32_tcxx . . $ uint32_t# *s5, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 215 | { |
| 216 | int i; |
| 217 | uint32_tcxx . . $ uint32_t# m[32]; |
| 218 | |
| 219 | for (i=0;i<w*h;i++) |
| 220 | { |
| 221 | m[0]=s1[i]; m[1]=s2[i]; m[2]=s3[i]; m[3]=s4[i]; m[4]=s5[i]; |
| 222 | is[i]=median5cxx . . $ median5(c22c494133c14864).(m); |
| 223 | } |
| 224 | |
| 225 | } |
| 226 | |
| 227 | |
| 228 | //------------------------------------------------------------ |
| 229 | //Arce BI packed char RGB image (uint32_t) |
| 230 | //s1,s2,s3 = previous, current, next frame |
| 231 | //is = output image |
| 232 | void ArceBIcxx . . $ ArceBI(6c037a616f2c86e8).(uint32_tcxx . . $ uint32_t# *s1, uint32_tcxx . . $ uint32_t# *s2, uint32_tcxx . . $ uint32_t# *s3, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 233 | { |
| 234 | int i,j,p; |
| 235 | uint32_tcxx . . $ uint32_t# mm[8],m[16]; |
| 236 | |
| 237 | for (i=1;i<h-1;i++) |
| 238 | for (j=1;j<w-1;j++) |
| 239 | { |
| 240 | p=i*w+j; |
| 241 | //grupa C |
| 242 | mm[0]=s1[p]; |
| 243 | //GRUPA W1 |
| 244 | m[0]=s1[p]; m[1]=s2[p-w-1]; m[2]=s2[p]; |
| 245 | m[3]=s2[p+w+1]; m[4]=s3[p]; |
| 246 | mm[3]=median5cxx . . $ median5(c22c494133c14864).(m); |
| 247 | //grupa W2 |
| 248 | m[0]=s1[p]; m[1]=s2[p-w]; m[2]=s2[p]; |
| 249 | m[3]=s2[p+w]; m[4]=s3[p]; |
| 250 | mm[4]=median5cxx . . $ median5(c22c494133c14864).(m); |
| 251 | //grupa W3 |
| 252 | m[0]=s1[p]; m[1]=s2[p-1]; m[2]=s2[p]; |
| 253 | m[3]=s2[p+1]; m[4]=s3[p]; |
| 254 | mm[5]=median5cxx . . $ median5(c22c494133c14864).(m); |
| 255 | //grupa W4 |
| 256 | m[0]=s1[p]; m[1]=s2[p-w+1]; m[2]=s2[p]; |
| 257 | m[3]=s2[p+w-1]; m[4]=s3[p]; |
| 258 | mm[6]=median5cxx . . $ median5(c22c494133c14864).(m); |
| 259 | //max |
| 260 | mm[1]=mm[3]; if (mm[4]>mm[1]) mm[1]=mm[4]; |
| 261 | if (mm[5]>mm[1]) mm[1]=mm[5]; |
| 262 | if (mm[6]>mm[1]) mm[1]=mm[6]; |
| 263 | //min |
| 264 | mm[2]=mm[3]; if (mm[4]<mm[2]) mm[2]=mm[4]; |
| 265 | if (mm[5]<mm[2]) mm[2]=mm[5]; |
| 266 | if (mm[6]<mm[2]) mm[2]=mm[6]; |
| 267 | //izhod |
| 268 | is[p]=median3cxx . . $ median3(c22c494133c14864).(mm); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | |
| 273 | //------------------------------------------------------------ |
| 274 | //Arp ML3D packed char RGB image (uint32_t) |
| 275 | //s1,s2,s3 = previous, current, next frame |
| 276 | //is = output image |
| 277 | void ml3dcxx . . $ ml3d(6c037a616f2c86e8).(uint32_tcxx . . $ uint32_t# *s1, uint32_tcxx . . $ uint32_t# *s2, uint32_tcxx . . $ uint32_t# *s3, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 278 | { |
| 279 | int i,j,p; |
| 280 | uint32_tcxx . . $ uint32_t# mm[8],m[16]; |
| 281 | |
| 282 | for (i=1;i<h-1;i++) |
| 283 | for (j=1;j<w-1;j++) |
| 284 | { |
| 285 | p=i*w+j; |
| 286 | //grupa C |
| 287 | mm[0]=s1[p]; |
| 288 | //grupa W6 |
| 289 | m[0]=s1[p]; m[1]=s2[p-w-1]; m[2]=s2[p-w+1]; |
| 290 | m[3]=s2[p]; m[4]=s2[p+w-1]; m[5]=s2[p+w+1]; |
| 291 | m[6]=s3[p]; |
| 292 | mm[1]=median7cxx . . $ median7(c22c494133c14864).(m); |
| 293 | //grupa W5 |
| 294 | m[0]=s1[p]; m[1]=s2[p-w]; m[2]=s2[p-1]; |
| 295 | m[3]=s2[p]; m[4]=s2[p+1]; m[5]=s2[p+w]; |
| 296 | m[6]=s3[p]; |
| 297 | mm[2]=median7cxx . . $ median7(c22c494133c14864).(m); |
| 298 | //izhod = median medianov |
| 299 | is[p]=median3cxx . . $ median3(c22c494133c14864).(mm); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | //------------------------------------------------------------ |
| 304 | //Kokaram ML3Dex packed char RGB image (uint32_t) |
| 305 | //s1,s2,s3 = previous, current, next frame |
| 306 | //is = output image |
| 307 | void ml3dexcxx . . $ ml3dex(6c037a616f2c86e8).(uint32_tcxx . . $ uint32_t# *s1, uint32_tcxx . . $ uint32_t# *s2, uint32_tcxx . . $ uint32_t# *s3, int w, int h, uint32_tcxx . . $ uint32_t# *is) |
| 308 | { |
| 309 | int i,j,p; |
| 310 | uint32_tcxx . . $ uint32_t# mm[8],m[16]; |
| 311 | |
| 312 | for (i=1;i<h-1;i++) |
| 313 | for (j=1;j<w-1;j++) |
| 314 | { |
| 315 | p=i*w+j; |
| 316 | //grupa W9 |
| 317 | m[0]=s1[p-w-1]; m[1]=s1[p-w+1]; m[2]=s1[p]; |
| 318 | m[3]=s1[p+w-1]; m[4]=s1[p+w+1]; m[5]=s2[p]; |
| 319 | m[6]=s3[p-w-1]; m[7]=s3[p-w+1]; m[8]=s3[p]; |
| 320 | m[9]=s3[p+w-1]; m[10]=s3[p+w+1]; |
| 321 | mm[0]=median11cxx . . $ median11(c22c494133c14864).(m); |
| 322 | //grupa W8 |
| 323 | m[0]=s1[p-w]; m[1]=s1[p-1]; m[2]=s1[p]; |
| 324 | m[3]=s1[p+w]; m[4]=s1[p+1]; m[5]=s2[p]; |
| 325 | m[6]=s3[p-w]; m[7]=s3[p-1]; m[8]=s3[p]; |
| 326 | m[9]=s3[p+w]; m[10]=s3[p+1]; |
| 327 | mm[1]=median11cxx . . $ median11(c22c494133c14864).(m); |
| 328 | //grupa W7 |
| 329 | m[0]=s1[p]; m[1]=s2[p]; m[2]=s3[p]; |
| 330 | mm[2]=median3cxx . . $ median3(c22c494133c14864).(m); |
| 331 | //grupa W6 |
| 332 | m[0]=s1[p]; m[1]=s2[p-w-1]; m[2]=s2[p-w+1]; |
| 333 | m[3]=s2[p]; m[4]=s2[p+w-1]; m[5]=s2[p+w+1]; |
| 334 | m[6]=s3[p]; |
| 335 | mm[3]=median7cxx . . $ median7(c22c494133c14864).(m); |
| 336 | //grupa W5 |
| 337 | m[0]=s1[p]; m[1]=s2[p-w]; m[2]=s2[p-1]; |
| 338 | m[3]=s2[p]; m[4]=s2[p+1]; m[5]=s2[p+w]; |
| 339 | m[6]=s3[p]; |
| 340 | mm[4]=median7cxx . . $ median7(c22c494133c14864).(m); |
| 341 | //izhod = median medianov |
| 342 | is[p]=median5cxx . . $ median5(c22c494133c14864).(mm); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | //**************************************************** |
| 347 | |
| 348 | //---------------------------------------- |
| 349 | //struktura za instanco efekta |
| 350 | typedef structcxx . . $ $anonymous_type_7dedf4dea87650a7_0# |
| 351 | { |
| 352 | int hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.; |
| 353 | int wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.; |
| 354 | |
| 355 | //parameters |
| 356 | int typecxx . . $ $anonymous_type_7dedf4dea87650a7_0#type.; |
| 357 | int sizecxx . . $ $anonymous_type_7dedf4dea87650a7_0#size.; |
| 358 | |
| 359 | //internal variables |
| 360 | uint32_tcxx . . $ uint32_t# *ppfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#ppf.,*pfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#pf.,*cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf.,*nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf.,*nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf.; |
| 361 | |
| 362 | //image buffers |
| 363 | uint32_tcxx . . $ uint32_t# *f1cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f1.; |
| 364 | uint32_tcxx . . $ uint32_t# *f2cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f2.; |
| 365 | uint32_tcxx . . $ uint32_t# *f3cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f3.; |
| 366 | uint32_tcxx . . $ uint32_t# *f4cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f4.; |
| 367 | uint32_tcxx . . $ uint32_t# *f5cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f5.; |
| 368 | |
| 369 | |
| 370 | char *liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr.; |
| 371 | } instcxx . . $ inst#; |
| 372 | |
| 373 | |
| 374 | //----------------------------------------------------- |
| 375 | //stretch [0...1] to parameter range [min...max] linear |
| 376 | float map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(double v, float min, float max) |
| 377 | { |
| 378 | return min+(max-min)*v; |
| 379 | } |
| 380 | |
| 381 | //----------------------------------------------------- |
| 382 | //collapse from parameter range [min...max] to [0...1] linear |
| 383 | double map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(float v, float min, float max) |
| 384 | { |
| 385 | return (v-min)/(max-min); |
| 386 | } |
| 387 | |
| 388 | //*********************************************** |
| 389 | // OBVEZNE FREI0R FUNKCIJE |
| 390 | |
| 391 | //----------------------------------------------- |
| 392 | int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).() |
| 393 | { |
| 394 | return 1; |
| 395 | } |
| 396 | |
| 397 | //------------------------------------------------ |
| 398 | void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).() |
| 399 | { |
| 400 | } |
| 401 | |
| 402 | //----------------------------------------------- |
| 403 | void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#* info) |
| 404 | { |
| 405 | |
| 406 | info->namecxx . . $ f0r_plugin_info#name.="Medians"; |
| 407 | info->authorcxx . . $ f0r_plugin_info#author.="Marko Cebokli"; |
| 408 | info->plugin_typecxx . . $ f0r_plugin_info#plugin_type.=F0R_PLUGIN_TYPE_FILTERcxx . . $ `include/frei0r.h:247:9`!; |
| 409 | info->color_modelcxx . . $ f0r_plugin_info#color_model.=F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!; |
| 410 | info->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version.=FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!; |
| 411 | info->major_versioncxx . . $ f0r_plugin_info#major_version.=0; |
| 412 | info->minor_versioncxx . . $ f0r_plugin_info#minor_version.=1; |
| 413 | info->num_paramscxx . . $ f0r_plugin_info#num_params.=2; |
| 414 | info->explanationcxx . . $ f0r_plugin_info#explanation.="Implements several median-type filters"; |
| 415 | } |
| 416 | |
| 417 | //-------------------------------------------------- |
| 418 | void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t#* info, int param_index) |
| 419 | { |
| 420 | switch(param_index) |
| 421 | { |
| 422 | case 0: |
| 423 | info->namecxx . . $ f0r_param_info#name. = "Type"; |
| 424 | info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_STRINGcxx . . $ `include/frei0r.h:400:9`!; |
| 425 | info->explanationcxx . . $ f0r_param_info#explanation. = "Choose type of median: Cross5, Square3x3, Bilevel, Diamond3x3, Square5x5, Temp3, Temp5, ArceBI, ML3D, ML3dEX, VarSize"; |
| 426 | break; |
| 427 | case 1: |
| 428 | info->namecxx . . $ f0r_param_info#name. = "Size"; |
| 429 | info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!; |
| 430 | info->explanationcxx . . $ f0r_param_info#explanation. = "Size for 'var size' type filter"; |
| 431 | break; |
| 432 | case 2: |
| 433 | info->namecxx . . $ f0r_param_info#name. = ""; |
| 434 | info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_BOOLcxx . . $ `include/frei0r.h:377:9`!; |
| 435 | info->explanationcxx . . $ f0r_param_info#explanation. = ""; |
| 436 | break; |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | //---------------------------------------------- |
| 441 | f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned int width, unsigned int height) |
| 442 | { |
| 443 | instcxx . . $ inst# *in; |
| 444 | |
| 445 | in=calloccxx . . $ calloc(63a7bf2941bfcd7a).(1,sizeof(instcxx . . $ inst#)); |
| 446 | in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.=width; |
| 447 | in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.=height; |
| 448 | |
| 449 | in->typecxx . . $ $anonymous_type_7dedf4dea87650a7_0#type.=1; |
| 450 | in->liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr.=calloccxx . . $ calloc(63a7bf2941bfcd7a).(1,strlencxx . . $ strlen(751346f8406fd082).("Square3x3")+1); |
| 451 | strcpycxx . . $ strcpy(b7b3a83273496486).(in->liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr.,"Square3x3"); |
| 452 | in->sizecxx . . $ $anonymous_type_7dedf4dea87650a7_0#size.=5; |
| 453 | |
| 454 | in->f1cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f1.=calloccxx . . $ calloc(63a7bf2941bfcd7a).(in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.*in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.,sizeof(uint32_tcxx . . $ uint32_t#)); |
| 455 | in->f2cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f2.=calloccxx . . $ calloc(63a7bf2941bfcd7a).(in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.*in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.,sizeof(uint32_tcxx . . $ uint32_t#)); |
| 456 | in->f3cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f3.=calloccxx . . $ calloc(63a7bf2941bfcd7a).(in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.*in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.,sizeof(uint32_tcxx . . $ uint32_t#)); |
| 457 | in->f4cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f4.=calloccxx . . $ calloc(63a7bf2941bfcd7a).(in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.*in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.,sizeof(uint32_tcxx . . $ uint32_t#)); |
| 458 | in->f5cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f5.=calloccxx . . $ calloc(63a7bf2941bfcd7a).(in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.*in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.,sizeof(uint32_tcxx . . $ uint32_t#)); |
| 459 | |
| 460 | in->ppfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#ppf.=in->f1cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f1.; |
| 461 | in->pfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#pf.=in->f2cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f2.; |
| 462 | in->cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf.=in->f3cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f3.; |
| 463 | in->nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf.=in->f4cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f4.; |
| 464 | in->nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf.=in->f5cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f5.; |
| 465 | |
| 466 | return (f0r_instance_tcxx . . $ f0r_instance_t#)in; |
| 467 | } |
| 468 | |
| 469 | //--------------------------------------------------- |
| 470 | void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# instance) |
| 471 | { |
| 472 | instcxx . . $ inst# *in; |
| 473 | |
| 474 | in=(instcxx . . $ inst#*)instance; |
| 475 | |
| 476 | freecxx . . $ free(5d22bdacc48458e8).(in->f1cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f1.); |
| 477 | freecxx . . $ free(5d22bdacc48458e8).(in->f2cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f2.); |
| 478 | freecxx . . $ free(5d22bdacc48458e8).(in->f3cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f3.); |
| 479 | freecxx . . $ free(5d22bdacc48458e8).(in->f4cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f4.); |
| 480 | freecxx . . $ free(5d22bdacc48458e8).(in->f5cxx . . $ $anonymous_type_7dedf4dea87650a7_0#f5.); |
| 481 | |
| 482 | freecxx . . $ free(5d22bdacc48458e8).(in->liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr.); |
| 483 | freecxx . . $ free(5d22bdacc48458e8).(instance); |
| 484 | } |
| 485 | |
| 486 | //----------------------------------------------------- |
| 487 | void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# parm, int param_index) |
| 488 | { |
| 489 | instcxx . . $ inst# *p; |
| 490 | double tmpf; |
| 491 | int chg; |
| 492 | char *tmpch; |
| 493 | char list1[][11]={"Cross5", "Square3x3", "Bilevel", "Diamond3x3", "Square5x5", "Temp3", "Temp5", "ArceBI", "ML3D", "ML3dEX", "VarSize"}; |
| 494 | |
| 495 | p=(instcxx . . $ inst#*)instance; |
| 496 | |
| 497 | chg=0; |
| 498 | switch(param_index) |
| 499 | { |
| 500 | case 0: //(string based list) |
| 501 | tmpch = (*(char**)parm); |
| 502 | p->liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr. = (char*)realloccxx . . $ realloc(417ab160f6baadc6).( p->liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr., strlencxx . . $ strlen(751346f8406fd082).(tmpch) + 1 ); |
| 503 | strcpycxx . . $ strcpy(b7b3a83273496486).( p->liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr., tmpch ); |
| 504 | p->typecxx . . $ $anonymous_type_7dedf4dea87650a7_0#type.=0; |
| 505 | while ((strcmpcxx . . $ strcmp(5ae29d726ae57f88).(p->liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr.,list1[p->typecxx . . $ $anonymous_type_7dedf4dea87650a7_0#type.])!=0)&&(p->typecxx . . $ $anonymous_type_7dedf4dea87650a7_0#type.<10)) p->typecxx . . $ $anonymous_type_7dedf4dea87650a7_0#type.++; |
| 506 | break; |
| 507 | case 1: |
| 508 | tmpf=map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(*((double*)parm), 0.0, 50); |
| 509 | if (tmpf!=p->sizecxx . . $ $anonymous_type_7dedf4dea87650a7_0#size.) chg=1; |
| 510 | p->sizecxx . . $ $anonymous_type_7dedf4dea87650a7_0#size.=tmpf; |
| 511 | break; |
| 512 | } |
| 513 | |
| 514 | if (chg==0) return; |
| 515 | |
| 516 | } |
| 517 | |
| 518 | //-------------------------------------------------- |
| 519 | 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) |
| 520 | { |
| 521 | instcxx . . $ inst# *p; |
| 522 | |
| 523 | p=(instcxx . . $ inst#*)instance; |
| 524 | |
| 525 | switch(param_index) |
| 526 | { |
| 527 | case 0: //(string based list) |
| 528 | *((char**)param) = p->liststrcxx . . $ $anonymous_type_7dedf4dea87650a7_0#liststr.; |
| 529 | break; |
| 530 | case 1: |
| 531 | *((double*)param)=map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(p->sizecxx . . $ $anonymous_type_7dedf4dea87650a7_0#size., 0.0, 50); |
| 532 | break; |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | //------------------------------------------------- |
| 537 | void f0r_updatecxx . . $ f0r_update(96cd7b27f2fca8a7).(f0r_instance_tcxx . . $ f0r_instance_t# instance, double time, const uint32_tcxx . . $ uint32_t#* inframe, uint32_tcxx . . $ uint32_t#* outframe) |
| 538 | { |
| 539 | instcxx . . $ inst# *in; |
| 540 | |
| 541 | assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance); |
| 542 | in=(instcxx . . $ inst#*)instance; |
| 543 | uint32_tcxx . . $ uint32_t# *tmpp; |
| 544 | uint8_tcxx . . $ uint8_t# *cin,*cout; |
| 545 | int step,i; |
| 546 | |
| 547 | memcpycxx . . $ memcpy(cc817cb175f282d).(in->ppfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#ppf., inframe, 4*in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.*in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.); |
| 548 | tmpp=in->nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf.; |
| 549 | in->nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf.=in->ppfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#ppf.; |
| 550 | in->ppfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#ppf.=in->pfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#pf.; |
| 551 | in->pfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#pf.=in->cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf.; |
| 552 | in->cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf.=in->nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf.; |
| 553 | in->nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf.=tmpp; |
| 554 | |
| 555 | cin=(uint8_tcxx . . $ uint8_t#*)inframe; |
| 556 | cout=(uint8_tcxx . . $ uint8_t#*)outframe; |
| 557 | |
| 558 | switch (in->typecxx . . $ $anonymous_type_7dedf4dea87650a7_0#type.) |
| 559 | { |
| 560 | case 0: |
| 561 | cross5cxx . . $ cross5(4441e435cc27af0f).(inframe, in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 562 | break; |
| 563 | case 1: |
| 564 | sq3x3cxx . . $ sq3x3(4441e435cc27af0f).(inframe, in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 565 | break; |
| 566 | case 2: |
| 567 | bilevelcxx . . $ bilevel(4441e435cc27af0f).(inframe, in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 568 | break; |
| 569 | case 3: |
| 570 | dia3x3cxx . . $ dia3x3(4441e435cc27af0f).(inframe, in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 571 | break; |
| 572 | case 4: |
| 573 | sq5x5cxx . . $ sq5x5(4441e435cc27af0f).(inframe, in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 574 | break; |
| 575 | case 5: |
| 576 | temp3cxx . . $ temp3(6c037a616f2c86e8).(in->cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf., in->nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf., in->nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf., in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 577 | break; |
| 578 | case 6: |
| 579 | temp5cxx . . $ temp5(d0ccb6d87d194896).(in->ppfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#ppf., in->pfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#pf., in->cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf., in->nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf., in->nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf., in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 580 | break; |
| 581 | case 7: |
| 582 | ArceBIcxx . . $ ArceBI(6c037a616f2c86e8).(in->cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf., in->nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf., in->nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf., in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 583 | break; |
| 584 | case 8: |
| 585 | ml3dcxx . . $ ml3d(6c037a616f2c86e8).(in->cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf., in->nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf., in->nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf., in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 586 | break; |
| 587 | case 9: |
| 588 | ml3dexcxx . . $ ml3dex(6c037a616f2c86e8).(in->cfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#cf., in->nfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nf., in->nnfcxx . . $ $anonymous_type_7dedf4dea87650a7_0#nnf., in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w., in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h., outframe); |
| 589 | break; |
| 590 | case 10: |
| 591 | //varsize |
| 592 | step=in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.*4; |
| 593 | ctmfcxx . . $ ctmf(819d8c7cec1a7d9c).(cin,cout,in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w.,in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.,step,step,in->sizecxx . . $ $anonymous_type_7dedf4dea87650a7_0#size.,4,512*1024); |
| 594 | break; |
| 595 | default: |
| 596 | break; |
| 597 | } |
| 598 | //COPY ALPHA |
| 599 | for (i = 3; i < 4 * in->wcxx . . $ $anonymous_type_7dedf4dea87650a7_0#w. * in->hcxx . . $ $anonymous_type_7dedf4dea87650a7_0#h.; i += 4) |
| 600 | cout[i]=cin[i]; |
| 601 | |
| 602 | } |
| 603 |