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 v4 1/2] lavc: add HWACCEL_CAP_RESET_WITHOUT_UNINIT capacity for hwaccel Date: Tue, 8 Nov 2022 19:45:00 +0800 Message-ID: <20221108114501.570349-1-fei.w.wang@intel.com> (raw) The capacity can avoid hwaccel being uninited when do the reset. It provides the method for hwaccel if it still want to use the previous initialized configuration after reset. And the configuration can be updated in AVHWAccel.init() if needed. For example, when use vaapi vp9 decode dynamic resolution clips, need to avoid changing vaContext in avctx->internal->hwaccel_priv_data if current frame resolution change and it reference a pervious frame with different resolution. Otherwise reference frame's information bound in vaContext will be lost, then corrupt current frame. Signed-off-by: Fei Wang <fei.w.wang@intel.com> --- libavcodec/decode.c | 10 ++++++---- libavcodec/hwconfig.h | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 6be2d3d6ed..cfada048e8 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1109,7 +1109,7 @@ static int hwaccel_init(AVCodecContext *avctx, return AVERROR_PATCHWELCOME; } - if (hwaccel->priv_data_size) { + if (hwaccel->priv_data_size && !avctx->internal->hwaccel_priv_data) { avctx->internal->hwaccel_priv_data = av_mallocz(hwaccel->priv_data_size); if (!avctx->internal->hwaccel_priv_data) @@ -1134,10 +1134,12 @@ static int hwaccel_init(AVCodecContext *avctx, static void hwaccel_uninit(AVCodecContext *avctx) { - if (avctx->hwaccel && avctx->hwaccel->uninit) - avctx->hwaccel->uninit(avctx); + if (avctx->hwaccel && !(avctx->hwaccel->caps_internal & HWACCEL_CAP_RESET_WITHOUT_UNINIT)) { + if (avctx->hwaccel->uninit) + avctx->hwaccel->uninit(avctx); - av_freep(&avctx->internal->hwaccel_priv_data); + av_freep(&avctx->internal->hwaccel_priv_data); + } avctx->hwaccel = NULL; diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h index 721424912c..5fb4e06d5f 100644 --- a/libavcodec/hwconfig.h +++ b/libavcodec/hwconfig.h @@ -25,6 +25,13 @@ #define HWACCEL_CAP_ASYNC_SAFE (1 << 0) +/** + * The hwaccel supports reset without calling back AVHWAccel.uninit() + * and realloc avctx->internal->hwaccel_priv_data. + * + * New configuration can set up through AVHWAccel.init(). + */ +#define HWACCEL_CAP_RESET_WITHOUT_UNINIT (1 << 1) typedef struct AVCodecHWConfigInternal { /** -- 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 reply other threads:[~2022-11-08 11:45 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-08 11:45 Fei Wang [this message] 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
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=20221108114501.570349-1-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