Commit f42635a5 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '33b97faa'

* commit '33b97faa':
  vf_setpts: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/f_setpts.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 270d3c96 33b97faa
...@@ -6712,8 +6712,17 @@ Change the PTS (presentation timestamp) of the input frames. ...@@ -6712,8 +6712,17 @@ Change the PTS (presentation timestamp) of the input frames.
@code{asetpts} works on audio frames, @code{setpts} on video frames. @code{asetpts} works on audio frames, @code{setpts} on video frames.
Accept in input an expression evaluated through the eval API, which This filter accepts the following options:
can contain the following constants:
@table @option
@item expr
The expression which is evaluated for each frame to construct its timestamp.
@end table
The expression is evaluated through the eval API and can contain the following
constants:
@table @option @table @option
@item FRAME_RATE @item FRAME_RATE
......
...@@ -690,6 +690,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque ...@@ -690,6 +690,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "pp" ) || !strcmp(filter->filter->name, "pp" ) ||
!strcmp(filter->filter->name, "aperms") || !strcmp(filter->filter->name, "aperms") ||
!strcmp(filter->filter->name, "resample") || !strcmp(filter->filter->name, "resample") ||
!strcmp(filter->filter->name, "setpts" ) ||
!strcmp(filter->filter->name, "showspectrum") || !strcmp(filter->filter->name, "showspectrum") ||
!strcmp(filter->filter->name, "silencedetect") || !strcmp(filter->filter->name, "silencedetect") ||
!strcmp(filter->filter->name, "subtitles") || !strcmp(filter->filter->name, "subtitles") ||
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "libavutil/eval.h" #include "libavutil/eval.h"
#include "libavutil/internal.h" #include "libavutil/internal.h"
#include "libavutil/mathematics.h" #include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/time.h" #include "libavutil/time.h"
#include "avfilter.h" #include "avfilter.h"
#include "internal.h" #include "internal.h"
...@@ -78,6 +79,8 @@ enum var_name { ...@@ -78,6 +79,8 @@ enum var_name {
}; };
typedef struct { typedef struct {
const AVClass *class;
char *expr_str;
AVExpr *expr; AVExpr *expr;
double var_values[VAR_VARS_NB]; double var_values[VAR_VARS_NB];
enum AVMediaType type; enum AVMediaType type;
...@@ -88,9 +91,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args) ...@@ -88,9 +91,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
SetPTSContext *setpts = ctx->priv; SetPTSContext *setpts = ctx->priv;
int ret; int ret;
if ((ret = av_expr_parse(&setpts->expr, args ? args : "PTS", if ((ret = av_expr_parse(&setpts->expr, setpts->expr_str,
var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) { var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", args); av_log(ctx, AV_LOG_ERROR, "Error while parsing expression '%s'\n", setpts->expr_str);
return ret; return ret;
} }
...@@ -236,6 +239,21 @@ AVFilter avfilter_af_asetpts = { ...@@ -236,6 +239,21 @@ AVFilter avfilter_af_asetpts = {
#endif /* CONFIG_ASETPTS_FILTER */ #endif /* CONFIG_ASETPTS_FILTER */
#if CONFIG_SETPTS_FILTER #if CONFIG_SETPTS_FILTER
#define OFFSET(x) offsetof(SetPTSContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
static const AVOption options[] = {
{ "expr", "Expression determining the frame timestamp", OFFSET(expr_str), AV_OPT_TYPE_STRING, { .str = "PTS" }, .flags = FLAGS },
{ NULL },
};
static const AVClass setpts_class = {
.class_name = "setpts",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
static const AVFilterPad avfilter_vf_setpts_inputs[] = { static const AVFilterPad avfilter_vf_setpts_inputs[] = {
{ {
.name = "default", .name = "default",
...@@ -262,6 +280,7 @@ AVFilter avfilter_vf_setpts = { ...@@ -262,6 +280,7 @@ AVFilter avfilter_vf_setpts = {
.uninit = uninit, .uninit = uninit,
.priv_size = sizeof(SetPTSContext), .priv_size = sizeof(SetPTSContext),
.priv_class = &setpts_class,
.inputs = avfilter_vf_setpts_inputs, .inputs = avfilter_vf_setpts_inputs,
.outputs = avfilter_vf_setpts_outputs, .outputs = avfilter_vf_setpts_outputs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment