annotate libmpcodecs/vf_hqdn3d.c @ 20984:41773d188756

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