Mercurial > mplayer.hg
annotate libmpcodecs/vf_smartblur.c @ 32959:b17dd13b3cce
Remove unreasonable inline definition from TranslateFilename().
author | ib |
---|---|
date | Tue, 08 Mar 2011 10:25:28 +0000 |
parents | 7af3e6f901fd |
children | 00ab9ef28181 |
rev | line source |
---|---|
8106 | 1 /* |
26727 | 2 * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
8106 | 20 |
21 #include <stdio.h> | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <inttypes.h> | |
25 #include <assert.h> | |
26 | |
17012 | 27 #include "mp_msg.h" |
26069
1318e956c092
FFmpeg now uses different (unified) #include paths.
diego
parents:
25221
diff
changeset
|
28 #include "libavutil/avutil.h" |
8106 | 29 #include "img_format.h" |
30 #include "mp_image.h" | |
31 #include "vf.h" | |
18861 | 32 #include "libswscale/swscale.h" |
10233
35f52ad860a0
vf_scale.h & related cleanup & some small warning fix by dominik
michael
parents:
9975
diff
changeset
|
33 #include "vf_scale.h" |
8106 | 34 |
35 //===========================================================================// | |
36 | |
37 typedef struct FilterParam{ | |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
38 float radius; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
39 float strength; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
40 int threshold; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
41 float quality; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
42 struct SwsContext *filterContext; |
8106 | 43 }FilterParam; |
44 | |
45 struct vf_priv_s { | |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
46 FilterParam luma; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
47 FilterParam chroma; |
8106 | 48 }; |
49 | |
50 | |
51 /***************************************************************************/ | |
52 | |
53 //FIXME stupid code duplication | |
54 static void getSubSampleFactors(int *h, int *v, int format){ | |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
55 switch(format){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
56 case IMGFMT_YV12: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
57 case IMGFMT_I420: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
58 *h=1; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
59 *v=1; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
60 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
61 case IMGFMT_YVU9: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
62 *h=2; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
63 *v=2; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
64 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
65 case IMGFMT_444P: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
66 *h=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
67 *v=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
68 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
69 case IMGFMT_422P: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
70 *h=1; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
71 *v=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
72 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
73 case IMGFMT_411P: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
74 *h=2; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
75 *v=0; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
76 break; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
77 } |
8106 | 78 } |
79 | |
80 static int allocStuff(FilterParam *f, int width, int height){ | |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
81 SwsVector *vec; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
82 SwsFilter swsF; |
8106 | 83 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
84 vec = sws_getGaussianVec(f->radius, f->quality); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
85 sws_scaleVec(vec, f->strength); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
86 vec->coeff[vec->length/2]+= 1.0 - f->strength; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
87 swsF.lumH= swsF.lumV= vec; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
88 swsF.chrH= swsF.chrV= NULL; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
89 f->filterContext= sws_getContext( |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
90 width, height, PIX_FMT_GRAY8, width, height, PIX_FMT_GRAY8, SWS_BICUBIC | get_sws_cpuflags(), &swsF, NULL, NULL); |
8106 | 91 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
92 sws_freeVec(vec); |
8106 | 93 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
94 return 0; |
8106 | 95 } |
96 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
97 static int config(struct vf_instance *vf, |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
98 int width, int height, int d_width, int d_height, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
99 unsigned int flags, unsigned int outfmt){ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
100 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
101 int sw, sh; |
8106 | 102 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
103 allocStuff(&vf->priv->luma, width, height); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
104 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
105 getSubSampleFactors(&sw, &sh, outfmt); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
106 allocStuff(&vf->priv->chroma, width>>sw, height>>sh); |
8106 | 107 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
108 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); |
8106 | 109 } |
110 | |
111 static void freeBuffers(FilterParam *f){ | |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
112 if(f->filterContext) sws_freeContext(f->filterContext); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
113 f->filterContext=NULL; |
8106 | 114 } |
115 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
116 static void uninit(struct vf_instance *vf){ |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
117 if(!vf->priv) return; |
8106 | 118 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
119 freeBuffers(&vf->priv->luma); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
120 freeBuffers(&vf->priv->chroma); |
8106 | 121 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
122 free(vf->priv); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
123 vf->priv=NULL; |
8106 | 124 } |
125 | |
126 static inline void blur(uint8_t *dst, uint8_t *src, int w, int h, int dstStride, int srcStride, FilterParam *fp){ | |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
127 int x, y; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
128 FilterParam f= *fp; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
129 const uint8_t* const srcArray[MP_MAX_PLANES] = {src}; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
130 uint8_t *dstArray[MP_MAX_PLANES]= {dst}; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
131 int srcStrideArray[MP_MAX_PLANES]= {srcStride}; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
132 int dstStrideArray[MP_MAX_PLANES]= {dstStride}; |
8106 | 133 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
134 sws_scale(f.filterContext, srcArray, srcStrideArray, 0, h, dstArray, dstStrideArray); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
135 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
136 if(f.threshold > 0){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
137 for(y=0; y<h; y++){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
138 for(x=0; x<w; x++){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
139 const int orig= src[x + y*srcStride]; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
140 const int filtered= dst[x + y*dstStride]; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
141 const int diff= orig - filtered; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
142 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
143 if(diff > 0){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
144 if(diff > 2*f.threshold){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
145 dst[x + y*dstStride]= orig; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
146 }else if(diff > f.threshold){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
147 dst[x + y*dstStride]= filtered + diff - f.threshold; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
148 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
149 }else{ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
150 if(-diff > 2*f.threshold){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
151 dst[x + y*dstStride]= orig; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
152 }else if(-diff > f.threshold){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
153 dst[x + y*dstStride]= filtered + diff + f.threshold; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
154 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
155 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
156 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
157 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
158 }else if(f.threshold < 0){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
159 for(y=0; y<h; y++){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
160 for(x=0; x<w; x++){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
161 const int orig= src[x + y*srcStride]; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
162 const int filtered= dst[x + y*dstStride]; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
163 const int diff= orig - filtered; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
164 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
165 if(diff > 0){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
166 if(diff > -2*f.threshold){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
167 }else if(diff > -f.threshold){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
168 dst[x + y*dstStride]= orig - diff - f.threshold; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
169 }else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
170 dst[x + y*dstStride]= orig; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
171 }else{ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
172 if(diff < 2*f.threshold){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
173 }else if(diff < f.threshold){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
174 dst[x + y*dstStride]= orig - diff + f.threshold; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
175 }else |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
176 dst[x + y*dstStride]= orig; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
177 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
178 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
179 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
180 } |
8106 | 181 } |
182 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
183 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:
32136
diff
changeset
|
184 int cw= mpi->w >> mpi->chroma_x_shift; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
185 int ch= mpi->h >> mpi->chroma_y_shift; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
186 FilterParam *f= &vf->priv; |
8106 | 187 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
188 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:
32136
diff
changeset
|
189 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE| |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
190 (f->threshold) ? MP_IMGFLAG_READABLE : 0, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
191 mpi->w,mpi->h); |
8106 | 192 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
193 assert(mpi->flags&MP_IMGFLAG_PLANAR); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
194 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
195 blur(dmpi->planes[0], mpi->planes[0], mpi->w,mpi->h, dmpi->stride[0], mpi->stride[0], &vf->priv->luma); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
196 blur(dmpi->planes[1], mpi->planes[1], cw , ch , dmpi->stride[1], mpi->stride[1], &vf->priv->chroma); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
197 blur(dmpi->planes[2], mpi->planes[2], cw , ch , dmpi->stride[2], mpi->stride[2], &vf->priv->chroma); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
198 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
199 return vf_next_put_image(vf,dmpi, pts); |
8106 | 200 } |
201 | |
202 //===========================================================================// | |
203 | |
30642
a972c1a4a012
cosmetics: Rename struct vf_instance_s --> vf_instance.
diego
parents:
30638
diff
changeset
|
204 static int query_format(struct vf_instance *vf, unsigned int fmt){ |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
205 switch(fmt) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
206 { |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
207 case IMGFMT_YV12: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
208 case IMGFMT_I420: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
209 case IMGFMT_IYUV: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
210 case IMGFMT_YVU9: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
211 case IMGFMT_444P: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
212 case IMGFMT_422P: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
213 case IMGFMT_411P: |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
214 return vf_next_query_format(vf, fmt); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
215 } |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
216 return 0; |
8106 | 217 } |
218 | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
29263
diff
changeset
|
219 static int vf_open(vf_instance_t *vf, char *args){ |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
220 int e; |
8106 | 221 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
222 vf->config=config; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
223 vf->put_image=put_image; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
224 // vf->get_image=get_image; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
225 vf->query_format=query_format; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
226 vf->uninit=uninit; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
227 vf->priv=malloc(sizeof(struct vf_priv_s)); |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
228 memset(vf->priv, 0, sizeof(struct vf_priv_s)); |
8106 | 229 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
230 if(args==NULL) return 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
231 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
232 e=sscanf(args, "%f:%f:%d:%f:%f:%d", |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
233 &vf->priv->luma.radius, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
234 &vf->priv->luma.strength, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
235 &vf->priv->luma.threshold, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
236 &vf->priv->chroma.radius, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
237 &vf->priv->chroma.strength, |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
238 &vf->priv->chroma.threshold |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
239 ); |
8106 | 240 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
241 vf->priv->luma.quality = vf->priv->chroma.quality= 3.0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29087
diff
changeset
|
242 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
243 if(e==3){ |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
244 vf->priv->chroma.radius= vf->priv->luma.radius; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
245 vf->priv->chroma.strength= vf->priv->luma.strength; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
246 vf->priv->chroma.threshold = vf->priv->luma.threshold; |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
247 }else if(e!=6) |
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
248 return 0; |
8106 | 249 |
32702
7af3e6f901fd
Convert some tabs to whitespace to allow using MPlayer filter sourcecode in FFmpeg.
cehoyos
parents:
32136
diff
changeset
|
250 return 1; |
8106 | 251 } |
252 | |
25221 | 253 const vf_info_t vf_info_smartblur = { |
8106 | 254 "smart blur", |
255 "smartblur", | |
256 "Michael Niedermayer", | |
257 "", | |
30638
a7b908875c14
Rename open() vf initialization function to vf_open().
diego
parents:
29263
diff
changeset
|
258 vf_open, |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
9494
diff
changeset
|
259 NULL |
8106 | 260 }; |
261 | |
262 //===========================================================================// |