annotate libmpcodecs/vf_hqdn3d.c @ 36704:a37f9abea303

Add language to audio track information.
author ib
date Fri, 07 Feb 2014 19:07:39 +0000
parents 7af3e6f901fd
children
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 /*
26727
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
2 * Copyright (C) 2003 Daniel Moreno <comac@comac.darktech.org>
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
3 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
4 * This file is part of MPlayer.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
5 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
7 * it under the terms of the GNU General Public License as published by
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
9 * (at your option) any later version.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
10 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
14 * GNU General Public License for more details.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
15 *
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
16 * You should have received a copy of the GNU General Public License along
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
82601a38e2a7 Use standard license headers.
diego
parents: 25221
diff changeset
19 */
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
20
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
21 #include <stdio.h>
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
22 #include <stdlib.h>
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
23 #include <string.h>
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
24 #include <inttypes.h>
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
25 #include <math.h>
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
26
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16699
diff changeset
27 #include "mp_msg.h"
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
28 #include "img_format.h"
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
29 #include "mp_image.h"
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
30 #include "vf.h"
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 #define PARAM1_DEFAULT 4.0
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
33 #define PARAM2_DEFAULT 3.0
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
34 #define PARAM3_DEFAULT 6.0
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
35
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
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
38 struct vf_priv_s {
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
39 int Coefs[4][512*16];
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
40 unsigned int *Line;
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
41 unsigned short *Frame[3];
9441
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
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
44
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
45 /***************************************************************************/
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
46
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 30642
diff changeset
47 static void uninit(struct vf_instance *vf)
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 30642
diff changeset
48 {
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
49 free(vf->priv->Line);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
50 free(vf->priv->Frame[0]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
51 free(vf->priv->Frame[1]);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
52 free(vf->priv->Frame[2]);
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 30642
diff changeset
53
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
54 vf->priv->Line = NULL;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
55 vf->priv->Frame[0] = NULL;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
56 vf->priv->Frame[1] = NULL;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
57 vf->priv->Frame[2] = NULL;
9441
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
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
60 static int config(struct vf_instance *vf,
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
61 int width, int height, int d_width, int d_height,
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
62 unsigned int flags, unsigned int outfmt){
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
63
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
64 uninit(vf);
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
65 vf->priv->Line = malloc(width*sizeof(int));
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
66
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
67 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
9441
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
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
70 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
71 // int dMul= (PrevMul&0xFFFFFF)-(CurrMul&0xFFFFFF);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
72 int dMul= PrevMul-CurrMul;
29372
04506b0477af 20% faster hqdn3d on x86_64
lorenm
parents: 29263
diff changeset
73 unsigned int d=((dMul+0x10007FF)>>12);
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
74 return CurrMul + Coef[d];
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
75 }
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
76
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
77 static void deNoiseTemporal(
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
78 unsigned char *Frame, // mpi->planes[x]
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
79 unsigned char *FrameDest, // dmpi->planes[x]
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
80 unsigned short *FrameAnt,
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
81 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
82 int *Temporal)
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
83 {
29372
04506b0477af 20% faster hqdn3d on x86_64
lorenm
parents: 29263
diff changeset
84 long X, Y;
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
85 unsigned int PixelDst;
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
86
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
87 for (Y = 0; Y < H; Y++){
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
88 for (X = 0; X < W; X++){
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
89 PixelDst = LowPassMul(FrameAnt[X]<<8, Frame[X]<<16, Temporal);
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
90 FrameAnt[X] = ((PixelDst+0x1000007F)>>8);
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
91 FrameDest[X]= ((PixelDst+0x10007FFF)>>16);
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
92 }
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
93 Frame += sStride;
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
94 FrameDest += dStride;
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
95 FrameAnt += W;
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
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
99 static void deNoiseSpacial(
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
100 unsigned char *Frame, // mpi->planes[x]
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
101 unsigned char *FrameDest, // dmpi->planes[x]
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
102 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
103 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
104 int *Horizontal, int *Vertical)
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
105 {
29372
04506b0477af 20% faster hqdn3d on x86_64
lorenm
parents: 29263
diff changeset
106 long X, Y;
04506b0477af 20% faster hqdn3d on x86_64
lorenm
parents: 29263
diff changeset
107 long sLineOffs = 0, dLineOffs = 0;
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
108 unsigned int PixelAnt;
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
109 unsigned int PixelDst;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
110
16684
33e93b55fbee neightbour --> neighbor typo fix
diego
parents: 16682
diff changeset
111 /* 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
112 PixelDst = LineAnt[0] = PixelAnt = Frame[0]<<16;
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
113 FrameDest[0]= ((PixelDst+0x10007FFF)>>16);
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
114
16699
0cb2e995edd1 Typo fix, patch by Ismail D«Ónmez <ismail AH kde POIS org POIS tr>
gpoirier
parents: 16684
diff changeset
115 /* 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
116 for (X = 1; X < W; X++){
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
117 PixelDst = LineAnt[X] = LowPassMul(PixelAnt, Frame[X]<<16, Horizontal);
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
118 FrameDest[X]= ((PixelDst+0x10007FFF)>>16);
16682
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
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
121 for (Y = 1; Y < H; Y++){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
122 unsigned int PixelAnt;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
123 sLineOffs += sStride, dLineOffs += dStride;
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
124 /* 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
125 PixelAnt = Frame[sLineOffs]<<16;
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
126 PixelDst = LineAnt[0] = LowPassMul(LineAnt[0], PixelAnt, Vertical);
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
127 FrameDest[dLineOffs]= ((PixelDst+0x10007FFF)>>16);
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
128
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
129 for (X = 1; X < W; X++){
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
130 unsigned int PixelDst;
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
131 /* The rest are normal */
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
132 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
133 PixelDst = LineAnt[X] = LowPassMul(LineAnt[X], PixelAnt, Vertical);
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
134 FrameDest[dLineOffs+X]= ((PixelDst+0x10007FFF)>>16);
16682
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 }
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
138
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
139 static void deNoise(unsigned char *Frame, // mpi->planes[x]
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
140 unsigned char *FrameDest, // dmpi->planes[x]
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
141 unsigned int *LineAnt, // vf->priv->Line (width bytes)
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
142 unsigned short **FrameAntPtr,
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
143 int W, int H, int sStride, int dStride,
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
144 int *Horizontal, int *Vertical, int *Temporal)
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
145 {
29372
04506b0477af 20% faster hqdn3d on x86_64
lorenm
parents: 29263
diff changeset
146 long X, Y;
04506b0477af 20% faster hqdn3d on x86_64
lorenm
parents: 29263
diff changeset
147 long sLineOffs = 0, dLineOffs = 0;
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
148 unsigned int PixelAnt;
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
149 unsigned int PixelDst;
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
150 unsigned short* FrameAnt=(*FrameAntPtr);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29087
diff changeset
151
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
152 if(!FrameAnt){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
153 (*FrameAntPtr)=FrameAnt=malloc(W*H*sizeof(unsigned short));
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
154 for (Y = 0; Y < H; Y++){
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
155 unsigned short* dst=&FrameAnt[Y*W];
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
156 unsigned char* src=Frame+Y*sStride;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
157 for (X = 0; X < W; X++) dst[X]=src[X]<<8;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
158 }
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
159 }
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
160
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
161 if(!Horizontal[0] && !Vertical[0]){
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
162 deNoiseTemporal(Frame, FrameDest, FrameAnt,
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
163 W, H, sStride, dStride, Temporal);
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
164 return;
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
165 }
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
166 if(!Temporal[0]){
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
167 deNoiseSpacial(Frame, FrameDest, LineAnt,
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
168 W, H, sStride, dStride, Horizontal, Vertical);
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
169 return;
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
170 }
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
171
16684
33e93b55fbee neightbour --> neighbor typo fix
diego
parents: 16682
diff changeset
172 /* 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
173 LineAnt[0] = PixelAnt = Frame[0]<<16;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
174 PixelDst = LowPassMul(FrameAnt[0]<<8, PixelAnt, Temporal);
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
175 FrameAnt[0] = ((PixelDst+0x1000007F)>>8);
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
176 FrameDest[0]= ((PixelDst+0x10007FFF)>>16);
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
177
16699
0cb2e995edd1 Typo fix, patch by Ismail D«Ónmez <ismail AH kde POIS org POIS tr>
gpoirier
parents: 16684
diff changeset
178 /* 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
179 * last frame */
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
180 for (X = 1; X < W; X++){
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
181 LineAnt[X] = PixelAnt = LowPassMul(PixelAnt, Frame[X]<<16, Horizontal);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
182 PixelDst = LowPassMul(FrameAnt[X]<<8, PixelAnt, Temporal);
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
183 FrameAnt[X] = ((PixelDst+0x1000007F)>>8);
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
184 FrameDest[X]= ((PixelDst+0x10007FFF)>>16);
9441
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
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
187 for (Y = 1; Y < H; Y++){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
188 unsigned int PixelAnt;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
189 unsigned short* LinePrev=&FrameAnt[Y*W];
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
190 sLineOffs += sStride, dLineOffs += dStride;
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
191 /* First pixel on each line doesn't have previous pixel */
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
192 PixelAnt = Frame[sLineOffs]<<16;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
193 LineAnt[0] = LowPassMul(LineAnt[0], PixelAnt, Vertical);
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
194 PixelDst = LowPassMul(LinePrev[0]<<8, LineAnt[0], Temporal);
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
195 LinePrev[0] = ((PixelDst+0x1000007F)>>8);
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
196 FrameDest[dLineOffs]= ((PixelDst+0x10007FFF)>>16);
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
197
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
198 for (X = 1; X < W; X++){
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
199 unsigned int PixelDst;
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
200 /* The rest are normal */
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
201 PixelAnt = LowPassMul(PixelAnt, Frame[sLineOffs+X]<<16, Horizontal);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
202 LineAnt[X] = LowPassMul(LineAnt[X], PixelAnt, Vertical);
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
203 PixelDst = LowPassMul(LinePrev[X]<<8, LineAnt[X], Temporal);
17965
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
204 LinePrev[X] = ((PixelDst+0x1000007F)>>8);
a1dc210f20b3 use shifts instead of division. 15% faster hqdn3d
lorenm
parents: 17906
diff changeset
205 FrameDest[dLineOffs+X]= ((PixelDst+0x10007FFF)>>16);
9441
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
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
210
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
211 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
212 int cw= mpi->w >> mpi->chroma_x_shift;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
213 int ch= mpi->h >> mpi->chroma_y_shift;
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
214 int W = mpi->w, H = mpi->h;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
215
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
216 mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
217 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
218 mpi->w,mpi->h);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
219
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
220 if(!dmpi) return 0;
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
221
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
222 deNoise(mpi->planes[0], dmpi->planes[0],
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
223 vf->priv->Line, &vf->priv->Frame[0], W, H,
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
224 mpi->stride[0], dmpi->stride[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[0],
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
227 vf->priv->Coefs[1]);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
228 deNoise(mpi->planes[1], dmpi->planes[1],
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
229 vf->priv->Line, &vf->priv->Frame[1], cw, ch,
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
230 mpi->stride[1], dmpi->stride[1],
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[2],
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
233 vf->priv->Coefs[3]);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
234 deNoise(mpi->planes[2], dmpi->planes[2],
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
235 vf->priv->Line, &vf->priv->Frame[2], cw, ch,
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
236 mpi->stride[2], dmpi->stride[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[2],
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
239 vf->priv->Coefs[3]);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
240
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
241 return vf_next_put_image(vf,dmpi, pts);
9441
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
30642
a972c1a4a012 cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents: 30638
diff changeset
246 static int query_format(struct vf_instance *vf, unsigned int fmt){
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
247 switch(fmt)
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
248 {
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
249 case IMGFMT_YV12:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
250 case IMGFMT_I420:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
251 case IMGFMT_IYUV:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
252 case IMGFMT_YVU9:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
253 case IMGFMT_444P:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
254 case IMGFMT_422P:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
255 case IMGFMT_411P:
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
256 return vf_next_query_format(vf, fmt);
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
257 }
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
258 return 0;
9441
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
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
262 #define ABS(A) ( (A) > 0 ? (A) : -(A) )
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
263
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
264 static void PrecalcCoefs(int *Ct, double Dist25)
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
265 {
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
266 int i;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
267 double Gamma, Simil, C;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
268
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
269 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
270
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
271 for (i = -255*16; i <= 255*16; i++)
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
272 {
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
273 Simil = 1.0 - ABS(i) / (16*255.0);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
274 C = pow(Simil, Gamma) * 65536.0 * (double)i / 16.0;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
275 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
276 }
16682
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
277
5f98b89262c4 hqdn3d: 2.5x faster temporal-only, 1.6x faster spatial-only.
lorenm
parents: 9593
diff changeset
278 Ct[0] = (Dist25 != 0);
9441
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
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 29372
diff changeset
282 static int vf_open(vf_instance_t *vf, char *args){
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
283 double LumSpac, LumTmp, ChromSpac, ChromTmp;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
284 double Param1, Param2, Param3, Param4;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
285
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
286 vf->config=config;
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
287 vf->put_image=put_image;
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
288 vf->query_format=query_format;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
289 vf->uninit=uninit;
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
290 vf->priv=malloc(sizeof(struct vf_priv_s));
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
291 memset(vf->priv, 0, sizeof(struct vf_priv_s));
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
292
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
293 if (args)
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
294 {
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
295 switch(sscanf(args, "%lf:%lf:%lf:%lf",
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
296 &Param1, &Param2, &Param3, &Param4
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 {
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
299 case 0:
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
300 LumSpac = PARAM1_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
301 LumTmp = PARAM3_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
302
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
303 ChromSpac = PARAM2_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
304 ChromTmp = LumTmp * ChromSpac / LumSpac;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
305 break;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
306
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
307 case 1:
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
308 LumSpac = Param1;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
309 LumTmp = PARAM3_DEFAULT * Param1 / PARAM1_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
310
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
311 ChromSpac = PARAM2_DEFAULT * Param1 / PARAM1_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
312 ChromTmp = LumTmp * ChromSpac / LumSpac;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
313 break;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
314
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
315 case 2:
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
316 LumSpac = Param1;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
317 LumTmp = PARAM3_DEFAULT * Param1 / PARAM1_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
318
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
319 ChromSpac = Param2;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
320 ChromTmp = LumTmp * ChromSpac / LumSpac;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
321 break;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
322
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
323 case 3:
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
324 LumSpac = Param1;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
325 LumTmp = Param3;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
326
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
327 ChromSpac = Param2;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
328 ChromTmp = LumTmp * ChromSpac / LumSpac;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
329 break;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
330
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
331 case 4:
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
332 LumSpac = Param1;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
333 LumTmp = Param3;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
334
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
335 ChromSpac = Param2;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
336 ChromTmp = Param4;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
337 break;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
338
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
339 default:
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
340 LumSpac = PARAM1_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
341 LumTmp = PARAM3_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
342
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
343 ChromSpac = PARAM2_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
344 ChromTmp = LumTmp * ChromSpac / LumSpac;
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 }
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
347 else
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
348 {
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
349 LumSpac = PARAM1_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
350 LumTmp = PARAM3_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
351
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
352 ChromSpac = PARAM2_DEFAULT;
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
353 ChromTmp = LumTmp * ChromSpac / LumSpac;
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
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
356 PrecalcCoefs(vf->priv->Coefs[0], LumSpac);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
357 PrecalcCoefs(vf->priv->Coefs[1], LumTmp);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
358 PrecalcCoefs(vf->priv->Coefs[2], ChromSpac);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
359 PrecalcCoefs(vf->priv->Coefs[3], ChromTmp);
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
360
32702
7af3e6f901fd Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents: 32537
diff changeset
361 return 1;
9441
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
25221
00fff9a3b735 Make all vf_info_t structs const
reimar
parents: 23373
diff changeset
364 const vf_info_t vf_info_hqdn3d = {
9441
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
365 "High Quality 3D Denoiser",
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
366 "hqdn3d",
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
367 "Daniel Moreno & A'rpi",
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
368 "",
30638
a7b908875c14 Rename open() vf initialization function to vf_open().
diego
parents: 29372
diff changeset
369 vf_open,
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 9441
diff changeset
370 NULL
9441
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
85fa92f14e99 vf_hqdn3d: High-Quality version of the denoise3d filter
arpi
parents:
diff changeset
373 //===========================================================================//