[FFmpeg-devel] [PATCH 1/5] lavfi: remplace passthrough_filter_frame with a flag.
Clément Bœsch
ubitux at gmail.com
Thu May 9 01:53:23 CEST 2013
With the introduction of AVFilterContext->is_disabled, we can simplify
the custom passthrough mode in filters.
---
libavfilter/af_apad.c | 3 +--
libavfilter/avfilter.c | 6 +++---
libavfilter/avfilter.h | 19 ++++++-------------
libavfilter/version.h | 4 ++--
libavfilter/vf_overlay.c | 25 ++++---------------------
5 files changed, 16 insertions(+), 41 deletions(-)
diff --git a/libavfilter/af_apad.c b/libavfilter/af_apad.c
index 265b76a..710baaa 100644
--- a/libavfilter/af_apad.c
+++ b/libavfilter/af_apad.c
@@ -131,7 +131,6 @@ static const AVFilterPad apad_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
.filter_frame = filter_frame,
- .passthrough_filter_frame = filter_frame,
},
{ NULL },
};
@@ -153,5 +152,5 @@ AVFilter avfilter_af_apad = {
.inputs = apad_inputs,
.outputs = apad_outputs,
.priv_class = &apad_class,
- .flags = AVFILTER_FLAG_SUPPORT_TIMELINE,
+ .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
};
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 3f94dde..1cf763c 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -995,9 +995,9 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame)
dstctx->var_values[VAR_POS] = pos == -1 ? NAN : pos;
dstctx->is_disabled = !av_expr_eval(dstctx->enable, dstctx->var_values, NULL);
- if (dstctx->is_disabled)
- filter_frame = dst->passthrough_filter_frame ? dst->passthrough_filter_frame
- : default_filter_frame;
+ if (dstctx->is_disabled &&
+ !(dstctx->filter->flags & (AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL^AVFILTER_FLAG_SUPPORT_TIMELINE)))
+ filter_frame = default_filter_frame;
}
ret = filter_frame(link, out);
link->frame_count++;
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 9314335..108ad4b 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -385,19 +385,6 @@ struct AVFilterPad {
int needs_fifo;
int needs_writable;
-
- /**
- * Passthrough filtering callback.
- *
- * If a filter supports timeline editing (in case
- * AVFILTER_FLAG_SUPPORT_TIMELINE is enabled) then it can implement a
- * custom passthrough callback to update its local context (for example to
- * keep a frame reference, or simply send the filter to a custom outlink).
- * The filter must not do any change to the frame in this callback.
- *
- * Input pads only.
- */
- int (*passthrough_filter_frame)(AVFilterLink *link, AVFrame *frame);
};
#endif
@@ -447,6 +434,12 @@ enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
* option have this flag set.
*/
#define AVFILTER_FLAG_SUPPORT_TIMELINE (1 << 16)
+/**
+ * Same as AVFILTER_FLAG_SUPPORT_TIMELINE, except that the filter will have its
+ * inpad->filter_frame() callback(s) naturally called (and will use
+ * AVFilterContext->is_disabled internally).
+ */
+#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL (1<<17 | AVFILTER_FLAG_SUPPORT_TIMELINE)
/**
* Filter definition. This defines the pads a filter contains, and all the
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 0773ff7..74e8bce 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -29,8 +29,8 @@
#include "libavutil/avutil.h"
#define LIBAVFILTER_VERSION_MAJOR 3
-#define LIBAVFILTER_VERSION_MINOR 63
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MINOR 64
+#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 1681979..79fd52e 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -88,7 +88,6 @@ enum var_name {
typedef struct {
const AVClass *class;
int x, y; ///< position of overlayed picture
- int enable; ///< tells if blending is enabled
int allow_packed_rgb;
uint8_t frame_requested;
@@ -597,7 +596,7 @@ static int try_filter_frame(AVFilterContext *ctx, AVFrame *mainpic)
over->var_values[VAR_X], over->x,
over->var_values[VAR_Y], over->y);
}
- if (over->enable)
+ if (!ctx->is_disabled)
blend_image(ctx, mainpic, over->overpicref, over->x, over->y);
}
@@ -663,20 +662,6 @@ static int filter_frame_over(AVFilterLink *inlink, AVFrame *inpicref)
return ret == AVERROR(EAGAIN) ? 0 : ret;
}
-#define DEF_FILTER_FRAME(name, mode, enable_value) \
-static int filter_frame_##name##_##mode(AVFilterLink *inlink, AVFrame *frame) \
-{ \
- AVFilterContext *ctx = inlink->dst; \
- OverlayContext *over = ctx->priv; \
- over->enable = enable_value; \
- return filter_frame_##name(inlink, frame); \
-}
-
-DEF_FILTER_FRAME(main, enabled, 1);
-DEF_FILTER_FRAME(main, disabled, 0);
-DEF_FILTER_FRAME(over, enabled, 1);
-DEF_FILTER_FRAME(over, disabled, 0);
-
static int request_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
@@ -734,16 +719,14 @@ static const AVFilterPad avfilter_vf_overlay_inputs[] = {
.type = AVMEDIA_TYPE_VIDEO,
.get_video_buffer = ff_null_get_video_buffer,
.config_props = config_input_main,
- .filter_frame = filter_frame_main_enabled,
- .passthrough_filter_frame = filter_frame_main_disabled,
+ .filter_frame = filter_frame_main,
.needs_writable = 1,
},
{
.name = "overlay",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_input_overlay,
- .filter_frame = filter_frame_over_enabled,
- .passthrough_filter_frame = filter_frame_over_disabled,
+ .filter_frame = filter_frame_over,
},
{ NULL }
};
@@ -773,5 +756,5 @@ AVFilter avfilter_vf_overlay = {
.inputs = avfilter_vf_overlay_inputs,
.outputs = avfilter_vf_overlay_outputs,
- .flags = AVFILTER_FLAG_SUPPORT_TIMELINE,
+ .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
};
--
1.8.2.2
More information about the ffmpeg-devel
mailing list