From: "Wang, Fei W" <fei.w.wang-at-intel.com@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>,
"Xiang, Haihao" <haihao.xiang@intel.com>
Subject: Re: [FFmpeg-devel] [PATCH v4 2/2] lavc/vaapi_decode: add support for HWACCEL_CAP_RESET_WITHOUT_UNINIT
Date: Mon, 14 Nov 2022 01:19:31 +0000
Message-ID: <032d4e510af1f87b3afb09529e6c0b0110036750.camel@intel.com> (raw)
In-Reply-To: <ff50c08fe6205cdddf349d5a9c93b0122a0f583c.camel@intel.com>
On Fri, 2022-11-11 at 03:45 +0000, Xiang, Haihao wrote:
> On Tue, 2022-11-08 at 19:45 +0800, Fei Wang wrote:
> > This can fix vp9 decode image corruption when the frame size is
> > change,
> > but the pervious frames still be referenced.
> >
> > Surfaces don't need to be bound to vaContext only after VAAPI
> > 1.0.0:
> > https://github.com/intel/libva/commit/492b692005ccd0d8da190209d5b3ae7b7825f4b8
> >
> > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > ---
> > libavcodec/vaapi_decode.c | 41 ++++++++++++++++++++++-------------
> > ----
> > libavcodec/vaapi_vp9.c | 4 ++++
> > 2 files changed, 27 insertions(+), 18 deletions(-)
> >
> > diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> > index 134f10eca5..618f3c3e0a 100644
> > --- a/libavcodec/vaapi_decode.c
> > +++ b/libavcodec/vaapi_decode.c
> > @@ -658,8 +658,10 @@ int ff_vaapi_decode_init(AVCodecContext
> > *avctx)
> > VAStatus vas;
> > int err;
> >
> > - ctx->va_config = VA_INVALID_ID;
> > - ctx->va_context = VA_INVALID_ID;
> > + if (!ctx->va_config && !ctx->va_context) {
> > + ctx->va_config = VA_INVALID_ID;
> > + ctx->va_context = VA_INVALID_ID;
> > + }
>
> 0 is valid for VA config and context, it is possible the underlying
> driver
> creates VA config and context with id 0.
Fixed in V5. Thanks.
Fei
>
> Thanks
> Haihao
>
> >
> > err = ff_decode_get_hw_frames_ctx(avctx,
> > AV_HWDEVICE_TYPE_VAAPI);
> > if (err < 0)
> > @@ -670,24 +672,27 @@ int ff_vaapi_decode_init(AVCodecContext
> > *avctx)
> > ctx->device = ctx->frames->device_ctx;
> > ctx->hwctx = ctx->device->hwctx;
> >
> > - err = vaapi_decode_make_config(avctx, ctx->frames->device_ref,
> > - &ctx->va_config, NULL);
> > - if (err)
> > - goto fail;
> > -
> > - vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
> > - avctx->coded_width, avctx->coded_height,
> > - VA_PROGRESSIVE,
> > - ctx->hwfc->surface_ids,
> > - ctx->hwfc->nb_surfaces,
> > - &ctx->va_context);
> > - if (vas != VA_STATUS_SUCCESS) {
> > - av_log(avctx, AV_LOG_ERROR, "Failed to create decode "
> > - "context: %d (%s).\n", vas, vaErrorStr(vas));
> > - err = AVERROR(EIO);
> > - goto fail;
> > + if (ctx->va_config == VA_INVALID_ID) {
> > + err = vaapi_decode_make_config(avctx, ctx->frames-
> > >device_ref,
> > + &ctx->va_config, NULL);
> > + if (err)
> > + goto fail;
> > }
> >
> > + if (ctx->va_context == VA_INVALID_ID) {
> > + vas = vaCreateContext(ctx->hwctx->display, ctx->va_config,
> > + avctx->coded_width, avctx-
> > >coded_height,
> > + VA_PROGRESSIVE,
> > + ctx->hwfc->surface_ids,
> > + ctx->hwfc->nb_surfaces,
> > + &ctx->va_context);
> > + if (vas != VA_STATUS_SUCCESS) {
> > + av_log(avctx, AV_LOG_ERROR, "Failed to create decode "
> > + "context: %d (%s).\n", vas, vaErrorStr(vas));
> > + err = AVERROR(EIO);
> > + goto fail;
> > + }
> > + }
> > av_log(avctx, AV_LOG_DEBUG, "Decode context initialised: "
> > "%#x/%#x.\n", ctx->va_config, ctx->va_context);
> >
> > diff --git a/libavcodec/vaapi_vp9.c b/libavcodec/vaapi_vp9.c
> > index 776382f683..245b7a1b3a 100644
> > --- a/libavcodec/vaapi_vp9.c
> > +++ b/libavcodec/vaapi_vp9.c
> > @@ -181,5 +181,9 @@ const AVHWAccel ff_vp9_vaapi_hwaccel = {
> > .uninit = ff_vaapi_decode_uninit,
> > .frame_params = ff_vaapi_common_frame_params,
> > .priv_data_size = sizeof(VAAPIDecodeContext),
> > +#if VA_CHECK_VERSION(1, 0, 0)
> > + .caps_internal = HWACCEL_CAP_ASYNC_SAFE |
> > HWACCEL_CAP_RESET_WITHOUT_UNINIT,
> > +#else
> > .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
> > +#endif
> > };
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2022-11-14 1:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 11:45 [FFmpeg-devel] [PATCH v4 1/2] lavc: add HWACCEL_CAP_RESET_WITHOUT_UNINIT capacity for hwaccel Fei Wang
2022-11-08 11:45 ` [FFmpeg-devel] [PATCH v4 2/2] lavc/vaapi_decode: add support for HWACCEL_CAP_RESET_WITHOUT_UNINIT Fei Wang
2022-11-11 3:45 ` Xiang, Haihao
2022-11-14 1:19 ` Wang, Fei W [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=032d4e510af1f87b3afb09529e6c0b0110036750.camel@intel.com \
--to=fei.w.wang-at-intel.com@ffmpeg.org \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=haihao.xiang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git