Debian Codegraph @

src/filter/defish0r/defish0r.c

raw symbols SCIP
1 /* defish0r.c
2
3 * Copyright (C) 2010 Marko Cebokli http://lea.hamradio.si/~s57uuu
4 * This file is a Frei0r plugin.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21
22
23 //compile: gcc -Wall -std=c99 -c -fPIC defish0r.c -o defish0r.o
24
25 //link: gcc -lm -shared -o defish0r.so defish0r.o
26
27 //skaliranje za center=1 se ne dela!!!!
28
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <math.h>
32
33 #include <frei0r.h>
34
35 #include "interp.h"
36
37
38 double PI=3.14159265358979;
39
40 //add simplified 'Elestic Scale' to fix superview
41 float stretchWidth(int width, int widthCentre, float currentXPos, float stretchFactor)
42 {
43 double ratio, lowerWeight = 0.0, higherWeight = 0.0, linearRatio;
44 unsigned int lengthSection;
45 float relativeXPos = 0.0f;
46
47 //midline?
48 if (currentXPos < (float)widthCentre)
49 {
50 lengthSection = widthCentre - 1;
51 linearRatio = (double) ( currentXPos ) / lengthSection;
52 ratio = sin(linearRatio * PI - PI) * stretchFactor + linearRatio;
53 }
54 else
55 {
56 lengthSection = width - widthCentre - 1;
57 linearRatio = (double) ( currentXPos - widthCentre ) / lengthSection;
58 ratio = sin(linearRatio * PI) * stretchFactor + linearRatio;
59 }
60 ratio = ratio <= 0.0 ? 0.0 : ratio;
61
62 relativeXPos = (float) ( ratio * lengthSection );
63
64 if (currentXPos < (float)widthCentre)
65 relativeXPos -= currentXPos;
66 else
67 relativeXPos -= ( currentXPos - widthCentre );
68
69 return relativeXPos;
70 }
71
72
73 //---------------------------------------------------------
74 // r = 0...1 izhod = 0...maxr
75 //ta funkcija da popacenje v odvisnosti od r
76 float fish(int n, float r, float f)
77 {
78 float rr,ff;
79
80 //printf("ff=%f\n",ff);
81 switch (n)
82 {
83 case 0: //equidistant
84 ff=f*2.0f/(float)PI;
85 rr=tanf(r/ff);
86 break;
87 case 1: //ortographic
88 ff=r/f;
89 if (ff>1.0)
90 rr=-1.0;
91 else
92 rr=tanf(asinf(ff));
93 break;
94 case 2: //equiarea
95 ff=r/2.0f/f;
96 if (ff>1.0f)
97 rr=-1.0f;
98 else
99 rr=tanf(2.0f*asinf(r/2.0f/f));
100 break;
101 case 3: //stereographic
102 ff=f*2.0f/(float)PI;
103 rr=tanf(2.0f*atanf(r/2.0f/ff));
104 break;
105 default:
106 // printf("Neznana fishitvena funkcija %d\n",n);
107 break;
108 }
109 return rr;
110 }
111
112 //---------------------------------------------------------
113 //ta funkcija da popacenje v odvisnosti od r
114 // r = 0...1 izhod = 0...1
115 float defish(int n, float r, float f, float mr)
116 {
117 float rr;
118
119 switch (n)
120 {
121 case 0: //equidistant
122 rr=f*2.0f/(float)PI*atanf(r*mr);
123 break;
124 case 1: //ortographic
125 rr=f*sinf(atanf(r*mr));
126 break;
127 case 2: //equiarea
128 rr=2.0f*f*sinf(atanf(r*mr)/2.0f);
129 break;
130 case 3: //stereographic
131 rr=f*4.0f/(float)PI*tanf(atanf(r*mr)/2.0f);
132 break;
133 default:
134 // printf("Neznana fishitvena funkcija %d\n",n);
135 break;
136 }
137 return rr;
138 }
139
140 //----------------------------------------------------------------
141 //nafila array map s polozaji pikslov
142 //locena funkcija, da jo poklicem samo enkrat na zacetku,
143 //array map[] potem uporablja funkcija remap()
144 //tako ni treba za vsak frame znova racunat teh sinusov itd...
145 //wi,hi,wo ho = input.output image width/height
146 //n = 0..3 function select
147 //f = focal ratio (amount of distortion)
148 //scal = scaling factor
149 //pari, paro = pixel aspect ratio (input / output)
150 //dx, dy offset on input (for non-cosited chroma subsampling)
151 void fishmap(int wi, int hi, int wo, int ho, int n, float f, float scal, float pari, float paro, float dx, float dy, float *map
152 , float stretchFactor, float yScale)
153 {
154 float rmax,maxr,r,kot,x,y,imax;
155 int i, j, ww;
156 float ii,jj,sc;
157 int wiMid = wi/2;
158 int hiMid = hi/2;
159
160 rmax=hypotf(ho/2.0f,wo/2.0f*paro);
161 maxr=fish(n,1.0,f);
162 imax=hypotf(hi/2.0f,wi/2.0f*pari);
163 sc=imax/maxr;
164
165 //printf("Fishmap: F=%5.2f Rmax= %7.2f Maxr=%6.2f sc=%6.2f scal=%6.2f\n",f,rmax,maxr,sc,scal);
166
167 for (i=0;i<hi;i++)
168 {
169 ii=(float)(i-hiMid)*yScale; //add Y scale
170 for (j=0;j<wi;j++)
171 {
172 jj=(j-wiMid)*paro;
173 r=hypotf(ii,jj);
174 kot=atan2f(ii,jj);
175 r=fish(n,r/rmax*scal,f)*sc;
176 ww=2*(wo*i+j);
177 if (r<0.0)
178 {
179 map[ww]=-1;
180 map[ww+1]=-1;
181 }
182 else
183 {
184 x=wiMid+r*cosf(kot)/pari;
185 y=hiMid+r*sinf(kot);
186 if ((x>0)&(x<(wi-1))&(y>0)&(y<(hi-1)))
187 {
188 if (stretchFactor != 0.0f)
189 x += stretchWidth(wo, wiMid, x, stretchFactor); //add stretch
190 map[ww]=x+dx;
191 map[ww+1]=y+dy;
192 }
193 else
194 {
195 map[ww]=-1;
196 map[ww+1]=-1;
197 }
198 }
199 }
200 }
201 }
202
203
204 //----------------------------------------------------------------
205 //nafila array map s polozaji pikslov
206 //locena funkcija, da jo poklicem samo enkrat na zacetku,
207 //array map[] potem uporablja funkcija remap()
208 //tako ni treba za vsak frame znova racunat teh sinusov itd...
209 //wi,hi,wo ho = input.output image width/height
210 //n = 0..3 function select
211 //f = focal ratio (amount of distortion)
212 //scal = scaling factor
213 //pari,paro = pixel aspect ratio (input / output)
214 //dx, dy offset on input (for non-cosited chroma subsampling)
215 //lbox = letterbox
216 //stretch = dynamic stretch, convert between 4:3 and 16:9
217 //yScale = -0.5.. 0.5 change aspect ratio on y access only
218 void defishmap(int wi, int hi, int wo, int ho, int n, float f, float scal, float pari, float paro, float dx, float dy, float *map
219 , int lbox, float stretchFactor, float yScale)
220 {
221 float rmax,maxr,r,kot,x,y,imax;
222 int i,j,ww;
223 float ii,jj,sc;
224 int wiMid = wi/2;
225 int hiMid = hi/2;
226
227 rmax=hypotf(ho/2.0f,wo/2.0f*paro);
228 maxr=fish(n,1.0,f);
229 imax=hypotf(hi/2.0f,wi/2.0f*pari);
230 sc=imax/maxr;
231
232 //printf("Defishmap: F=%f rmax= %f Maxr=%f sc=%6.2f scal=%6.2f\n",f,rmax,maxr,sc,scal);
233
234 for (i=0;i<hi;i++)
235 {
236 ii = (float)(i-hiMid)*yScale; //add Y scale
237 for (j=0;j<wi;j++)
238 {
239 jj=(j-wiMid)*paro; //aspect....
240 r=hypotf(ii,jj)/scal;
241 kot=atan2f(ii,jj);
242 ww=2*(wi*i+j);
243 r=defish(n,r/sc,f,1.0)*imax;
244 if (r<0.0)
245 {
246 map[ww]=-1;
247 map[ww+1]=-1;
248 }
249 else
250 {
251 x=wiMid+r*cosf(kot)/pari;
252 y=hiMid+r*sinf(kot);
253
254 if ((x>0)&&(x<(wi-1))&&(y>0)&&(y<(hi-1)))
255 {
256 if (stretchFactor != 0.0f)
257 x += stretchWidth(wi, wiMid, x, stretchFactor); //add stretch
258
259 map[ww]=x;
260 map[ww+1]=y;
261 }
262 else
263 {
264 map[ww]=-1;
265 map[ww+1]=-1;
266 }
267 }
268 }
269 }
270
271 //crop all 4 borders
272 if (lbox)
273 { //top/bottom
274 for (i = 0; i < hi; i++)
275 {
276 ww = 2 * (wi*i + wiMid);
277 if (map[ww] <= 0)
278 {
279 for (j = 0; j < wi; j++)
280 { //clear entire row
281 ww = 2 * (wi*i + j);
282 map[ww] = -1;
283 map[ww + 1] = -1;
284 }
285 }
286 }
287 //left/right
288 for (i = 0; i < wi; i++)
289 {
290 ww = 2 * (wi*hiMid +i);
291 if (map[ww] <= 0)
292 {
293 for (j = 0; j < hi; j++)
294 { //clear entire column
295 ww = 2 * (wi*j + i);
296 map[ww] = -1;
297 map[ww + 1] = -1;
298 }
299 }
300 }
301 }
302 }
303
304 //=====================================================
305 //kao instanca frei0r
306 //w,h: image dimensions in pixels
307 //f: focal ratio
308 //dir: 0=defish 1=fish
309 //type: 0..3 equidistant, ortographic, equiarea, stereographic
310 //scal: 0..3 image to fill, keep center scale, image to fit, manu
311 //intp: 0..6 type of interpolator
312 //aspt: 0..4 aspect type square, PAL, NTSC, HDV, manual
313 //par: pixel aspect ratio
314 //lbox: 1=letterbox
315 //stretch 0..1 stretch video to fix superview distortion
316 typedef struct
317 {
318 int w;
319 int h;
320 float f;
321 int dir;
322 int type;
323 int scal;
324 int intp;
325 float mscale;
326 int aspt;
327 float mpar;
328 float par;
329 float *map;
330 int lbox;
331 float stretch;
332 float yScale;
333 interpp interpol;
334 } param;
335
336
337
338 //-------------------------------------------------------
339 interpp set_intp(param p)
340 {
341 switch (p.intp) //katero interpolacijo bo uporabil
342 {
343 // case -1:return interpNNpr_b; //nearest neighbor+print
344 case 0: return interpNN_b32; //nearest neighbor
345 case 1: return interpBL_b32; //bilinear
346 case 2: return interpBC_b32; //bicubic smooth
347 case 3: return interpBC2_b32; //bicibic sharp
348 case 4: return interpSP4_b32; //spline 4x4
349 case 5: return interpSP6_b32; //spline 6x6
350 case 6: return interpSC16_b32; //lanczos 8x8
351 default: return NULL;
352 }
353 }
354
355 //--------------------------------------------------------
356 void make_map(param p)
357 {
358 float rmax,maxr,imax,fscal,dscal;
359
360 rmax=hypotf(p.h/2.0,p.w/2.0*p.par);
361 maxr=fish(p.type,1.0,p.f);
362 imax=hypotf(p.h/2.0,p.w/2.0*p.par);
363
364 if (p.dir==0) //defish
365 {
366 switch (p.scal)
367 {
368 case 0: //fill
369 dscal=maxr*p.h/2.0/rmax/fish(p.type,p.h/2.0/rmax,p.f);
370 break;
371 case 1: //keep
372 dscal=maxr*p.f;
373 if ((p.type==0)||(p.type==3)) dscal=dscal/PI*2.0;break;
374 case 2: //fit
375 dscal=1.0; break;
376 case 3: //manual
377 dscal=p.mscale; break;
378 }
379 defishmap(p.w ,p.h ,p.w ,p.h, p.type, p.f, dscal, p.par, p.par, 0.0, 0.0, p.map, p.lbox, p.stretch, p.yScale);
380 }
381 else //fish
382 {
383 switch (p.scal)
384 {
385 case 0: //fill
386 fscal=1.0;break;
387 case 1: //keep
388 fscal=maxr*p.f;
389 if ((p.type==0)||(p.type==3)) fscal=fscal/PI*2.0;
390 break;
391 case 2: //fit
392 fscal=2.0*defish(p.type,p.h/2.0*maxr/imax,p.f,1.0)/p.h*rmax;
393 break;
394 case 3: //manual
395 fscal=1.0/p.mscale; break;
396 }
397 fishmap(p.w, p.h, p.w ,p.h, p.type, p.f, fscal, p.par, p.par, 0.0, 0.0, p.map, p.stretch, p.yScale);
398 }
399
400 }
401
402 //*********************************************************
403 // OBVEZNE FREI0R FUNKCIJE
404
405 //-----------------------------------------------
406 int f0r_init()
407 {
408 return 1;
409 }
410
411 //------------------------------------------------
412 void f0r_deinit()
413 {
414 }
415
416 //-----------------------------------------------
417 void f0r_get_plugin_info(f0r_plugin_info_t* info)
418 {
419
420 info->name="Defish0r";
421 info->author="Marko Cebokli";
422 info->plugin_type=F0R_PLUGIN_TYPE_FILTER;
423 info->color_model=F0R_COLOR_MODEL_RGBA8888;
424 info->frei0r_version=FREI0R_MAJOR_VERSION;
425 info->major_version=0;
426 info->minor_version=4;
427 info->num_params=11;
428 info->explanation="Non rectilinear lens mappings";
429 }
430
431 //--------------------------------------------------
432 void f0r_get_param_info(f0r_param_info_t* info, int param_index)
433 {
434 switch(param_index)
435 {
436 case 0:
437 info->name = "Amount";
438 info->type = F0R_PARAM_DOUBLE;
439 info->explanation = "Focal Ratio";
440 break;
441 case 1:
442 info->name = "DeFish";
443 info->type = F0R_PARAM_BOOL;
444 info->explanation = "Fish or Defish";
445 break;
446 case 2:
447 info->name = "Type";
448 info->type = F0R_PARAM_DOUBLE;
449 info->explanation = "Mapping function";
450 break;
451 case 3:
452 info->name = "Scaling";
453 info->type = F0R_PARAM_DOUBLE;
454 info->explanation = "Scaling method";
455 break;
456 case 4:
457 info->name = "Manual Scale";
458 info->type = F0R_PARAM_DOUBLE;
459 info->explanation = "Manual Scale";
460 break;
461 case 5:
462 info->name = "Interpolator";
463 info->type = F0R_PARAM_DOUBLE;
464 info->explanation = "Quality of interpolation";
465 break;
466 case 6:
467 info->name = "Aspect type";
468 info->type = F0R_PARAM_DOUBLE;
469 info->explanation = "Pixel aspect ratio presets";
470 break;
471 case 7:
472 info->name = "Manual Aspect";
473 info->type = F0R_PARAM_DOUBLE;
474 info->explanation = "Manual Pixel Aspect ratio";
475 break;
476 case 8:
477 info->name = "Crop";
478 info->type = F0R_PARAM_BOOL;
479 info->explanation = "Straighten all edges of video frame";
480 break;
481 case 9:
482 info->name = "Non-Linear scale";
483 info->type = F0R_PARAM_DOUBLE;
484 info->explanation = "Fix camera scaling between 4:3 and 16:9";
485 break;
486 case 10:
487 info->name = "Y Scale";
488 info->type = F0R_PARAM_DOUBLE;
489 info->explanation = "Scale Y to affect aspect ratio";
490 break;
491 }
492
493 }
494
495 //--------------------------------------------------------
496 //kao constructor za frei0r
497 f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
498 {
499 param *p;
500
501 p=(param*)calloc(1, sizeof(param));
502
503 p->w=width;
504 p->h=height;
505 p->f=20.0; //defaults (not used??)
506 p->dir=1;
507 p->type=2;
508 p->scal=2;
509 p->intp=1;
510 p->mscale=1.0;
511 p->aspt=0; //square pixels
512 p->par=1.0; //square pixels
513 p->mpar=1.0;
514 p->lbox=0; //letterbox
515 p->stretch = 0.0f; //dynamic stretch
516 p->yScale = 1.0f; //separate Y stretch
517
518 p->map=(float*)calloc(1, sizeof(float)*(p->w*p->h*2+2));
519 p->interpol=set_intp(*p);
520
521 make_map(*p);
522
523 //printf("Construct, w=%d h=%d\n",width,height);
524
525 return (f0r_instance_t)p;
526 }
527
528 //---------------------------------------------------
529 void f0r_destruct(f0r_instance_t instance)
530 {
531 param *p;
532 p=(param*)instance;
533
534 free(p->map);
535 free(instance);
536 }
537
538 //----------------------------------------------------
539 //not used in frei0r plugin
540 void change_param(param *p, int w, int h, float f, int dir, int type, int scal, int intp)
541 {
542 p->f=f;
543 p->dir=dir;
544 p->type=type;
545 p->scal=scal;
546 p->intp=intp;
547
548 if ((w!=p->w)||(h!=p->h))
549 {
550 free(p->map);
551 p->map=(float*)calloc(1, sizeof(float)*(w*h*2+2));
552 p->w=w;
553 p->h=h;
554 }
555
556 p->interpol=set_intp(*p);
557 make_map(*p);
558 }
559
560 //-----------------------------------------------------
561 void print_param(param p)
562 //not used in frei0r plugin
563 {
564 printf("Param: w=%d h=%d f=%f dir=%d",p.w, p.h, p.f, p.dir);
565 printf(" type=%d scal=%d intp=%d",p.type, p.scal, p.intp);
566 printf(" mscale=%f par=%f mpar=%f\n",p.mscale, p.par, p.mpar);
567 }
568
569 //------------------------------------------------------
570 //computes x to the power p
571 //only for positive x
572 float pwr(float x, float p)
573 {
574 if (x<=0) return 0;
575 //printf("exp(%f)=%f\n",x,expf(p*logf(x)));
576 return expf(p*logf(x));
577 }
578
579 //-----------------------------------------------------
580 //stretch [0...1] to parameter range [min...max] logarithmic
581 //min and max must be positive!
582 float map_value_forward_log(double v, float min, float max)
583 {
584 float sr,k;
585
586 sr=sqrtf(min*max);
587 k=2.0*log(max/sr);
588 return sr*expf(k*(v-0.5));
589 }
590
591 //-----------------------------------------------------
592 //collapse from parameter range [min...max] to [0...1] logarithmic
593 //min and max must be positive!
594 double map_value_backward_log(float v, float min, float max)
595 {
596 float sr,k;
597
598 sr=sqrtf(min*max);
599 k=2.0*log(max/sr);
600 return logf(v/sr)/k+0.5;
601 }
602
603 //-----------------------------------------------------
604 //stretch [0...1] to parameter range [min...max] linear
605 float map_value_forward(double v, float min, float max)
606 {
607 return min+(max-min)*v;
608 }
609
610 //-----------------------------------------------------
611 //collapse from parameter range [min...max] to [0...1] linear
612 double map_value_backward(float v, float min, float max)
613 {
614 return (v-min)/(max-min);
615 }
616
617 //-----------------------------------------------------
618 //smisele vrednosti za parameter f: (za fish)
619 // tip 0: (0.3) 1.001...10; tip 1: 1.000...10
620 // tip 2: (0.5) 0.75...10.0 tip 3: (0.1) 0.78...10
621 //za defish:
622 // tip 0: 0.1...10 tip 1: 1.0...10
623 // tip 2: 0.5...10 tip 3: (0.1) 0.5...10
624 void f0r_set_param_value(f0r_instance_t instance, f0r_param_t parm, int param_index)
625 {
626 param *p;
627 int chg,tmpi;
628 float tmpf;
629
630 p=(param*)instance;
631
632 //printf("set parm: index=%d, value=%f\n",param_index,*(float*)parm);
633 chg=0;
634 switch(param_index)
635 {
636 case 0: //f
637 tmpf=pwr(*((double*)parm),1.0/5.0);
638 // tmpf=map_value_forward(*((double*)parm), 10.0, 0.1);
639 tmpf=map_value_forward(tmpf, 20.0, 0.1);
640 if (p->f != tmpf) chg=1;
641 p->f=tmpf;
642 break;
643 case 1: //fish
644 tmpi=map_value_forward(*((double*)parm), 1.0, 0.0);//BOOL!!
645 if (p->dir != tmpi) chg=1;
646 p->dir=tmpi;
647 break;
648 case 2: //type
649 tmpi=map_value_forward(*((double*)parm), 0.0, 3.999);
650 if (p->type != tmpi) chg=1;
651 p->type=tmpi;
652 break;
653 case 3: //scaling
654 tmpi=map_value_forward(*((double*)parm), 0.0, 3.999);
655 if (p->scal != tmpi) chg=1;
656 p->scal=tmpi;
657 break;
658 case 4: //manual scale
659 tmpf=map_value_forward_log(*((double*)parm), 0.01, 100.0);
660 if (p->mscale != tmpf) chg=1;
661 p->mscale=tmpf;
662 break;
663 case 5: //interpolator
664 tmpi=map_value_forward(*((double*)parm), 0.0, 6.999);
665 if (p->intp != tmpi) chg=1;
666 p->intp=tmpi;
667 break;
668 case 6: //aspect type
669 tmpi=map_value_forward(*((double*)parm), 0.0, 4.999);
670 if (p->aspt != tmpi) chg=1;
671 p->aspt=tmpi;
672 break;
673 case 7: //manual aspect
674 tmpf=map_value_forward_log(*((double*)parm), 0.5, 2.0);
675 if (p->mpar != tmpf) chg=1;
676 p->mpar=tmpf;
677 break;
678 case 8: //letterbox
679 tmpi=(int)map_value_forward(*((double*)parm), 0.0f, 1.0f);//BOOL!!
680 if (p->lbox != tmpi) chg=1;
681 p->lbox=tmpi;
682 break;
683 case 9: //stretch
684 tmpf=map_value_forward(*((double*)parm), -0.2f, 0.2f);
685 if (p->stretch != tmpf) chg=1;
686 p->stretch=tmpf;
687 break;
688 case 10: //Y scale
689 tmpf=map_value_forward(*((double*)parm), 1.5f, 0.5f);
690 if (p->yScale != tmpf) chg=1;
691 p->yScale=tmpf;
692 break;
693 }
694
695 if (chg!=0)
696 {
697 switch (p->aspt) //pixel aspect ratio
698 {
699 case 0: p->par=1.000;break; //square pixels
700 case 1: p->par=1.067;break; //PAL DV
701 case 2: p->par=0.889;break; //NTSC DV
702 case 3: p->par=1.333;break; //HDV
703 case 4: p->par=p->mpar;break; //manual
704 }
705 p->interpol=set_intp(*p);
706 make_map(*p);
707 }
708
709 //print_param(*p);
710 }
711
712 //--------------------------------------------------
713 void f0r_get_param_value(f0r_instance_t instance, f0r_param_t parm, int param_index)
714 {
715 param *p;
716 float tmpf;
717
718 p=(param*)instance;
719
720 switch(param_index)
721 {
722 case 0: //f
723 // *((double*)parm)=map_value_backward(p->f, 10.0, 0.1);
724 tmpf=map_value_backward(p->f, 20.0, 0.1);
725 *((double*)parm)=pwr(tmpf, 5.0);
726 break;
727 case 1: //fish
728 *((double*)parm)=map_value_backward(p->dir, 1.0, 0.0); //BOOL!!
729 break;
730 case 2: //type
731 *((double*)parm)=map_value_backward(p->type, 0.0, 3.0);
732 break;
733 case 3: //scaling
734 *((double*)parm)=map_value_backward(p->scal, 0.0, 3.0);
735 break;
736 case 4: //manual scale
737 *((double*)parm)=map_value_backward_log(p->mscale, 0.01, 100.0);
738 break;
739 case 5: //interpolator
740 *((double*)parm)=map_value_backward(p->intp, 0.0, 6.0);
741 break;
742 case 6: //aspect type
743 *((double*)parm)=map_value_backward(p->aspt, 0.0, 4.999);
744 break;
745 case 7: //manual aspect
746 *((double*)parm)=map_value_backward_log(p->mpar, 0.5, 2.0);
747 break;
748 case 8: //letterbox
749 *((double*)parm)=map_value_backward((float)p->lbox, 0.0f, 1.0f); //BOOL!!
750 break;
751 case 9: //stretch/upscale fix
752 *((double*)parm)=map_value_backward_log(p->stretch, -0.2f, 0.2f);
753 break;
754 case 10: //Y scale
755 *((double*)parm)=map_value_backward(p->yScale, 1.5f, 0.5f);
756 break;
757 }
758 }
759
760 //-------------------------------------------------
761 void f0r_update(f0r_instance_t instance, double time, const uint32_t* inframe, uint32_t* outframe)
762 {
763 param *p;
764
765 p=(param*)instance;
766
767 remap32(p->w, p->h, p->w, p->h, (unsigned char*) inframe, (unsigned char*) outframe, p->map, 0, p->interpol);
768
769 }