---
configure| 3 +
libavfilter/Makefile | 1 +
libavfilter/allfilters.c | 1 +
libavfilter/vf_scale_vaapi.c | 451 +++
4 files changed, 456 insertions(+)
create mode 100644 libavfilter/vf_scale_vaapi.c
diff --git a/configure b/configure
index 76d028d..b1aed3a 100755
--- a/configure
+++ b/configure
@@ -2360,6 +2360,7 @@ interlace_filter_deps="gpl"
ocv_filter_deps="libopencv"
resample_filter_deps="avresample"
scale_filter_deps="swscale"
+scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
# examples
avcodec_example_deps="avcodec avutil"
@@ -4458,6 +4459,8 @@ check_type "windows.h dxva.h" "DXVA_PicParams_HEVC"
-DWINAPI_FAMILY=WINAPI_FAMIL
check_type "windows.h d3d11.h" "ID3D11VideoDecoder"
check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
+check_type "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer"
+
check_type "vdpau/vdpau.h" "VdpPictureInfoHEVC"
if ! disabled w32threads && ! enabled pthreads; then
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fa6647b..0f9643d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -71,6 +71,7 @@ OBJS-$(CONFIG_OVERLAY_FILTER)+= vf_overlay.o
OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
OBJS-$(CONFIG_PIXDESCTEST_FILTER)+= vf_pixdesctest.o
OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o
+OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o
OBJS-$(CONFIG_SELECT_FILTER) += vf_select.o
OBJS-$(CONFIG_SETDAR_FILTER) += vf_aspect.o
OBJS-$(CONFIG_SETPTS_FILTER) += setpts.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9461145..a2ff4d2 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -108,6 +108,7 @@ void avfilter_register_all(void)
REGISTER_FILTER(TRANSPOSE, transpose, vf);
REGISTER_FILTER(TRIM, trim, vf);
REGISTER_FILTER(UNSHARP,unsharp,vf);
+REGISTER_FILTER(SCALE_VAAPI,scale_vaapi,vf);
REGISTER_FILTER(VFLIP, vflip, vf);
REGISTER_FILTER(YADIF, yadif, vf);
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
new file mode 100644
index 000..fcf8348
--- /dev/null
+++ b/libavfilter/vf_scale_vaapi.c
@@ -0,0 +1,451 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav 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,
+ * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include
+
+#include
+#include
+
+#include "libavutil/avassert.h"
+#include "libavutil/hwcontext.h"
+#include "libavutil/hwcontext_vaapi.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+
+typedef struct ScaleVAAPIContext {
+const AVClass *class;
+
+AVVAAPIDeviceContext *hwctx;
+AVBufferRef *device_ref;
+
+VAConfigID va_config;
+VAContextID va_context;
+
+AVBufferRef *input_frames_ref;
+AVHWFramesContext *input_frames;
+
+AVBufferRef *output_frames_ref;
+AVHWFramesContext *output_frames;
+
+char *output_format_string;
+enum AVPixelFormat output_format;
+int output_width;
+int output_height;
+
+} ScaleVAAPIContext;
+
+
+static int scale_vaapi_query_formats(AVFilterContext *avctx)
+{
+enum AVPixelFormat pix_fmts[] = {
+AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE,
+};
+
+ff_formats_ref(ff_make_format_list(pix_fmts),
+ >inputs[0]->out_formats);
+ff_formats_ref(ff_make_format_list(pix_fmts),
+ >outputs[0]->in_formats);
+
+return 0;
+}
+
+static int scale_vaapi_pipeline_uninit(ScaleVAAPIContext *ctx)
+{
+if (ctx->va_context != VA_INVALID_ID) {
+vaDestroyContext(ctx->hwctx->display, ctx->va_context);
+ctx->va_context = VA_INVALID_ID;
+}
+
+if (ctx->va_config != VA_INVALID_ID) {
+vaDestroyConfig(ctx->hwctx->display, ctx->va_config);
+ctx->va_config = VA_INVALID_ID;
+}
+
+av_buffer_unref(>output_frames_ref);
+av_buffer_unref(>device_ref);
+ctx->hwctx = 0;
+
+return 0;
+}
+
+static int scale_vaapi_config_input(AVFilterLink *inlink)
+{
+AVFilterContext *avctx =