On 28/02/17 00:31, wm4 wrote: > On Tue, 28 Feb 2017 00:11:26 +0000 > Mark Thompson <[email protected]> wrote: > >> --- >> Don't laugh. >> >> Thanks to wm4 for debugging this issue. >> >> >> libavfilter/vf_deinterlace_vaapi.c | 15 +++++++++++++++ >> libavutil/hwcontext_vaapi.c | 3 ++- >> libavutil/hwcontext_vaapi.h | 5 +++++ >> 3 files changed, 22 insertions(+), 1 deletion(-) >> >> diff --git a/libavfilter/vf_deinterlace_vaapi.c >> b/libavfilter/vf_deinterlace_vaapi.c >> index 526ba6c87..6a983e1d5 100644 >> --- a/libavfilter/vf_deinterlace_vaapi.c >> +++ b/libavfilter/vf_deinterlace_vaapi.c >> @@ -22,6 +22,7 @@ >> #include <va/va_vpp.h> >> >> #include "libavutil/avassert.h" >> +#include "libavutil/common.h" >> #include "libavutil/hwcontext.h" >> #include "libavutil/hwcontext_vaapi.h" >> #include "libavutil/mem.h" >> @@ -210,6 +211,12 @@ static int >> deint_vaapi_build_filter_params(AVFilterContext *avctx) >> return AVERROR(EIO); >> } >> >> + if (ctx->hwctx->driver_quirks & >> + AV_VAAPI_DRIVER_QUIRK_REVERSED_FILTER_REFERENCES) { >> + FFSWAP(unsigned int, ctx->pipeline_caps.num_backward_references, >> + ctx->pipeline_caps.num_forward_references); >> + } >> + >> ctx->queue_depth = ctx->pipeline_caps.num_backward_references + >> ctx->pipeline_caps.num_forward_references + 1; >> if (ctx->queue_depth > MAX_REFERENCES) { >> @@ -488,6 +495,14 @@ static int deint_vaapi_filter_frame(AVFilterLink >> *inlink, AVFrame *input_frame) >> params.num_backward_references = >> ctx->pipeline_caps.num_backward_references; >> >> + if (ctx->hwctx->driver_quirks & >> + AV_VAAPI_DRIVER_QUIRK_REVERSED_FILTER_REFERENCES) { >> + FFSWAP(VASurfaceID*, params.forward_references, >> + params.backward_references); >> + FFSWAP(unsigned int, params.num_forward_references, >> + params.num_backward_references); >> + } >> + >> } else { >> params.filters = NULL; >> params.num_filters = 0; >> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c >> index 23bce7660..bfe4d078a 100644 >> --- a/libavutil/hwcontext_vaapi.c >> +++ b/libavutil/hwcontext_vaapi.c >> @@ -265,7 +265,8 @@ static const struct { >> { >> "Intel i965 (Quick Sync)", >> "i965", >> - AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS, >> + AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS | >> + AV_VAAPI_DRIVER_QUIRK_REVERSED_FILTER_REFERENCES, >> }, >> { >> "Intel iHD", >> diff --git a/libavutil/hwcontext_vaapi.h b/libavutil/hwcontext_vaapi.h >> index 529d26e07..4b17f3f78 100644 >> --- a/libavutil/hwcontext_vaapi.h >> +++ b/libavutil/hwcontext_vaapi.h >> @@ -58,6 +58,11 @@ enum { >> * and the results of the vaQuerySurfaceAttributes() call will be faked. >> */ >> AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES = (1 << 3), >> + >> + /** >> + * The driver requires past frames as forward references. >> + */ >> + AV_VAAPI_DRIVER_QUIRK_REVERSED_FILTER_REFERENCES = (1 << 4), >> }; >> >> /** > > Yeah, that's apparently the result of my debugging sessions. Could you > confirm this, and does it really happen only with this driver?
Yes. I tested all of this on Skylake with the i965 driver, Skylake with the Media SDK iHD driver, and Polaris with the Mesa/Gallium driver. > I also asked a kodi person to confirm. (Apparently they've been > successfully using it with switched references.) _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
