[FFmpeg-devel] [PATCH v2] avfilter/qsvvpp: Work around a bug in MSDK where VPP processing hangs under certain conditions

Soft Works softworkz at hotmail.com
Sun Jun 7 02:40:05 EEST 2020



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Max Dmitrichenko
> Sent: Saturday, June 6, 2020 2:54 PM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter/qsvvpp: Work around a bug
> in MSDK where VPP processing hangs under certain conditions
> 
> On Sat, Jun 6, 2020 at 7:29 AM Soft Works <softworkz at hotmail.com> wrote:
> 
> >
> >
> > > -----Original Message-----
> > > From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> > > Max Dmitrichenko
> > > Sent: Friday, June 5, 2020 3:09 PM
> > > To: FFmpeg development discussions and patches <ffmpeg-
> > > devel at ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter/qsvvpp: Work around
> > > a bug in MSDK where VPP processing hangs under certain conditions
> > >
> > > On Mon, May 25, 2020 at 12:40 AM Soft Works
> <softworkz at hotmail.com>
> > > wrote:
> > >
> > > > These are:
> > > > - Dimensions are already aligned (e.g. 1920x800)
> > > > - No scaling is done
> > > > - Color format conversion (e.g. 10bit to 8bit)
> > > >
> > > > Example command:
> > > > ffmpeg -c:v hevc_qsv -hwaccel qsv -i hevc_10bit_1920_800.mkv
> > > > -filter_complex "scale_qsv=format=nv12" -c:v h264_qsv out.mkv
> > > >
> > > > Fix:
> > > > - Increase the frame height to the next alignment value
> > > >
> > > > V2:
> > > > - removed empty line
> > > > - removed duplicated line
> > > > ---
> > > >  libavfilter/qsvvpp.c       | 7 ++++++-
> > > >  libavfilter/vf_scale_qsv.c | 9 ++++++++-
> > > >  2 files changed, 14 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> > > > 1bbb7a7e68..98d2353d1c 100644
> > > > --- a/libavfilter/qsvvpp.c
> > > > +++ b/libavfilter/qsvvpp.c
> > > > @@ -420,6 +420,7 @@ static int init_vpp_session(AVFilterContext
> > > > *avctx, QSVVPPContext *s)
> > > >      mfxHandleType handle_type;
> > > >      mfxVersion ver;
> > > >      mfxIMPL impl;
> > > > +    int height_align_adjust = 0;
> > > >      int ret, i;
> > > >
> > > >      if (inlink->hw_frames_ctx) {
> > > > @@ -463,9 +464,13 @@ static int init_vpp_session(AVFilterContext
> > > > *avctx, QSVVPPContext *s)
> > > >          out_frames_ctx   = (AVHWFramesContext *)out_frames_ref-
> >data;
> > > >          out_frames_hwctx = out_frames_ctx->hwctx;
> > > >
> > > > +        /* work around a bug in MSDK where VPP processing hangs
> > > > + under
> > > > certain conditions */
> > > > +        if (inlink->h == outlink->h)
> > > > +            height_align_adjust = 1;
> > > > +
> > > >          out_frames_ctx->format            = AV_PIX_FMT_QSV;
> > > >          out_frames_ctx->width             = FFALIGN(outlink->w, 32);
> > > > -        out_frames_ctx->height            = FFALIGN(outlink->h, 32);
> > > > +        out_frames_ctx->height            = FFALIGN(outlink->h +
> > > > height_align_adjust, 32);
> > > >          out_frames_ctx->sw_format         = s->out_sw_format;
> > > >          out_frames_ctx->initial_pool_size = 64;
> > > >          if (avctx->extra_hw_frames > 0) diff --git
> > > > a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index
> > > > 5259104a4f..303d2101a9 100644
> > > > --- a/libavfilter/vf_scale_qsv.c
> > > > +++ b/libavfilter/vf_scale_qsv.c
> > > > @@ -181,8 +181,10 @@ static int init_out_pool(AVFilterContext *ctx,
> > > >      AVQSVFramesContext *out_frames_hwctx;
> > > >      enum AVPixelFormat in_format;
> > > >      enum AVPixelFormat out_format;
> > > > +    int height_align_adjust = 0;
> > > >      int i, ret;
> > > >
> > > >      /* check that we have a hw context */
> > > >      if (!ctx->inputs[0]->hw_frames_ctx) {
> > > >          av_log(ctx, AV_LOG_ERROR, "No hw context provided on
> > > > input\n"); @@ -191,6 +193,7 @@ static int
> > > > init_out_pool(AVFilterContext
> > > *ctx,
> > > >      in_frames_ctx   =
> > > > (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data;
> > > >      in_frames_hwctx = in_frames_ctx->hwctx;
> > > >
> > > >      in_format     = in_frames_ctx->sw_format;
> > > >      out_format    = (s->format == AV_PIX_FMT_NONE) ? in_format :
> > > > s->format;
> > > >
> > > > @@ -200,9 +203,13 @@ static int init_out_pool(AVFilterContext *ctx,
> > > >      out_frames_ctx   = (AVHWFramesContext*)outlink-
> >hw_frames_ctx-
> > > >data;
> > > >      out_frames_hwctx = out_frames_ctx->hwctx;
> > > >
> > > > +    /* work around a bug in MSDK where VPP processing hangs under
> > > > + certain
> > > > conditions */
> > > > +    if (in_frames_ctx->height == out_height)
> > > > +        height_align_adjust = 1;
> > > > +
> > > >      out_frames_ctx->format            = AV_PIX_FMT_QSV;
> > > >      out_frames_ctx->width             = FFALIGN(out_width,  16);
> > > > -    out_frames_ctx->height            = FFALIGN(out_height, 16);
> > > > +    out_frames_ctx->height            = FFALIGN(out_height +
> > > > height_align_adjust, 16);
> > > >      out_frames_ctx->sw_format         = out_format;
> > > >      out_frames_ctx->initial_pool_size = 4;
> > > >
> > > > --
> > > > 2.26.2.windows.1
> > > >
> > > >
> > > patch seems to be manually edited and cannot be applied automatically.
> > >
> > > During my tests, I couldn't see any change of behavior with and
> > > without patch, more details needed for patch justification.
> >
> > Well, before talking about the patch - the question is whether you can
> > reproduce the hang with the video file I sent you and the command line
> > above?
> >
> > It should be reproducible with drivers corresponding to MSDK 1.31 I
> > haven't tried with the latest ones (1.32).
> >
> 
> Exact driver version is more important than MSDK API version, as there can
> be the same MSDK API version across different versions of GPU driver.
> 
> No hang is visible with the latest drivers.


Hi Max,

thanks for replying.

Intel Driver Numbers are difficult to understand.
At the low-level it's those numbers:

                            "DeviceName": "\\\\.\\DISPLAY5",
                            "DirectXType": "DX9",
                            "Description": "Intel(R) HD Graphics 530",
                            "Driver": "igdumdim64.dll",
                            "DeviceId": 6418,
                            "VendorId": 32902,
                            "DriverVersionMajor": 1703956,
                            "DriverVersionMinor": 6561470,
                            "SubSysId": 2257850435,
                            "DeviceGuid": "{d7b78e66-5a52-11cf-4d6d-f0a6bdc2d735}",
                            "ApiVersionMajor": 1,
                            "ApiVersionMinor": 31







More information about the ffmpeg-devel mailing list