... | ... |
@@ -139,23 +139,23 @@ static int filter_brng(SignalstatsContext *s, const AVFrame *in, AVFrame *out, i |
139 | 139 |
int x, y, score = 0; |
140 | 140 |
|
141 | 141 |
for (y = 0; y < h; y++) { |
142 |
- const int yc = y >> s->vsub; |
|
143 |
- const uint8_t *pluma = &in->data[0][y * in->linesize[0]]; |
|
144 |
- const uint8_t *pchromau = &in->data[1][yc * in->linesize[1]]; |
|
145 |
- const uint8_t *pchromav = &in->data[2][yc * in->linesize[2]]; |
|
146 |
- |
|
147 |
- for (x = 0; x < w; x++) { |
|
148 |
- const int xc = x >> s->hsub; |
|
149 |
- const int luma = pluma[x]; |
|
150 |
- const int chromau = pchromau[xc]; |
|
151 |
- const int chromav = pchromav[xc]; |
|
152 |
- const int filt = luma < 16 || luma > 235 || |
|
153 |
- chromau < 16 || chromau > 240 || |
|
154 |
- chromav < 16 || chromav > 240; |
|
155 |
- score += filt; |
|
156 |
- if (out && filt) |
|
157 |
- burn_frame(s, out, x, y); |
|
158 |
- } |
|
142 |
+ const int yc = y >> s->vsub; |
|
143 |
+ const uint8_t *pluma = &in->data[0][y * in->linesize[0]]; |
|
144 |
+ const uint8_t *pchromau = &in->data[1][yc * in->linesize[1]]; |
|
145 |
+ const uint8_t *pchromav = &in->data[2][yc * in->linesize[2]]; |
|
146 |
+ |
|
147 |
+ for (x = 0; x < w; x++) { |
|
148 |
+ const int xc = x >> s->hsub; |
|
149 |
+ const int luma = pluma[x]; |
|
150 |
+ const int chromau = pchromau[xc]; |
|
151 |
+ const int chromav = pchromav[xc]; |
|
152 |
+ const int filt = luma < 16 || luma > 235 || |
|
153 |
+ chromau < 16 || chromau > 240 || |
|
154 |
+ chromav < 16 || chromav > 240; |
|
155 |
+ score += filt; |
|
156 |
+ if (out && filt) |
|
157 |
+ burn_frame(s, out, x, y); |
|
158 |
+ } |
|
159 | 159 |
} |
160 | 160 |
return score; |
161 | 161 |
} |
... | ... |
@@ -173,35 +173,35 @@ static int filter_tout(SignalstatsContext *s, const AVFrame *in, AVFrame *out, i |
173 | 173 |
|
174 | 174 |
for (y = 0; y < h; y++) { |
175 | 175 |
|
176 |
- if (y - 1 < 0 || y + 1 >= h) |
|
177 |
- continue; |
|
176 |
+ if (y - 1 < 0 || y + 1 >= h) |
|
177 |
+ continue; |
|
178 | 178 |
|
179 |
- // detect two pixels above and below (to eliminate interlace artefacts) |
|
180 |
- // should check that video format is infact interlaced. |
|
179 |
+ // detect two pixels above and below (to eliminate interlace artefacts) |
|
180 |
+ // should check that video format is infact interlaced. |
|
181 | 181 |
|
182 | 182 |
#define FILTER(i, j) \ |
183 |
-filter_tout_outlier(p[(y-j) * lw + x + i], \ |
|
184 |
- p[ y * lw + x + i], \ |
|
185 |
- p[(y+j) * lw + x + i]) |
|
183 |
+ filter_tout_outlier(p[(y-j) * lw + x + i], \ |
|
184 |
+ p[ y * lw + x + i], \ |
|
185 |
+ p[(y+j) * lw + x + i]) |
|
186 | 186 |
|
187 | 187 |
#define FILTER3(j) (FILTER(-1, j) && FILTER(0, j) && FILTER(1, j)) |
188 | 188 |
|
189 |
- if (y - 2 >= 0 && y + 2 < h) { |
|
190 |
- for (x = 1; x < w - 1; x++) { |
|
191 |
- filt = FILTER3(2) && FILTER3(1); |
|
192 |
- score += filt; |
|
193 |
- if (filt && out) |
|
194 |
- burn_frame(s, out, x, y); |
|
195 |
- } |
|
196 |
- } else { |
|
197 |
- for (x = 1; x < w - 1; x++) { |
|
198 |
- filt = FILTER3(1); |
|
199 |
- score += filt; |
|
200 |
- if (filt && out) |
|
201 |
- burn_frame(s, out, x, y); |
|
189 |
+ if (y - 2 >= 0 && y + 2 < h) { |
|
190 |
+ for (x = 1; x < w - 1; x++) { |
|
191 |
+ filt = FILTER3(2) && FILTER3(1); |
|
192 |
+ score += filt; |
|
193 |
+ if (filt && out) |
|
194 |
+ burn_frame(s, out, x, y); |
|
195 |
+ } |
|
196 |
+ } else { |
|
197 |
+ for (x = 1; x < w - 1; x++) { |
|
198 |
+ filt = FILTER3(1); |
|
199 |
+ score += filt; |
|
200 |
+ if (filt && out) |
|
201 |
+ burn_frame(s, out, x, y); |
|
202 |
+ } |
|
202 | 203 |
} |
203 | 204 |
} |
204 |
- } |
|
205 | 205 |
return score; |
206 | 206 |
} |
207 | 207 |
|
... | ... |
@@ -214,18 +214,18 @@ static int filter_vrep(SignalstatsContext *s, const AVFrame *in, AVFrame *out, i |
214 | 214 |
int x, y, score = 0; |
215 | 215 |
|
216 | 216 |
for (y = VREP_START; y < h; y++) { |
217 |
- const int y2lw = (y - VREP_START) * lw; |
|
218 |
- const int ylw = y * lw; |
|
219 |
- int filt, totdiff = 0; |
|
220 |
- |
|
221 |
- for (x = 0; x < w; x++) |
|
222 |
- totdiff += abs(p[y2lw + x] - p[ylw + x]); |
|
223 |
- filt = totdiff < w; |
|
217 |
+ const int y2lw = (y - VREP_START) * lw; |
|
218 |
+ const int ylw = y * lw; |
|
219 |
+ int filt, totdiff = 0; |
|
224 | 220 |
|
225 |
- score += filt; |
|
226 |
- if (filt && out) |
|
227 | 221 |
for (x = 0; x < w; x++) |
228 |
- burn_frame(s, out, x, y); |
|
222 |
+ totdiff += abs(p[y2lw + x] - p[ylw + x]); |
|
223 |
+ filt = totdiff < w; |
|
224 |
+ |
|
225 |
+ score += filt; |
|
226 |
+ if (filt && out) |
|
227 |
+ for (x = 0; x < w; x++) |
|
228 |
+ burn_frame(s, out, x, y); |
|
229 | 229 |
} |
230 | 230 |
return score * w; |
231 | 231 |
} |
... | ... |
@@ -317,12 +317,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) |
317 | 317 |
cpw += prev->linesize[1]; |
318 | 318 |
} |
319 | 319 |
|
320 |
- for (fil = 0; fil < FILT_NUMB; fil ++) { |
|
321 |
- if (s->filters & 1<<fil) { |
|
322 |
- AVFrame *dbg = out != in && s->outfilter == fil ? out : NULL; |
|
323 |
- filtot[fil] = filters_def[fil].process(s, in, dbg, link->w, link->h); |
|
324 |
- } |
|
320 |
+ for (fil = 0; fil < FILT_NUMB; fil ++) { |
|
321 |
+ if (s->filters & 1<<fil) { |
|
322 |
+ AVFrame *dbg = out != in && s->outfilter == fil ? out : NULL; |
|
323 |
+ filtot[fil] = filters_def[fil].process(s, in, dbg, link->w, link->h); |
|
325 | 324 |
} |
325 |
+ } |
|
326 | 326 |
|
327 | 327 |
// find low / high based on histogram percentile |
328 | 328 |
// these only need to be calculated once. |