From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 9CB6044ED9 for ; Mon, 28 Nov 2022 13:21:25 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D491568B52B; Mon, 28 Nov 2022 15:21:21 +0200 (EET) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91586680CB2 for ; Mon, 28 Nov 2022 15:21:15 +0200 (EET) Received: by mail-wr1-f46.google.com with SMTP id q7so15878731wrr.8 for ; Mon, 28 Nov 2022 05:21:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=J2gMLIRz3vYann+9T0YLkum25SvQVdR/xfC3iuSDQXQ=; b=Z/WwHm6UWaNE0zwPZQnMIRX9Xb/kcXZ2KiuoPRAXRy4jKz5wbhVJSBOz2016/FdMdt jzPHvI0hj39SNMMbEUu+P0oIzHYB0RGfO6vag6BSMX1oSCf4CgLDUNvC6HeRZHYw24WL gB4LuEfYrub9h9y0SECp6msgl6pt3cVW1GjhZuAInibjtI8eZLY1GusdBNt/ANkMVw0O KcsRVhASL6SdVZlS4K5TtPyFOD8MDvgkHsGQ9c99HAePJqWeYpESOa1nOf2S5oSGUUsz GdQ9EYt6zoG3rBebaXqifVLMwZxcRODTQkqUaAkvej6ZHecWQMgGa+/OsNUgrDN/aYMh 6eOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J2gMLIRz3vYann+9T0YLkum25SvQVdR/xfC3iuSDQXQ=; b=B59JEfxlP40uJvlV020dpg/menbACV1HYFSgZQWnKf09PjRS3nWnBbKrn+3uO4lay8 PXVd/dUecOAk9mbcFzbFctuU6WA8GsEM3kY8ZpV1pjhYu0Zzi4d0clOJlAR28NkHZI0m xk5GEJyX/Ufbo6rQGhw5F6mmeEOCVYlW9Uy1wqnMmDTmUAKoe2giYz6EUFTqhj9zMKbs sm563bjOcUKM3jRtEkv7APRSJlABcdmrJBvZcb3ZvDMy/D/Wb1IA5M/c8tCSzem68ud/ /c8hSeJJ6URo4QlgUEul+r10/MYyPQSRYXjv/xpjZpuGvJlKFhBnjfBrAOOK0/Fw2+cz ELhQ== X-Gm-Message-State: ANoB5pmLUwfOvTRCe9TkaPAAUkYVFAHTyoRPwWFyX182TAhHkW+dq63+ iULTx/spQixPM2yRCHIcWtaou8olHdp3GA== X-Google-Smtp-Source: AA0mqf4MlJlayVscW3Z+wtDrrl3X4Vam0vKaQXlYfPtvJzjRw3CWPlb8VGPeHuHU9W/42O243ZPH5w== X-Received: by 2002:a05:6000:233:b0:241:d79a:951c with SMTP id l19-20020a056000023300b00241d79a951cmr21925800wrz.445.1669641674591; Mon, 28 Nov 2022 05:21:14 -0800 (PST) Received: from [192.168.0.14] (cpc91224-cmbg18-2-0-cust209.5-4.cable.virginm.net. [81.106.228.210]) by smtp.gmail.com with ESMTPSA id w13-20020adfec4d000000b00241dd5de644sm10827451wrn.97.2022.11.28.05.21.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Nov 2022 05:21:14 -0800 (PST) Message-ID: Date: Mon, 28 Nov 2022 13:20:56 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20221114011605.1157707-1-fei.w.wang@intel.com> <20221114011605.1157707-2-fei.w.wang@intel.com> From: Mark Thompson In-Reply-To: <20221114011605.1157707-2-fei.w.wang@intel.com> Subject: Re: [FFmpeg-devel] [PATCH v5 2/2] lavc/vaapi_decode: add support for HWACCEL_CAP_RESET_WITHOUT_UNINIT X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 14/11/2022 01:16, 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 > --- > libavcodec/vaapi_decode.c | 11 ++++++++--- > libavcodec/vaapi_decode.h | 1 + > libavcodec/vaapi_vp9.c | 4 ++++ > 3 files changed, 13 insertions(+), 3 deletions(-) This always segfaults immediately on anything unsupported. E.g. with fate/hevc/paramchange_yuv420p_yuv420p10.hevc: [hevc @ 0x555557c0e7c0] Format vaapi chosen by get_format(). [hevc @ 0x555557c0e7c0] Format vaapi requires hwaccel initialisation. [hevc @ 0x555557c0e7c0] Hardware does not support image size 1056x8440 (constraints: width 0-4096 height 0-4096). Thread 20 "av:hevc:df0" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffb4ff9700 (LWP 509456)] ff_vaapi_decode_uninit (avctx=0x555557c0e7c0) at src/libavcodec/vaapi_decode.c:714 714 vas = vaDestroyContext(ctx->hwctx->display, ctx->va_context); (gdb) bt #0 ff_vaapi_decode_uninit (avctx=0x555557c0e7c0) at src/libavcodec/vaapi_decode.c:714 #1 0x00005555563073d7 in ff_vaapi_decode_init (avctx=0x555557c0e7c0) at src/libavcodec/vaapi_decode.c:704 #2 0x0000555555e62fee in hwaccel_init (avctx=0x555557c0e7c0, hw_config=0x55555728f770 <__compound_literal.0>) at src/libavcodec/decode.c:1121 #3 0x0000555555e634ec in ff_get_format (avctx=0x555557c0e7c0, fmt=0x7fffb4ff8ccc) at src/libavcodec/decode.c:1261 #4 0x00005555561ca829 in ff_thread_get_format (avctx=0x555557c0e7c0, fmt=0x7fffb4ff8ccc) at src/libavcodec/pthread_frame.c:1048 #5 0x0000555555f68f37 in get_format (s=0x555557c3e6c0, sps=0x555557c21f80) at src/libavcodec/hevcdec.c:505 #6 0x0000555555f69621 in hls_slice_header (s=0x555557c3e6c0) at src/libavcodec/hevcdec.c:618 #7 0x0000555555f7472d in decode_nal_unit (s=0x555557c3e6c0, nal=0x7fff8802e920) at src/libavcodec/hevcdec.c:3173 #8 0x0000555555f7508a in decode_nal_units (s=0x555557c3e6c0, buf=0x7ffff637c010 "", length=159280) at src/libavcodec/hevcdec.c:3355 #9 0x0000555555f756d6 in hevc_decode_frame (avctx=0x555557c0e7c0, rframe=0x555557c0ecc0, got_output=0x555557c0d690, avpkt=0x555557c0ef40) at src/libavcodec/hevcdec.c:3497 #10 0x00005555561c839c in frame_worker_thread (arg=0x555557c0d580) at src/libavcodec/pthread_frame.c:241 #11 0x00007ffff68ccea7 in start_thread (arg=) at pthread_create.c:477 #12 0x00007ffff67ecaef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 (gdb) Also, I don't see how this is testing whether the driver supports changing the resolution at runtime? The note in libva that you cite allows new switching render targets in the context, but I don't see why different resolution would be allowed given that it's a parameter passed to vaCreateContext()? Looking at the Mesa driver it appears that the internally-allocated references are not going to allow size changes (where does the template width get updated?). I don't have any hardware to test that, though - are you able to try this on recent AMD hardware with VP9 support? What have you done to verify the METHOD_HW_FRAMES_CTX behaviour? This has changed so that vaapi_decode_make_config() is no longer called, which feels possibly-bad though I'm unsure of the exact consequences. As I said last time, I do think you should only do this in exactly the places where it is required, and not change any other behaviour. Thanks, - Mark > 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 > }; _______________________________________________ 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".