Mercurial > mplayer.hg
annotate libmpcodecs/vf_unsharp.c @ 11036:8e55228b6102
vidix equalizer support by Jake Page <jake@CS.Stanford.EDU>
author | alex |
---|---|
date | Tue, 07 Oct 2003 22:29:37 +0000 |
parents | 7d6a854a5fe5 |
children | 4a6b79a1ad52 |
rev | line source |
---|---|
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
1 /* |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
2 Copyright (C) 2002 Rémi Guyomarch <rguyom@pobox.com> |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
3 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
4 This program is free software; you can redistribute it and/or modify |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
6 the Free Software Foundation; either version 2 of the License, or |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
7 (at your option) any later version. |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
8 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
12 GNU General Public License for more details. |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
13 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
15 along with this program; if not, write to the Free Software |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
17 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
18 */ |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
19 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
20 #include <stdio.h> |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
21 #include <stdlib.h> |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
22 #include <string.h> |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
23 #include <inttypes.h> |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
24 #include <math.h> |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
25 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
26 #include "../config.h" |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
27 #include "../mp_msg.h" |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
28 #include "../cpudetect.h" |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
29 |
8083
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
30 #ifdef USE_SETLOCALE |
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
31 #include <locale.h> |
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
32 #endif |
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
33 |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
34 #ifdef HAVE_MALLOC_H |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
35 #include <malloc.h> |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
36 #endif |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
37 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
38 #include "img_format.h" |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
39 #include "mp_image.h" |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
40 #include "vf.h" |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
41 #include "../libvo/fastmemcpy.h" |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
42 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
43 #ifndef MIN |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
44 #define MIN(a,b) (((a)<(b))?(a):(b)) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
45 #endif |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
46 #ifndef MAX |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
47 #define MAX(a,b) (((a)>(b))?(a):(b)) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
48 #endif |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
49 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
50 //===========================================================================// |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
51 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
52 #define MIN_MATRIX_SIZE 3 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
53 #define MAX_MATRIX_SIZE 63 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
54 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
55 typedef struct FilterParam { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
56 int msizeX, msizeY; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
57 double amount; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
58 uint32_t *SC[MAX_MATRIX_SIZE-1]; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
59 } FilterParam; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
60 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
61 struct vf_priv_s { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
62 FilterParam lumaParam; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
63 FilterParam chromaParam; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
64 unsigned int outfmt; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
65 }; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
66 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
67 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
68 //===========================================================================// |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
69 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
70 /* This code is based on : |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
71 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
72 An Efficient algorithm for Gaussian blur using finite-state machines |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
73 Frederick M. Waltz and John W. V. Miller |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
74 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
75 SPIE Conf. on Machine Vision Systems for Inspection and Metrology VII |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
76 Originally published Boston, Nov 98 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
77 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
78 */ |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
79 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
80 static void unsharp( uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height, FilterParam *fp ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
81 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
82 uint32_t **SC = fp->SC; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
83 uint32_t SR[MAX_MATRIX_SIZE-1], Tmp1, Tmp2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
84 uint8_t* src2 = src; // avoid gcc warning |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
85 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
86 int32_t res; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
87 int x, y, z; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
88 int amount = fp->amount * 65536.0; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
89 int stepsX = fp->msizeX/2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
90 int stepsY = fp->msizeY/2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
91 int scalebits = (stepsX+stepsY)*2; |
8015
403f7a58ccf2
vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents:
7966
diff
changeset
|
92 int32_t halfscale = 1 << ((stepsX+stepsY)*2-1); |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
93 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
94 if( !fp->amount ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
95 if( src == dst ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
96 return; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
97 if( dstStride == srcStride ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
98 memcpy( dst, src, srcStride*height ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
99 else |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
100 for( y=0; y<height; y++, dst+=dstStride, src+=srcStride ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
101 memcpy( dst, src, width ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
102 return; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
103 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
104 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
105 for( y=0; y<2*stepsY; y++ ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
106 memset( SC[y], 0, sizeof(SC[y][0]) * (width+2*stepsX) ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
107 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
108 for( y=-stepsY; y<height+stepsY; y++ ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
109 if( y < height ) src2 = src; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
110 memset( SR, 0, sizeof(SR[0]) * (2*stepsX-1) ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
111 for( x=-stepsX; x<width+stepsX; x++ ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
112 Tmp1 = x<=0 ? src2[0] : x>=width ? src2[width-1] : src2[x]; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
113 for( z=0; z<stepsX*2; z+=2 ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
114 Tmp2 = SR[z+0] + Tmp1; SR[z+0] = Tmp1; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
115 Tmp1 = SR[z+1] + Tmp2; SR[z+1] = Tmp2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
116 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
117 for( z=0; z<stepsY*2; z+=2 ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
118 Tmp2 = SC[z+0][x+stepsX] + Tmp1; SC[z+0][x+stepsX] = Tmp1; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
119 Tmp1 = SC[z+1][x+stepsX] + Tmp2; SC[z+1][x+stepsX] = Tmp2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
120 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
121 if( x>=stepsX && y>=stepsY ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
122 uint8_t* srx = src - stepsY*srcStride + x - stepsX; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
123 uint8_t* dsx = dst - stepsY*dstStride + x - stepsX; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
124 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
125 res = (int32_t)*srx + ( ( ( (int32_t)*srx - (int32_t)((Tmp1+halfscale) >> scalebits) ) * amount ) >> 16 ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
126 *dsx = res>255 ? 255 : res<0 ? 0 : (uint8_t)res; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
127 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
128 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
129 if( y >= 0 ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
130 dst += dstStride; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
131 src += srcStride; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
132 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
133 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
134 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
135 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
136 //===========================================================================// |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
137 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
138 static int config( struct vf_instance_s* vf, |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
139 int width, int height, int d_width, int d_height, |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
140 unsigned int flags, unsigned int outfmt ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
141 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
142 int z, stepsX, stepsY; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
143 FilterParam *fp; |
8015
403f7a58ccf2
vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents:
7966
diff
changeset
|
144 char *effect; |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
145 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
146 // allocate buffers |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
147 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
148 fp = &vf->priv->lumaParam; |
8015
403f7a58ccf2
vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents:
7966
diff
changeset
|
149 effect = fp->amount == 0 ? "don't touch" : fp->amount < 0 ? "blur" : "sharpen"; |
403f7a58ccf2
vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents:
7966
diff
changeset
|
150 mp_msg( MSGT_VFILTER, MSGL_INFO, "unsharp: %dx%d:%0.2f (%s luma) \n", fp->msizeX, fp->msizeY, fp->amount, effect ); |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
151 memset( fp->SC, 0, sizeof( fp->SC ) ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
152 stepsX = fp->msizeX/2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
153 stepsY = fp->msizeY/2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
154 for( z=0; z<2*stepsY; z++ ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
155 fp->SC[z] = memalign( 16, sizeof(*(fp->SC[z])) * (width+2*stepsX) ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
156 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
157 fp = &vf->priv->chromaParam; |
8015
403f7a58ccf2
vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents:
7966
diff
changeset
|
158 effect = fp->amount == 0 ? "don't touch" : fp->amount < 0 ? "blur" : "sharpen"; |
403f7a58ccf2
vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents:
7966
diff
changeset
|
159 mp_msg( MSGT_VFILTER, MSGL_INFO, "unsharp: %dx%d:%0.2f (%s chroma)\n", fp->msizeX, fp->msizeY, fp->amount, effect ); |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
160 memset( fp->SC, 0, sizeof( fp->SC ) ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
161 stepsX = fp->msizeX/2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
162 stepsY = fp->msizeY/2; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
163 for( z=0; z<2*stepsY; z++ ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
164 fp->SC[z] = memalign( 16, sizeof(*(fp->SC[z])) * (width+2*stepsX) ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
165 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
166 return vf_next_config( vf, width, height, d_width, d_height, flags, outfmt ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
167 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
168 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
169 //===========================================================================// |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
170 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
171 static void get_image( struct vf_instance_s* vf, mp_image_t *mpi ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
172 if( mpi->flags & MP_IMGFLAG_PRESERVE ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
173 return; // don't change |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
174 if( mpi->imgfmt!=vf->priv->outfmt ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
175 return; // colorspace differ |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
176 |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
177 vf->dmpi = vf_get_image( vf->next, mpi->imgfmt, mpi->type, mpi->flags, mpi->w, mpi->h ); |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
178 mpi->planes[0] = vf->dmpi->planes[0]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
179 mpi->stride[0] = vf->dmpi->stride[0]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
180 mpi->width = vf->dmpi->width; |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
181 if( mpi->flags & MP_IMGFLAG_PLANAR ) { |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
182 mpi->planes[1] = vf->dmpi->planes[1]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
183 mpi->planes[2] = vf->dmpi->planes[2]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
184 mpi->stride[1] = vf->dmpi->stride[1]; |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
185 mpi->stride[2] = vf->dmpi->stride[2]; |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
186 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
187 mpi->flags |= MP_IMGFLAG_DIRECT; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
188 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
189 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
190 static int put_image( struct vf_instance_s* vf, mp_image_t *mpi ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
191 mp_image_t *dmpi; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
192 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
193 if( !(mpi->flags & MP_IMGFLAG_DIRECT) ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
194 // no DR, so get a new image! hope we'll get DR buffer: |
10141
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
195 vf->dmpi = vf_get_image( vf->next,vf->priv->outfmt, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, mpi->w, mpi->h); |
7d6a854a5fe5
cleanup, use vf->dmpi rather than vf->priv->dmpi for consistency
rfelker
parents:
9934
diff
changeset
|
196 dmpi= vf->dmpi; |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
197 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
198 unsharp( dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
199 unsharp( dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
200 unsharp( dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2, &vf->priv->chromaParam ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
201 |
9934 | 202 vf_clone_mpi_attributes(dmpi, mpi); |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
203 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
204 #ifdef HAVE_MMX |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
205 if(gCpuCaps.hasMMX) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
206 asm volatile ("emms\n\t"); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
207 #endif |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
208 #ifdef HAVE_MMX2 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
209 if(gCpuCaps.hasMMX2) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
210 asm volatile ("sfence\n\t"); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
211 #endif |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
212 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
213 return vf_next_put_image( vf, dmpi ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
214 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
215 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
216 static void uninit( struct vf_instance_s* vf ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
217 unsigned int z; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
218 FilterParam *fp; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
219 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
220 if( !vf->priv ) return; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
221 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
222 fp = &vf->priv->lumaParam; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
223 for( z=0; z<sizeof(fp->SC)/sizeof(fp->SC[0]); z++ ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
224 if( fp->SC[z] ) free( fp->SC[z] ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
225 fp->SC[z] = NULL; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
226 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
227 fp = &vf->priv->chromaParam; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
228 for( z=0; z<sizeof(fp->SC)/sizeof(fp->SC[0]); z++ ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
229 if( fp->SC[z] ) free( fp->SC[z] ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
230 fp->SC[z] = NULL; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
231 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
232 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
233 free( vf->priv ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
234 vf->priv = NULL; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
235 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
236 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
237 //===========================================================================// |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
238 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
239 static int query_format( struct vf_instance_s* vf, unsigned int fmt ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
240 switch(fmt) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
241 case IMGFMT_YV12: |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
242 case IMGFMT_I420: |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
243 case IMGFMT_IYUV: |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
244 return vf_next_query_format( vf, vf->priv->outfmt ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
245 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
246 return 0; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
247 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
248 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
249 //===========================================================================// |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
250 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
251 static void parse( FilterParam *fp, char* args ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
252 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
253 // l7x5:0.8:c3x3:-0.2 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
254 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
255 char *z; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
256 char *pos = args; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
257 char *max = args + strlen(args); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
258 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
259 // parse matrix sizes |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
260 fp->msizeX = ( pos && pos+1<max ) ? atoi( pos+1 ) : 0; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
261 z = strchr( pos+1, 'x' ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
262 fp->msizeY = ( z && z+1<max ) ? atoi( pos=z+1 ) : fp->msizeX; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
263 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
264 // min/max & odd |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
265 fp->msizeX = 1 | MIN( MAX( fp->msizeX, MIN_MATRIX_SIZE ), MAX_MATRIX_SIZE ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
266 fp->msizeY = 1 | MIN( MAX( fp->msizeY, MIN_MATRIX_SIZE ), MAX_MATRIX_SIZE ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
267 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
268 // parse amount |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
269 pos = strchr( pos+1, ':' ); |
8083
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
270 #ifdef USE_SETLOCALE |
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
271 setlocale( LC_NUMERIC, "C" ); |
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
272 #endif |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
273 fp->amount = ( pos && pos+1<max ) ? atof( pos+1 ) : 0; |
8083
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
274 #ifdef USE_SETLOCALE |
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
275 setlocale( LC_NUMERIC, "" ); |
3aee0db04665
Fixed a bug which would prevent proper parsing of floating point
rguyom
parents:
8015
diff
changeset
|
276 #endif |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
277 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
278 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
279 //===========================================================================// |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
280 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
281 static unsigned int fmt_list[] = { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
282 IMGFMT_YV12, |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
283 IMGFMT_I420, |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
284 IMGFMT_IYUV, |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
285 0 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
286 }; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
287 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
288 static int open( vf_instance_t *vf, char* args ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
289 vf->config = config; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
290 vf->put_image = put_image; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
291 vf->get_image = get_image; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
292 vf->query_format = query_format; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
293 vf->uninit = uninit; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
294 vf->priv = malloc( sizeof(struct vf_priv_s) ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
295 memset( vf->priv, 0, sizeof(struct vf_priv_s) ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
296 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
297 if( args ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
298 char *args2 = strchr( args, 'l' ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
299 if( args2 ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
300 parse( &vf->priv->lumaParam, args2 ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
301 else { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
302 vf->priv->lumaParam.amount = |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
303 vf->priv->lumaParam.msizeX = |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
304 vf->priv->lumaParam.msizeY = 0; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
305 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
306 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
307 args2 = strchr( args, 'c' ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
308 if( args2 ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
309 parse( &vf->priv->chromaParam, args2 ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
310 else { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
311 vf->priv->chromaParam.amount = |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
312 vf->priv->chromaParam.msizeX = |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
313 vf->priv->chromaParam.msizeY = 0; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
314 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
315 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
316 if( !vf->priv->lumaParam.msizeX && !vf->priv->chromaParam.msizeX ) |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
317 return 0; // nothing to do |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
318 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
319 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
320 // check csp: |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
321 vf->priv->outfmt = vf_match_csp( &vf->next, fmt_list, IMGFMT_YV12 ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
322 if( !vf->priv->outfmt ) { |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
323 uninit( vf ); |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
324 return 0; // no csp match :( |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
325 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
326 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
327 return 1; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
328 } |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
329 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
330 vf_info_t vf_info_unsharp = { |
8015
403f7a58ccf2
vf_unsharp: proper rounding & print if sharpening or bluring
arpi
parents:
7966
diff
changeset
|
331 "unsharp mask & gaussian blur", |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
332 "unsharp", |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
333 "Rémi Guyomarch", |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
334 "", |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8083
diff
changeset
|
335 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
8083
diff
changeset
|
336 NULL |
7966
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
337 }; |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
338 |
a03235a5f395
new video filter: unsharp - does image (l/c/l+c) sharping/bluring
arpi
parents:
diff
changeset
|
339 //===========================================================================// |