[FFmpeg-cvslog] avfilter/signalstats: remove pointless sub filter init system
Clément Bœsch
git at videolan.org
Wed Nov 26 21:58:49 CET 2014
ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Sun Nov 16 21:12:52 2014 +0100| [c7e8f610f281765d2958a3dfbbc70a8cb0ac87bf] | committer: Clément Bœsch
avfilter/signalstats: remove pointless sub filter init system
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c7e8f610f281765d2958a3dfbbc70a8cb0ac87bf
---
libavfilter/vf_signalstats.c | 57 +++++++++++-------------------------------
1 file changed, 15 insertions(+), 42 deletions(-)
diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 8c6a2d6..b5b45b8 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -43,7 +43,6 @@ typedef struct {
enum FilterMode outfilter;
int filters;
AVFrame *frame_prev;
- char *vrep_line;
uint8_t rgba_color[4];
int yuv_color[3];
} SignalstatsContext;
@@ -88,7 +87,6 @@ static av_cold void uninit(AVFilterContext *ctx)
{
SignalstatsContext *s = ctx->priv;
av_frame_free(&s->frame_prev);
- av_freep(&s->vrep_line);
}
static int query_formats(AVFilterContext *ctx)
@@ -124,12 +122,6 @@ static int config_props(AVFilterLink *outlink)
s->fs = inlink->w * inlink->h;
s->cfs = s->chromaw * s->chromah;
- if (s->filters & 1<<FILTER_VREP) {
- s->vrep_line = av_malloc(inlink->h * sizeof(*s->vrep_line));
- if (!s->vrep_line)
- return AVERROR(ENOMEM);
- }
-
return 0;
}
@@ -209,49 +201,34 @@ filter_tout_outlier(p[(y-j) * lw + x + i], \
#define VREP_START 4
-static void filter_init_vrep(SignalstatsContext *s, const AVFrame *p, int w, int h)
-{
- int i, y;
- int lw = p->linesize[0];
-
- for (y = VREP_START; y < h; y++) {
- int totdiff = 0;
- int y2lw = (y - VREP_START) * lw;
- int ylw = y * lw;
-
- for (i = 0; i < w; i++)
- totdiff += abs(p->data[0][y2lw + i] - p->data[0][ylw + i]);
-
- /* this value should be definable */
- s->vrep_line[y] = totdiff < w;
- }
-}
-
static int filter_vrep(SignalstatsContext *s, const AVFrame *in, AVFrame *out, int y, int w, int h)
{
- int x, score = 0;
+ const uint8_t *p = in->data[0];
+ const int lw = in->linesize[0];
+ int x, score, totdiff = 0;
+ const int y2lw = (y - VREP_START) * lw;
+ const int ylw = y * lw;
if (y < VREP_START)
return 0;
- for (x = 0; x < w; x++) {
- if (s->vrep_line[y]) {
- score++;
- if (out)
- burn_frame(s, out, x, y);
- }
- }
+ for (x = 0; x < w; x++)
+ totdiff += abs(p[y2lw + x] - p[ylw + x]);
+
+ score = (totdiff < w) * w;
+ if (score && out)
+ for (x = 0; x < w; x++)
+ burn_frame(s, out, x, y);
return score;
}
static const struct {
const char *name;
- void (*init)(SignalstatsContext *s, const AVFrame *p, int w, int h);
int (*process)(SignalstatsContext *s, const AVFrame *in, AVFrame *out, int y, int w, int h);
} filters_def[] = {
- {"TOUT", NULL, filter_tout},
- {"VREP", filter_init_vrep, filter_vrep},
- {"BRNG", NULL, filter_brng},
+ {"TOUT", filter_tout},
+ {"VREP", filter_vrep},
+ {"BRNG", filter_brng},
{NULL}
};
@@ -299,10 +276,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
av_frame_make_writable(out);
}
- for (fil = 0; fil < FILT_NUMB; fil ++)
- if ((s->filters & 1<<fil) && filters_def[fil].init)
- filters_def[fil].init(s, in, link->w, link->h);
-
// Calculate luma histogram and difference with previous frame or field.
for (j = 0; j < link->h; j++) {
for (i = 0; i < link->w; i++) {
More information about the ffmpeg-cvslog
mailing list