Mercurial > mplayer.hg
annotate libmpcodecs/vf_hqdn3d.c @ 26236:34cbcf7b4c80
better wording
author | ptt |
---|---|
date | Fri, 21 Mar 2008 19:16:44 +0000 |
parents | 00fff9a3b735 |
children | 82601a38e2a7 |
rev | line source |
---|---|
9441 | 1 /* |
2 Copyright (C) 2003 Daniel Moreno <comac@comac.darktech.org> | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2 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 General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software | |
17367
401b440a6d76
Update licensing information: The FSF changed postal address.
diego
parents:
17012
diff
changeset
|
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
9441 | 17 */ |
18 | |
19 #include <stdio.h> | |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 #include <inttypes.h> | |
23 #include <math.h> | |
24 | |
17012 | 25 #include "config.h" |
26 #include "mp_msg.h" | |
9441 | 27 |
28 #ifdef HAVE_MALLOC_H | |
29 #include <malloc.h> | |
30 #endif | |
31 | |
32 #include "img_format.h" | |
33 #include "mp_image.h" | |
34 #include "vf.h" | |
35 | |
36 #define PARAM1_DEFAULT 4.0 | |
37 #define PARAM2_DEFAULT 3.0 | |
38 #define PARAM3_DEFAULT 6.0 | |
39 | |
40 //===========================================================================// | |
41 | |
42 struct vf_priv_s { | |
43 int Coefs[4][512*16]; | |
44 unsigned int *Line; | |
45 unsigned short *Frame[3]; | |
46 }; | |
47 | |
48 | |
49 /***************************************************************************/ | |
50 | |
51 static void uninit(struct vf_instance_s* vf){ | |
52 if(vf->priv->Line){free(vf->priv->Line);vf->priv->Line=NULL;} | |
53 if(vf->priv->Frame[0]){free(vf->priv->Frame[0]);vf->priv->Frame[0]=NULL;} | |
54 if(vf->priv->Frame[1]){free(vf->priv->Frame[1]);vf->priv->Frame[1]=NULL;} | |
55 if(vf->priv->Frame[2]){free(vf->priv->Frame[2]);vf->priv->Frame[2]=NULL;} | |
56 } | |
57 | |
58 static int config(struct vf_instance_s* vf, | |
59 int width, int height, int d_width, int d_height, | |
60 unsigned int flags, unsigned int outfmt){ | |
61 | |
62 uninit(vf); | |
63 vf->priv->Line = malloc(width*sizeof(int)); | |
64 | |
65 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); | |
66 } | |
67 | |
68 static inline unsigned int LowPassMul(unsigned int PrevMul, unsigned int CurrMul, int* Coef){ | |
69 // int dMul= (PrevMul&0xFFFFFF)-(CurrMul&0xFFFFFF); | |
70 int dMul= PrevMul-CurrMul; | |
17965 | 71 int d=((dMul+0x10007FF)>>12); |
9441 | 72 return CurrMul + Coef[d]; |
73 } | |
74 | |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
75 static void deNoiseTemporal( |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
76 unsigned char *Frame, // mpi->planes[x] |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
77 unsigned char *FrameDest, // dmpi->planes[x] |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
78 unsigned short *FrameAnt, |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
79 int W, int H, int sStride, int dStride, |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
80 int *Temporal) |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
81 { |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
82 int X, Y; |
17965 | 83 unsigned int PixelDst; |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
84 |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
85 for (Y = 0; Y < H; Y++){ |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
86 for (X = 0; X < W; X++){ |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
87 PixelDst = LowPassMul(FrameAnt[X]<<8, Frame[X]<<16, Temporal); |
17965 | 88 FrameAnt[X] = ((PixelDst+0x1000007F)>>8); |
89 FrameDest[X]= ((PixelDst+0x10007FFF)>>16); | |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
90 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
91 Frame += sStride; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
92 FrameDest += dStride; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
93 FrameAnt += W; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
94 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
95 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
96 |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
97 static void deNoiseSpacial( |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
98 unsigned char *Frame, // mpi->planes[x] |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
99 unsigned char *FrameDest, // dmpi->planes[x] |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
100 unsigned int *LineAnt, // vf->priv->Line (width bytes) |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
101 int W, int H, int sStride, int dStride, |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
102 int *Horizontal, int *Vertical) |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
103 { |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
104 int X, Y; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
105 int sLineOffs = 0, dLineOffs = 0; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
106 unsigned int PixelAnt; |
17965 | 107 unsigned int PixelDst; |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
108 |
16684 | 109 /* First pixel has no left nor top neighbor. */ |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
110 PixelDst = LineAnt[0] = PixelAnt = Frame[0]<<16; |
17965 | 111 FrameDest[0]= ((PixelDst+0x10007FFF)>>16); |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
112 |
16699
0cb2e995edd1
Typo fix, patch by Ismail D«Ónmez <ismail AH kde POIS org POIS tr>
gpoirier
parents:
16684
diff
changeset
|
113 /* First line has no top neighbor, only left. */ |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
114 for (X = 1; X < W; X++){ |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
115 PixelDst = LineAnt[X] = LowPassMul(PixelAnt, Frame[X]<<16, Horizontal); |
17965 | 116 FrameDest[X]= ((PixelDst+0x10007FFF)>>16); |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
117 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
118 |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
119 for (Y = 1; Y < H; Y++){ |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
120 unsigned int PixelAnt; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
121 sLineOffs += sStride, dLineOffs += dStride; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
122 /* First pixel on each line doesn't have previous pixel */ |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
123 PixelAnt = Frame[sLineOffs]<<16; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
124 PixelDst = LineAnt[0] = LowPassMul(LineAnt[0], PixelAnt, Vertical); |
17965 | 125 FrameDest[dLineOffs]= ((PixelDst+0x10007FFF)>>16); |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
126 |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
127 for (X = 1; X < W; X++){ |
17965 | 128 unsigned int PixelDst; |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
129 /* The rest are normal */ |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
130 PixelAnt = LowPassMul(PixelAnt, Frame[sLineOffs+X]<<16, Horizontal); |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
131 PixelDst = LineAnt[X] = LowPassMul(LineAnt[X], PixelAnt, Vertical); |
17965 | 132 FrameDest[dLineOffs+X]= ((PixelDst+0x10007FFF)>>16); |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
133 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
134 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
135 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
136 |
9441 | 137 static void deNoise(unsigned char *Frame, // mpi->planes[x] |
138 unsigned char *FrameDest, // dmpi->planes[x] | |
139 unsigned int *LineAnt, // vf->priv->Line (width bytes) | |
140 unsigned short **FrameAntPtr, | |
141 int W, int H, int sStride, int dStride, | |
142 int *Horizontal, int *Vertical, int *Temporal) | |
143 { | |
144 int X, Y; | |
145 int sLineOffs = 0, dLineOffs = 0; | |
146 unsigned int PixelAnt; | |
17965 | 147 unsigned int PixelDst; |
9441 | 148 unsigned short* FrameAnt=(*FrameAntPtr); |
149 | |
150 if(!FrameAnt){ | |
151 (*FrameAntPtr)=FrameAnt=malloc(W*H*sizeof(unsigned short)); | |
152 for (Y = 0; Y < H; Y++){ | |
153 unsigned short* dst=&FrameAnt[Y*W]; | |
154 unsigned char* src=Frame+Y*sStride; | |
155 for (X = 0; X < W; X++) dst[X]=src[X]<<8; | |
156 } | |
157 } | |
158 | |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
159 if(!Horizontal[0] && !Vertical[0]){ |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
160 deNoiseTemporal(Frame, FrameDest, FrameAnt, |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
161 W, H, sStride, dStride, Temporal); |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
162 return; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
163 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
164 if(!Temporal[0]){ |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
165 deNoiseSpacial(Frame, FrameDest, LineAnt, |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
166 W, H, sStride, dStride, Horizontal, Vertical); |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
167 return; |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
168 } |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
169 |
16684 | 170 /* First pixel has no left nor top neighbor. Only previous frame */ |
9441 | 171 LineAnt[0] = PixelAnt = Frame[0]<<16; |
172 PixelDst = LowPassMul(FrameAnt[0]<<8, PixelAnt, Temporal); | |
17965 | 173 FrameAnt[0] = ((PixelDst+0x1000007F)>>8); |
174 FrameDest[0]= ((PixelDst+0x10007FFF)>>16); | |
9441 | 175 |
16699
0cb2e995edd1
Typo fix, patch by Ismail D«Ónmez <ismail AH kde POIS org POIS tr>
gpoirier
parents:
16684
diff
changeset
|
176 /* First line has no top neighbor. Only left one for each pixel and |
9441 | 177 * last frame */ |
178 for (X = 1; X < W; X++){ | |
179 LineAnt[X] = PixelAnt = LowPassMul(PixelAnt, Frame[X]<<16, Horizontal); | |
180 PixelDst = LowPassMul(FrameAnt[X]<<8, PixelAnt, Temporal); | |
17965 | 181 FrameAnt[X] = ((PixelDst+0x1000007F)>>8); |
182 FrameDest[X]= ((PixelDst+0x10007FFF)>>16); | |
9441 | 183 } |
184 | |
185 for (Y = 1; Y < H; Y++){ | |
186 unsigned int PixelAnt; | |
187 unsigned short* LinePrev=&FrameAnt[Y*W]; | |
188 sLineOffs += sStride, dLineOffs += dStride; | |
189 /* First pixel on each line doesn't have previous pixel */ | |
190 PixelAnt = Frame[sLineOffs]<<16; | |
191 LineAnt[0] = LowPassMul(LineAnt[0], PixelAnt, Vertical); | |
192 PixelDst = LowPassMul(LinePrev[0]<<8, LineAnt[0], Temporal); | |
17965 | 193 LinePrev[0] = ((PixelDst+0x1000007F)>>8); |
194 FrameDest[dLineOffs]= ((PixelDst+0x10007FFF)>>16); | |
9441 | 195 |
196 for (X = 1; X < W; X++){ | |
17965 | 197 unsigned int PixelDst; |
9441 | 198 /* The rest are normal */ |
199 PixelAnt = LowPassMul(PixelAnt, Frame[sLineOffs+X]<<16, Horizontal); | |
200 LineAnt[X] = LowPassMul(LineAnt[X], PixelAnt, Vertical); | |
201 PixelDst = LowPassMul(LinePrev[X]<<8, LineAnt[X], Temporal); | |
17965 | 202 LinePrev[X] = ((PixelDst+0x1000007F)>>8); |
203 FrameDest[dLineOffs+X]= ((PixelDst+0x10007FFF)>>16); | |
9441 | 204 } |
205 } | |
206 } | |
207 | |
208 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17367
diff
changeset
|
209 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
9441 | 210 int cw= mpi->w >> mpi->chroma_x_shift; |
211 int ch= mpi->h >> mpi->chroma_y_shift; | |
212 int W = mpi->w, H = mpi->h; | |
213 | |
214 mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
215 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
216 mpi->w,mpi->h); | |
217 | |
218 if(!dmpi) return 0; | |
219 | |
220 deNoise(mpi->planes[0], dmpi->planes[0], | |
221 vf->priv->Line, &vf->priv->Frame[0], W, H, | |
222 mpi->stride[0], dmpi->stride[0], | |
223 vf->priv->Coefs[0], | |
224 vf->priv->Coefs[0], | |
225 vf->priv->Coefs[1]); | |
226 deNoise(mpi->planes[1], dmpi->planes[1], | |
227 vf->priv->Line, &vf->priv->Frame[1], cw, ch, | |
228 mpi->stride[1], dmpi->stride[1], | |
229 vf->priv->Coefs[2], | |
230 vf->priv->Coefs[2], | |
231 vf->priv->Coefs[3]); | |
232 deNoise(mpi->planes[2], dmpi->planes[2], | |
233 vf->priv->Line, &vf->priv->Frame[2], cw, ch, | |
234 mpi->stride[2], dmpi->stride[2], | |
235 vf->priv->Coefs[2], | |
236 vf->priv->Coefs[2], | |
237 vf->priv->Coefs[3]); | |
238 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17367
diff
changeset
|
239 return vf_next_put_image(vf,dmpi, pts); |
9441 | 240 } |
241 | |
242 //===========================================================================// | |
243 | |
244 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
245 switch(fmt) | |
246 { | |
247 case IMGFMT_YV12: | |
248 case IMGFMT_I420: | |
249 case IMGFMT_IYUV: | |
250 case IMGFMT_YVU9: | |
251 case IMGFMT_444P: | |
252 case IMGFMT_422P: | |
253 case IMGFMT_411P: | |
254 return vf_next_query_format(vf, fmt); | |
255 } | |
256 return 0; | |
257 } | |
258 | |
259 | |
260 #define ABS(A) ( (A) > 0 ? (A) : -(A) ) | |
261 | |
262 static void PrecalcCoefs(int *Ct, double Dist25) | |
263 { | |
264 int i; | |
265 double Gamma, Simil, C; | |
266 | |
267 Gamma = log(0.25) / log(1.0 - Dist25/255.0 - 0.00001); | |
268 | |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
269 for (i = -255*16; i <= 255*16; i++) |
9441 | 270 { |
271 Simil = 1.0 - ABS(i) / (16*255.0); | |
272 C = pow(Simil, Gamma) * 65536.0 * (double)i / 16.0; | |
273 Ct[16*256+i] = (C<0) ? (C-0.5) : (C+0.5); | |
274 } | |
16682
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
275 |
5f98b89262c4
hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents:
9593
diff
changeset
|
276 Ct[0] = (Dist25 != 0); |
9441 | 277 } |
278 | |
279 | |
280 static int open(vf_instance_t *vf, char* args){ | |
281 double LumSpac, LumTmp, ChromSpac, ChromTmp; | |
282 double Param1, Param2, Param3, Param4; | |
283 | |
284 vf->config=config; | |
285 vf->put_image=put_image; | |
286 vf->query_format=query_format; | |
287 vf->uninit=uninit; | |
288 vf->priv=malloc(sizeof(struct vf_priv_s)); | |
289 memset(vf->priv, 0, sizeof(struct vf_priv_s)); | |
290 | |
291 if (args) | |
292 { | |
293 switch(sscanf(args, "%lf:%lf:%lf:%lf", | |
294 &Param1, &Param2, &Param3, &Param4 | |
295 )) | |
296 { | |
297 case 0: | |
298 LumSpac = PARAM1_DEFAULT; | |
299 LumTmp = PARAM3_DEFAULT; | |
300 | |
301 ChromSpac = PARAM2_DEFAULT; | |
302 ChromTmp = LumTmp * ChromSpac / LumSpac; | |
303 break; | |
304 | |
305 case 1: | |
306 LumSpac = Param1; | |
307 LumTmp = PARAM3_DEFAULT * Param1 / PARAM1_DEFAULT; | |
308 | |
309 ChromSpac = PARAM2_DEFAULT * Param1 / PARAM1_DEFAULT; | |
310 ChromTmp = LumTmp * ChromSpac / LumSpac; | |
311 break; | |
312 | |
313 case 2: | |
314 LumSpac = Param1; | |
315 LumTmp = PARAM3_DEFAULT * Param1 / PARAM1_DEFAULT; | |
316 | |
317 ChromSpac = Param2; | |
318 ChromTmp = LumTmp * ChromSpac / LumSpac; | |
319 break; | |
320 | |
321 case 3: | |
322 LumSpac = Param1; | |
323 LumTmp = Param3; | |
324 | |
325 ChromSpac = Param2; | |
326 ChromTmp = LumTmp * ChromSpac / LumSpac; | |
327 break; | |
328 | |
329 case 4: | |
330 LumSpac = Param1; | |
331 LumTmp = Param3; | |
332 | |
333 ChromSpac = Param2; | |
334 ChromTmp = Param4; | |
335 break; | |
336 | |
337 default: | |
338 LumSpac = PARAM1_DEFAULT; | |
339 LumTmp = PARAM3_DEFAULT; | |
340 | |
341 ChromSpac = PARAM2_DEFAULT; | |
342 ChromTmp = LumTmp * ChromSpac / LumSpac; | |
343 } | |
344 } | |
345 else | |
346 { | |
347 LumSpac = PARAM1_DEFAULT; | |
348 LumTmp = PARAM3_DEFAULT; | |
349 | |
350 ChromSpac = PARAM2_DEFAULT; | |
351 ChromTmp = LumTmp * ChromSpac / LumSpac; | |
352 } | |
353 | |
354 PrecalcCoefs(vf->priv->Coefs[0], LumSpac); | |
355 PrecalcCoefs(vf->priv->Coefs[1], LumTmp); | |
356 PrecalcCoefs(vf->priv->Coefs[2], ChromSpac); | |
357 PrecalcCoefs(vf->priv->Coefs[3], ChromTmp); | |
358 | |
359 return 1; | |
360 } | |
361 | |
25221 | 362 const vf_info_t vf_info_hqdn3d = { |
9441 | 363 "High Quality 3D Denoiser", |
364 "hqdn3d", | |
365 "Daniel Moreno & A'rpi", | |
366 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9441
diff
changeset
|
367 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9441
diff
changeset
|
368 NULL |
9441 | 369 }; |
370 | |
371 //===========================================================================// |