summaryrefslogtreecommitdiff
path: root/libavfilter/vf_scale_vaapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavfilter/vf_scale_vaapi.c')
-rw-r--r--libavfilter/vf_scale_vaapi.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index 50be68eee0..22e928c098 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -1,18 +1,18 @@
/*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -31,6 +31,7 @@
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
+#include "scale.h"
#include "video.h"
typedef struct ScaleVAAPIContext {
@@ -51,9 +52,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;
@@ -62,11 +66,14 @@ static int scale_vaapi_query_formats(AVFilterContext *avctx)
enum AVPixelFormat pix_fmts[] = {
AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE,
};
+ int err;
- ff_formats_ref(ff_make_format_list(pix_fmts),
- &avctx->inputs[0]->out_formats);
- ff_formats_ref(ff_make_format_list(pix_fmts),
- &avctx->outputs[0]->in_formats);
+ if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
+ &avctx->inputs[0]->out_formats)) < 0)
+ return err;
+ if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
+ &avctx->outputs[0]->in_formats)) < 0)
+ return err;
return 0;
}
@@ -111,6 +118,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;
@@ -163,6 +171,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 ||
@@ -347,7 +361,7 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
goto fail_after_render;
}
- if (ctx->hwctx->driver_quirks &
+ if (CONFIG_VAAPI_1 || ctx->hwctx->driver_quirks &
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) {
vas = vaDestroyBuffer(ctx->hwctx->display, params_id);
if (vas != VA_STATUS_SUCCESS) {
@@ -416,12 +430,12 @@ static av_cold void scale_vaapi_uninit(AVFilterContext *avctx)
#define OFFSET(x) offsetof(ScaleVAAPIContext, x)
-#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM)
+#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 },