From: Fei Wang <fei.w.wang-at-intel.com@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: Fei Wang <fei.w.wang@intel.com> Subject: [FFmpeg-devel] [PATCH v5 2/2] lavc/vaapi_decode: add support for HWACCEL_CAP_RESET_WITHOUT_UNINIT Date: Mon, 14 Nov 2022 09:16:05 +0800 Message-ID: <20221114011605.1157707-2-fei.w.wang@intel.com> (raw) In-Reply-To: <20221114011605.1157707-1-fei.w.wang@intel.com> 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 | 11 ++++++++--- libavcodec/vaapi_decode.h | 1 + libavcodec/vaapi_vp9.c | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 134f10eca5..d950471b6d 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -658,9 +658,6 @@ int ff_vaapi_decode_init(AVCodecContext *avctx) VAStatus vas; int err; - ctx->va_config = VA_INVALID_ID; - ctx->va_context = VA_INVALID_ID; - err = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_VAAPI); if (err < 0) goto fail; @@ -670,6 +667,12 @@ int ff_vaapi_decode_init(AVCodecContext *avctx) ctx->device = ctx->frames->device_ctx; ctx->hwctx = ctx->device->hwctx; + if (ctx->inited) + return 0; + + ctx->va_config = VA_INVALID_ID; + ctx->va_context = VA_INVALID_ID; + err = vaapi_decode_make_config(avctx, ctx->frames->device_ref, &ctx->va_config, NULL); if (err) @@ -691,6 +694,8 @@ int ff_vaapi_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "Decode context initialised: " "%#x/%#x.\n", ctx->va_config, ctx->va_context); + ctx->inited = 1; + return 0; fail: diff --git a/libavcodec/vaapi_decode.h b/libavcodec/vaapi_decode.h index 6beda14e52..62a4f37ed9 100644 --- a/libavcodec/vaapi_decode.h +++ b/libavcodec/vaapi_decode.h @@ -61,6 +61,7 @@ typedef struct VAAPIDecodeContext { int surface_count; VASurfaceAttrib pixel_format_attribute; + int inited; } VAAPIDecodeContext; 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 }; -- 2.25.1 _______________________________________________ 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".
next prev parent reply other threads:[~2022-11-14 1:16 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-14 1:16 [FFmpeg-devel] [PATCH v5 1/2] lavc: add HWACCEL_CAP_RESET_WITHOUT_UNINIT capacity for hwaccel Fei Wang 2022-11-14 1:16 ` Fei Wang [this message] 2022-11-28 13:20 ` [FFmpeg-devel] [PATCH v5 2/2] lavc/vaapi_decode: add support for HWACCEL_CAP_RESET_WITHOUT_UNINIT Mark Thompson 2022-12-01 1:55 ` Wang, Fei W 2022-12-06 8:57 ` Wang, Fei W 2022-11-16 2:02 ` [FFmpeg-devel] [PATCH v5 1/2] lavc: add HWACCEL_CAP_RESET_WITHOUT_UNINIT capacity for hwaccel Wang, Fei W 2022-11-23 11:29 ` Xiang, Haihao 2022-11-23 11:39 ` Xiang, Haihao
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=20221114011605.1157707-2-fei.w.wang@intel.com \ --to=fei.w.wang-at-intel.com@ffmpeg.org \ --cc=fei.w.wang@intel.com \ --cc=ffmpeg-devel@ffmpeg.org \ /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