/*
- * 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
*/
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
+#include "scale.h"
#include "video.h"
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;
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;
}
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;
}
}
+ 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 ||
#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 },