summaryrefslogtreecommitdiff
path: root/libavfilter/vf_scale_vaapi.c
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2017-02-01 16:30:18 -0800
committerMark Thompson <sw@jkqxz.net>2017-02-02 22:58:54 +0000
commit037bb4021c0b0b33c752850f58cf7e2ea44359b7 (patch)
treed92a56bd24ab29e5019cb1f71f4ef6caf4f204ca /libavfilter/vf_scale_vaapi.c
parentc8467abbadab424757ea23f71a1036abfb7f14b4 (diff)
downloadffmpeg-037bb4021c0b0b33c752850f58cf7e2ea44359b7.tar.gz
avfilter/scale: refactor common code for scaling height/width expressions
Implements support for height/width expressions in vf_scale_vaapi, by refactoring common code into a new libavfilter/scale.c Signed-off-by: Mark Thompson <sw@jkqxz.net>
Diffstat (limited to 'libavfilter/vf_scale_vaapi.c')
-rw-r--r--libavfilter/vf_scale_vaapi.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index d1cb246d1f..604cd95767 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -31,6 +31,7 @@
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
+#include "scale.h"
typedef struct ScaleVAAPIContext {
const AVClass *class;
@@ -50,9 +51,12 @@ typedef struct ScaleVAAPIContext {
char *output_format_string;
enum AVPixelFormat output_format;
- int output_width;
- int output_height;
+ char *w_expr; // width expression string
+ char *h_expr; // height expression string
+
+ int output_width; // computed width
+ int output_height; // computed height
} ScaleVAAPIContext;
@@ -110,6 +114,7 @@ static int scale_vaapi_config_input(AVFilterLink *inlink)
static int scale_vaapi_config_output(AVFilterLink *outlink)
{
+ AVFilterLink *inlink = outlink->src->inputs[0];
AVFilterContext *avctx = outlink->src;
ScaleVAAPIContext *ctx = avctx->priv;
AVVAAPIHWConfig *hwconfig = NULL;
@@ -162,6 +167,12 @@ static int scale_vaapi_config_output(AVFilterLink *outlink)
}
}
+ if ((err = ff_scale_eval_dimensions(ctx,
+ ctx->w_expr, ctx->h_expr,
+ inlink, outlink,
+ &ctx->output_width, &ctx->output_height)) < 0)
+ goto fail;
+
if (ctx->output_width < constraints->min_width ||
ctx->output_height < constraints->min_height ||
ctx->output_width > constraints->max_width ||
@@ -414,9 +425,9 @@ static av_cold void scale_vaapi_uninit(AVFilterContext *avctx)
#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
static const AVOption scale_vaapi_options[] = {
{ "w", "Output video width",
- OFFSET(output_width), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS },
+ OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = FLAGS },
{ "h", "Output video height",
- OFFSET(output_height), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS },
+ OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = FLAGS },
{ "format", "Output video format (software format of hardware frames)",
OFFSET(output_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS },
{ NULL },