You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
vf_setpts: switch to an AVOptions-based system.
This commit is contained in:
@@ -1895,8 +1895,17 @@ See also the @ref{setsar} filter documentation.
|
|||||||
|
|
||||||
Change the PTS (presentation timestamp) of the input video frames.
|
Change the PTS (presentation timestamp) of the input 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 PTS
|
@item PTS
|
||||||
@@ -1938,10 +1947,10 @@ Some examples follow:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
# start counting PTS from zero
|
# start counting PTS from zero
|
||||||
setpts=PTS-STARTPTS
|
setpts=expr=PTS-STARTPTS
|
||||||
|
|
||||||
# fast motion
|
# fast motion
|
||||||
setpts=0.5*PTS
|
setpts=expr=0.5*PTS
|
||||||
|
|
||||||
# slow motion
|
# slow motion
|
||||||
setpts=2.0*PTS
|
setpts=2.0*PTS
|
||||||
|
@@ -29,6 +29,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"
|
||||||
@@ -67,6 +68,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];
|
||||||
} SetPTSContext;
|
} SetPTSContext;
|
||||||
@@ -76,9 +79,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +148,20 @@ static av_cold void uninit(AVFilterContext *ctx)
|
|||||||
setpts->expr = NULL;
|
setpts->expr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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",
|
||||||
@@ -171,6 +188,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,
|
||||||
|
Reference in New Issue
Block a user